jonathanjordan21 commited on
Commit
28bce37
1 Parent(s): ca5271c

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +34 -28
apis/chat_api.py CHANGED
@@ -155,32 +155,33 @@ class ChatAPIApp:
155
  default=False,
156
  description="(bool) Stream",
157
  )
158
- options: dict = Field(
159
- default={
160
- "temperature":0.5,
161
- "top_p":0.95,
162
- "max_tokens":-1,
163
- "use_cache":False
164
- },
165
- description="(dict) Options"
166
- )
167
- # temperature: Union[float, None] = Field(
168
- # default=0.5,
169
- # description="(float) Temperature",
170
- # )
171
- # top_p: Union[float, None] = Field(
172
- # default=0.95,
173
- # description="(float) top p",
174
- # )
175
- # max_tokens: Union[int, None] = Field(
176
- # default=-1,
177
- # description="(int) Max tokens",
178
- # )
179
- # use_cache: bool = Field(
180
- # default=False,
181
- # description="(bool) Use cache",
182
  # )
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  def generate_text(
186
  self, item: GenerateRequest, api_key: str = Depends(extract_api_key)
@@ -200,11 +201,16 @@ class ChatAPIApp:
200
  streamer = HuggingfaceStreamer(model=item.model)
201
  stream_response = streamer.chat_response(
202
  prompt=item.prompt,
203
- temperature=item.options.get('temperature', 0.6),
204
- top_p=item.options.get('top_p', 0.95),
205
- max_new_tokens=item.options.get('max_new_tokens', -1),
206
  api_key=api_key,
207
- use_cache=item.options.get('use_cache', False),
 
 
 
 
 
208
  )
209
 
210
  if item.stream:
 
155
  default=False,
156
  description="(bool) Stream",
157
  )
158
+ # options: dict = Field(
159
+ # default={
160
+ # "temperature":0.5,
161
+ # "top_p":0.95,
162
+ # "max_tokens":-1,
163
+ # "use_cache":False
164
+ # },
165
+ # description="(dict) Options"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  # )
167
 
168
+ temperature: Union[float, None] = Field(
169
+ default=0.5,
170
+ description="(float) Temperature",
171
+ )
172
+ top_p: Union[float, None] = Field(
173
+ default=0.95,
174
+ description="(float) top p",
175
+ )
176
+ max_tokens: Union[int, None] = Field(
177
+ default=-1,
178
+ description="(int) Max tokens",
179
+ )
180
+ use_cache: bool = Field(
181
+ default=False,
182
+ description="(bool) Use cache",
183
+ )
184
+
185
 
186
  def generate_text(
187
  self, item: GenerateRequest, api_key: str = Depends(extract_api_key)
 
201
  streamer = HuggingfaceStreamer(model=item.model)
202
  stream_response = streamer.chat_response(
203
  prompt=item.prompt,
204
+ temperature=item.temperature,
205
+ top_p=item.top_p,
206
+ max_new_tokens=item.max_tokens,
207
  api_key=api_key,
208
+ use_cache=item.use_cache,
209
+ # temperature=item.options.get('temperature', 0.6),
210
+ # top_p=item.options.get('top_p', 0.95),
211
+ # max_new_tokens=item.options.get('max_new_tokens', -1),
212
+ # api_key=api_key,
213
+ # use_cache=item.options.get('use_cache', False),
214
  )
215
 
216
  if item.stream: