Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -53,17 +53,28 @@ def respond(
|
|
53 |
response = ""
|
54 |
|
55 |
# Stream response tokens from the chat completion API
|
56 |
-
for message_chunk in client.chat_completion(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
model = "google/gemma-2b-it",
|
58 |
messages=messages,
|
59 |
max_tokens=max_tokens,
|
60 |
stream=True,
|
61 |
temperature=temperature,
|
62 |
top_p=top_p,
|
63 |
-
)
|
64 |
-
|
65 |
-
|
66 |
-
yield response
|
67 |
|
68 |
# Create a Gradio ChatInterface demo
|
69 |
demo = gr.ChatInterface(
|
|
|
53 |
response = ""
|
54 |
|
55 |
# Stream response tokens from the chat completion API
|
56 |
+
# for message_chunk in client.chat_completion(
|
57 |
+
# model = "google/gemma-2b-it",
|
58 |
+
# messages=messages,
|
59 |
+
# max_tokens=max_tokens,
|
60 |
+
# stream=True,
|
61 |
+
# temperature=temperature,
|
62 |
+
# top_p=top_p,
|
63 |
+
# ):
|
64 |
+
# token = message_chunk["choices"][0]["delta"].get("content", "")
|
65 |
+
# response += token
|
66 |
+
# yield response
|
67 |
+
|
68 |
+
response = client.chat.completions.create(
|
69 |
model = "google/gemma-2b-it",
|
70 |
messages=messages,
|
71 |
max_tokens=max_tokens,
|
72 |
stream=True,
|
73 |
temperature=temperature,
|
74 |
top_p=top_p,
|
75 |
+
)
|
76 |
+
response += response.choices[0].message
|
77 |
+
return response
|
|
|
78 |
|
79 |
# Create a Gradio ChatInterface demo
|
80 |
demo = gr.ChatInterface(
|