Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -107,23 +107,23 @@ def resetChat():
|
|
107 |
chat_engine.reset()
|
108 |
return True
|
109 |
|
110 |
-
def rag(input_text, history, jezik
|
111 |
# if (btn):
|
112 |
# resetChat()
|
113 |
print(history, input_text)
|
114 |
-
if (file):
|
115 |
# documents = []
|
116 |
# for f in file:
|
117 |
# documents += SimpleDirectoryReader(f).load_data()
|
118 |
# f = file + "*.pdf"
|
119 |
-
pathname = os.path.dirname
|
120 |
# shutil.copyfile(file.name, path)
|
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)]]
|
@@ -132,7 +132,7 @@ def rag(input_text, history, jezik, file):
|
|
132 |
# ids=[f"id{last+i}" for i in range(len(documents))],
|
133 |
# metadatas=[{"state": "s0", "next": "s0", "used": False, "source": 'None', "page": -1, "lang": jezik } for i in range(len(documents)) ]
|
134 |
# )
|
135 |
-
else:
|
136 |
o_jezik = "N/A"
|
137 |
match jezik:
|
138 |
case 'hrvatski':
|
@@ -171,7 +171,7 @@ iface = gr.ChatInterface(rag,
|
|
171 |
undo_btn="Briši prethodno",
|
172 |
clear_btn="Briši sve",
|
173 |
additional_inputs = [gr.Dropdown(["slovenski", "hrvatski", "srpski", "makedonski", "Eksperimentalna opcija"], value="srpski", label="Jezik", info="N/A"),
|
174 |
-
gr.File()
|
175 |
]
|
176 |
)
|
177 |
|
|
|
107 |
chat_engine.reset()
|
108 |
return True
|
109 |
|
110 |
+
def rag(input_text, history, jezik):
|
111 |
# if (btn):
|
112 |
# resetChat()
|
113 |
print(history, input_text)
|
114 |
+
## if (file):
|
115 |
# documents = []
|
116 |
# for f in file:
|
117 |
# documents += SimpleDirectoryReader(f).load_data()
|
118 |
# f = file + "*.pdf"
|
119 |
+
## pathname = os.path.dirname
|
120 |
# shutil.copyfile(file.name, path)
|
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)]]
|
|
|
132 |
# ids=[f"id{last+i}" for i in range(len(documents))],
|
133 |
# metadatas=[{"state": "s0", "next": "s0", "used": False, "source": 'None', "page": -1, "lang": jezik } for i in range(len(documents)) ]
|
134 |
# )
|
135 |
+
## else:
|
136 |
o_jezik = "N/A"
|
137 |
match jezik:
|
138 |
case 'hrvatski':
|
|
|
171 |
undo_btn="Briši prethodno",
|
172 |
clear_btn="Briši sve",
|
173 |
additional_inputs = [gr.Dropdown(["slovenski", "hrvatski", "srpski", "makedonski", "Eksperimentalna opcija"], value="srpski", label="Jezik", info="N/A"),
|
174 |
+
## gr.File()
|
175 |
]
|
176 |
)
|
177 |
|