Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,15 +98,15 @@ Settings.embed_model = HuggingFaceEmbedding(model_name=EMBED_MODEL)
|
|
| 98 |
#)
|
| 99 |
vector_store = ChromaVectorStore(chroma_collection=collection)
|
| 100 |
index = VectorStoreIndex.from_vector_store(vector_store, embed_model=Settings.embed_model)
|
| 101 |
-
|
| 102 |
-
query_engine = index.as_query_engine(verbose=True)
|
| 103 |
|
| 104 |
def upload_file(filepath):
|
| 105 |
documents = SimpleDirectoryReader(filepath).load_data()
|
| 106 |
index = VectorStoreIndex.from_documents(documents)
|
| 107 |
#query_engine = index.as_query_engine()
|
| 108 |
#condense_question condense_plus_context
|
| 109 |
-
|
| 110 |
return filepath
|
| 111 |
|
| 112 |
def resetChat():
|
|
@@ -183,8 +183,8 @@ def rag(input_text, history, jezik): # , file):
|
|
| 183 |
# if (o_jezik!='N/A'):
|
| 184 |
# input_text += " - odgovori " + o_jezik + "."
|
| 185 |
# Settings.llm.system_prompt = system_prompt
|
| 186 |
-
response =
|
| 187 |
-
# response =
|
| 188 |
return response
|
| 189 |
# gr.Textbox(label="Pitanje:", lines=6),
|
| 190 |
# outputs=[gr.Textbox(label="Odgovor:", lines=6)],
|
|
|
|
| 98 |
#)
|
| 99 |
vector_store = ChromaVectorStore(chroma_collection=collection)
|
| 100 |
index = VectorStoreIndex.from_vector_store(vector_store, embed_model=Settings.embed_model)
|
| 101 |
+
chat_engine = index.as_chat_engine(chat_mode="condense_question", verbose=True)
|
| 102 |
+
#query_engine = index.as_query_engine(verbose=True)
|
| 103 |
|
| 104 |
def upload_file(filepath):
|
| 105 |
documents = SimpleDirectoryReader(filepath).load_data()
|
| 106 |
index = VectorStoreIndex.from_documents(documents)
|
| 107 |
#query_engine = index.as_query_engine()
|
| 108 |
#condense_question condense_plus_context
|
| 109 |
+
chat_engine = index.as_chat_engine(verbose=True)
|
| 110 |
return filepath
|
| 111 |
|
| 112 |
def resetChat():
|
|
|
|
| 183 |
# if (o_jezik!='N/A'):
|
| 184 |
# input_text += " - odgovori " + o_jezik + "."
|
| 185 |
# Settings.llm.system_prompt = system_prompt
|
| 186 |
+
response = chat_engine.chat(str({"role": "user", "content": system_prompt + input_text})).response
|
| 187 |
+
# response = query_engine.query(input_text)
|
| 188 |
return response
|
| 189 |
# gr.Textbox(label="Pitanje:", lines=6),
|
| 190 |
# outputs=[gr.Textbox(label="Odgovor:", lines=6)],
|