Spaces:
Sleeping
Sleeping
updated streaming code
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ marketing_email_prompt = """Below is a product and description, please write a m
|
|
20 |
{}"""
|
21 |
|
22 |
def greet(product,description):
|
23 |
-
|
24 |
messages=[
|
25 |
{
|
26 |
"role": "system",
|
@@ -40,9 +40,10 @@ def greet(product,description):
|
|
40 |
stream=True
|
41 |
)
|
42 |
partial_message = ""
|
43 |
-
for chunk in
|
44 |
-
|
45 |
-
|
|
|
46 |
yield partial_message
|
47 |
|
48 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs="text")
|
|
|
20 |
{}"""
|
21 |
|
22 |
def greet(product,description):
|
23 |
+
output = llm.create_chat_completion(
|
24 |
messages=[
|
25 |
{
|
26 |
"role": "system",
|
|
|
40 |
stream=True
|
41 |
)
|
42 |
partial_message = ""
|
43 |
+
for chunk in output:
|
44 |
+
delta = chunk['choices'][0]['delta']
|
45 |
+
if 'content' in delta:
|
46 |
+
partial_message = partial_message + delta.get('content', '')
|
47 |
yield partial_message
|
48 |
|
49 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs="text")
|