Spaces:
Sleeping
Sleeping
Commit
·
e7fc387
1
Parent(s):
9c6d092
hotfix
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ def respond(
|
|
32 |
|
33 |
response = ""
|
34 |
|
35 |
-
if
|
36 |
cohere_response = client_cohere.chat(
|
37 |
message=message,
|
38 |
model=COHERE_MODEL,
|
@@ -42,16 +42,16 @@ def respond(
|
|
42 |
response = cohere_response.text
|
43 |
yield response
|
44 |
else:
|
45 |
-
for message in
|
46 |
messages,
|
47 |
max_tokens=max_tokens,
|
|
|
48 |
temperature=temperature,
|
49 |
top_p=top_p,
|
50 |
):
|
51 |
-
token = message.choices[0].delta.content
|
52 |
-
|
53 |
response += token
|
54 |
-
yield response
|
55 |
|
56 |
|
57 |
"""
|
|
|
32 |
|
33 |
response = ""
|
34 |
|
35 |
+
if use_cohere_api:
|
36 |
cohere_response = client_cohere.chat(
|
37 |
message=message,
|
38 |
model=COHERE_MODEL,
|
|
|
42 |
response = cohere_response.text
|
43 |
yield response
|
44 |
else:
|
45 |
+
for message in client_hf.chat_completion(
|
46 |
messages,
|
47 |
max_tokens=max_tokens,
|
48 |
+
stream=True,
|
49 |
temperature=temperature,
|
50 |
top_p=top_p,
|
51 |
):
|
52 |
+
token = message.choices[0].delta.content # Extract generated token
|
|
|
53 |
response += token
|
54 |
+
yield response # Yield response incrementally
|
55 |
|
56 |
|
57 |
"""
|