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",
|
@@ -39,12 +39,10 @@ def greet(product,description):
|
|
39 |
temperature=0.7,
|
40 |
stream=True
|
41 |
)
|
42 |
-
|
43 |
-
|
44 |
-
if
|
45 |
-
|
46 |
-
|
47 |
-
yield delta['content']
|
48 |
-
|
49 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs="text")
|
50 |
demo.launch()
|
|
|
20 |
{}"""
|
21 |
|
22 |
def greet(product,description):
|
23 |
+
response = llm.create_chat_completion(
|
24 |
messages=[
|
25 |
{
|
26 |
"role": "system",
|
|
|
39 |
temperature=0.7,
|
40 |
stream=True
|
41 |
)
|
42 |
+
partial_message = ""
|
43 |
+
for chunk in response:
|
44 |
+
if chunk.choices[0].delta.content is not None:
|
45 |
+
partial_message = partial_message + chunk.choices[0].delta.content
|
46 |
+
yield partial_message
|
|
|
|
|
47 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs="text")
|
48 |
demo.launch()
|