Spaces:
Sleeping
Sleeping
jonathanjordan21
commited on
Commit
•
f9ac435
1
Parent(s):
198a4f7
Update apis/chat_api.py
Browse files- apis/chat_api.py +32 -30
apis/chat_api.py
CHANGED
@@ -155,33 +155,33 @@ class ChatAPIApp:
|
|
155 |
default=False,
|
156 |
description="(bool) Stream",
|
157 |
)
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
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)
|
@@ -199,13 +199,15 @@ class ChatAPIApp:
|
|
199 |
)
|
200 |
else:
|
201 |
streamer = HuggingfaceStreamer(model=item.model)
|
|
|
202 |
stream_response = streamer.chat_response(
|
203 |
prompt=item.prompt,
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
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),
|
|
|
155 |
default=False,
|
156 |
description="(bool) Stream",
|
157 |
)
|
158 |
+
options: dict = Field(
|
159 |
+
default={
|
160 |
+
"temperature":0.6,
|
161 |
+
"top_p":0.9,
|
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)
|
|
|
199 |
)
|
200 |
else:
|
201 |
streamer = HuggingfaceStreamer(model=item.model)
|
202 |
+
options = {k:v for k,v in item.options.items() if v is not None}
|
203 |
stream_response = streamer.chat_response(
|
204 |
prompt=item.prompt,
|
205 |
+
**options,
|
206 |
+
# temperature=item.temperature,
|
207 |
+
# top_p=item.top_p,
|
208 |
+
# max_new_tokens=item.max_tokens,
|
209 |
+
# api_key=api_key,
|
210 |
+
# use_cache=item.use_cache,
|
211 |
# temperature=item.options.get('temperature', 0.6),
|
212 |
# top_p=item.options.get('top_p', 0.95),
|
213 |
# max_new_tokens=item.options.get('max_new_tokens', -1),
|