shoom013 commited on
Commit
1da1b16
1 Parent(s): 4ac8a4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -95,16 +95,17 @@ def rag(input_text, file):
95
  print("basename=", os.path.basename(file))
96
  print("filename=", file.name)
97
  documents = SimpleDirectoryReader(file).load_data()
98
- index = VectorStoreIndex.from_documents(documents)
 
 
99
  # collection.add(
100
  # documents=documents,
101
  # ids=[f"id{last+i}" for i in range(len(documents))],
102
  # metadatas=[{"state": "s0", "next": "s0", "used": False, "source": 'None', "page": -1, "lang": jezik } for i in range(len(documents)) ]
103
  # )
104
- query_engine = index.as_query_engine()
105
- return query_engine.query(
106
- input_text
107
- )
108
 
109
  iface = gr.Interface(fn=rag, inputs=[gr.Textbox(label="Pitanje:", lines=6), gr.File()],
110
  outputs=[gr.Textbox(label="Odgovor:", lines=6)],
 
95
  print("basename=", os.path.basename(file))
96
  print("filename=", file.name)
97
  documents = SimpleDirectoryReader(file).load_data()
98
+ index2 = VectorStoreIndex.from_documents(documents)
99
+ query_engine = index2.as_query_engine()
100
+ return query_engine.query(input_text)
101
  # collection.add(
102
  # documents=documents,
103
  # ids=[f"id{last+i}" for i in range(len(documents))],
104
  # metadatas=[{"state": "s0", "next": "s0", "used": False, "source": 'None', "page": -1, "lang": jezik } for i in range(len(documents)) ]
105
  # )
106
+ else:
107
+ query_engine = index.as_query_engine()
108
+ return query_engine.query(input_text)
 
109
 
110
  iface = gr.Interface(fn=rag, inputs=[gr.Textbox(label="Pitanje:", lines=6), gr.File()],
111
  outputs=[gr.Textbox(label="Odgovor:", lines=6)],