Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -121,12 +121,12 @@ def rag(input_text, history, jezik, file):
|
|
121 |
print("pathname=", pathname)
|
122 |
print("basename=", os.path.basename(file))
|
123 |
print("filename=", file.name)
|
124 |
-
documents = SimpleDirectoryReader(file
|
125 |
index2 = VectorStoreIndex.from_documents(documents)
|
126 |
query_engine = index2.as_query_engine()
|
127 |
# return query_engine.query(input_text)
|
128 |
# return history.append({"role": "assistant", "content": query_engine.query(input_text)})
|
129 |
-
return history + [input_text, query_engine.query(input_text)]
|
130 |
# collection.add(
|
131 |
# documents=documents,
|
132 |
# ids=[f"id{last+i}" for i in range(len(documents))],
|
@@ -153,7 +153,8 @@ def rag(input_text, history, jezik, file):
|
|
153 |
# if (o_jezik!='N/A'):
|
154 |
# input_text += " - odgovori " + o_jezik + "."
|
155 |
# return query_engine.query(input_text)
|
156 |
-
|
|
|
157 |
# Interface
|
158 |
# gr.Textbox(label="Pitanje:", lines=6),
|
159 |
# outputs=[gr.Textbox(label="Odgovor:", lines=6)],
|
|
|
121 |
print("pathname=", pathname)
|
122 |
print("basename=", os.path.basename(file))
|
123 |
print("filename=", file.name)
|
124 |
+
documents = SimpleDirectoryReader(file).load_data()
|
125 |
index2 = VectorStoreIndex.from_documents(documents)
|
126 |
query_engine = index2.as_query_engine()
|
127 |
# return query_engine.query(input_text)
|
128 |
# return history.append({"role": "assistant", "content": query_engine.query(input_text)})
|
129 |
+
return history + [[input_text, query_engine.query(input_text)]]
|
130 |
# collection.add(
|
131 |
# documents=documents,
|
132 |
# ids=[f"id{last+i}" for i in range(len(documents))],
|
|
|
153 |
# if (o_jezik!='N/A'):
|
154 |
# input_text += " - odgovori " + o_jezik + "."
|
155 |
# return query_engine.query(input_text)
|
156 |
+
response = chat_engine.chat(input_text)
|
157 |
+
return history + [[input_text, response]]
|
158 |
# Interface
|
159 |
# gr.Textbox(label="Pitanje:", lines=6),
|
160 |
# outputs=[gr.Textbox(label="Odgovor:", lines=6)],
|