Omar Solano
commited on
Commit
Β·
f0db5cb
1
Parent(s):
d612ca2
add streaming
Browse files- scripts/gradio-ui.py +6 -4
scripts/gradio-ui.py
CHANGED
@@ -62,7 +62,9 @@ index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
|
|
62 |
# Initialize query engine
|
63 |
llm = OpenAI(temperature=0, model="gpt-3.5-turbo-0125", max_tokens=None)
|
64 |
embeds = OpenAIEmbedding(model="text-embedding-3-large", mode="text_search")
|
65 |
-
query_engine = index.as_query_engine(
|
|
|
|
|
66 |
|
67 |
|
68 |
AVAILABLE_SOURCES_UI = [
|
@@ -194,9 +196,9 @@ def get_answer(history, sources: Optional[list[str]] = None):
|
|
194 |
completion = query_engine.query(user_input)
|
195 |
|
196 |
history[-1][1] = ""
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
|
202 |
example_questions = [
|
|
|
62 |
# Initialize query engine
|
63 |
llm = OpenAI(temperature=0, model="gpt-3.5-turbo-0125", max_tokens=None)
|
64 |
embeds = OpenAIEmbedding(model="text-embedding-3-large", mode="text_search")
|
65 |
+
query_engine = index.as_query_engine(
|
66 |
+
llm=llm, similarity_top_k=5, embed_model=embeds, streaming=True
|
67 |
+
)
|
68 |
|
69 |
|
70 |
AVAILABLE_SOURCES_UI = [
|
|
|
196 |
completion = query_engine.query(user_input)
|
197 |
|
198 |
history[-1][1] = ""
|
199 |
+
for token in completion.response_gen:
|
200 |
+
history[-1][1] += token
|
201 |
+
yield history, completion
|
202 |
|
203 |
|
204 |
example_questions = [
|