Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -82,24 +82,26 @@ def generate(
|
|
82 |
)
|
83 |
|
84 |
reformed_query = reformulate_query(prompt, history)
|
85 |
-
formatted_prompt = format_prompt(reformed_query, history)
|
86 |
-
|
87 |
-
text_stream = chat_client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
88 |
|
89 |
docs = retriever.get_relevant_documents(reformed_query)
|
|
|
90 |
sources = "\nSources:\n"
|
91 |
for doc in docs:
|
92 |
if 'source' in doc.metadata:
|
93 |
sources += doc.metadata['source'] + '\n'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
98 |
output += response.token.text
|
99 |
yield output
|
100 |
|
101 |
output += sources
|
102 |
-
|
103 |
return output
|
104 |
|
105 |
demo = gr.ChatInterface(generate,
|
|
|
82 |
)
|
83 |
|
84 |
reformed_query = reformulate_query(prompt, history)
|
|
|
|
|
|
|
85 |
|
86 |
docs = retriever.get_relevant_documents(reformed_query)
|
87 |
+
|
88 |
sources = "\nSources:\n"
|
89 |
for doc in docs:
|
90 |
if 'source' in doc.metadata:
|
91 |
sources += doc.metadata['source'] + '\n'
|
92 |
+
|
93 |
+
formatted_prompt = format_prompt(reformed_query, history)
|
94 |
+
|
95 |
+
output = ''
|
96 |
+
|
97 |
+
stream = chat_client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
98 |
+
|
99 |
+
for response in stream:
|
100 |
output += response.token.text
|
101 |
yield output
|
102 |
|
103 |
output += sources
|
104 |
+
yield output
|
105 |
return output
|
106 |
|
107 |
demo = gr.ChatInterface(generate,
|