shoom013 commited on
Commit
1e82d0f
1 Parent(s): dd3611a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -83,6 +83,13 @@ Settings.embed_model = HuggingFaceEmbedding(model_name="sentence-transformers/al
83
  vector_store = ChromaVectorStore(chroma_collection=collection)
84
  index = VectorStoreIndex.from_vector_store(vector_store, embed_model=Settings.embed_model)
85
  query_engine = index.as_query_engine()
 
 
 
 
 
 
 
86
  def rag(input_text, file):
87
  if (file):
88
  # documents = []
@@ -107,30 +114,24 @@ def rag(input_text, file):
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)],
112
- # title="Kako Vam mogu pomoći?",
113
- # description= "UChat"
114
- # )
115
 
116
- def upload_file(filepath):
117
- documents = SimpleDirectoryReader(filepath).load_data()
118
- index = VectorStoreIndex.from_documents(documents)
119
- query_engine = index.as_query_engine()
120
- return filepath
121
-
122
- with gr.Blocks() as iface:
123
- gr.Markdown("Uchat")
124
- file_out = gr.File()
125
- with gr.Row():
126
- with gr.Column(scale=1):
127
- inp = gr.Textbox(label="Pitanje:", lines=6)
128
- u = gr.UploadButton("Upload a file", file_count="single")
129
- with gr.Column(scale=1):
130
- out = gr.Textbox(label="Odgovor:", lines=6)
131
- sub = gr.Button("Pokreni")
132
-
133
- u.upload(upload_file, u, file_out)
134
- sub.click(rag, inp, out)
135
 
136
  iface.launch()
 
83
  vector_store = ChromaVectorStore(chroma_collection=collection)
84
  index = VectorStoreIndex.from_vector_store(vector_store, embed_model=Settings.embed_model)
85
  query_engine = index.as_query_engine()
86
+
87
+ def upload_file(filepath):
88
+ documents = SimpleDirectoryReader(filepath).load_data()
89
+ index = VectorStoreIndex.from_documents(documents)
90
+ query_engine = index.as_query_engine()
91
+ return filepath
92
+
93
  def rag(input_text, file):
94
  if (file):
95
  # documents = []
 
114
  query_engine = index.as_query_engine()
115
  return query_engine.query(input_text)
116
 
117
+ iface = gr.Interface(fn=rag, inputs=[gr.Textbox(label="Pitanje:", lines=6), gr.File()],
118
+ outputs=[gr.Textbox(label="Odgovor:", lines=6)],
119
+ title="Kako Vam mogu pomoći?",
120
+ description= "UChat"
121
+ )
122
 
123
+ #with gr.Blocks() as iface:
124
+ # gr.Markdown("Uchat")
125
+ # file_out = gr.File()
126
+ # with gr.Row():
127
+ # with gr.Column(scale=1):
128
+ # inp = gr.Textbox(label="Pitanje:", lines=6)
129
+ # u = gr.UploadButton("Upload a file", file_count="single")
130
+ # with gr.Column(scale=1):
131
+ # out = gr.Textbox(label="Odgovor:", lines=6)
132
+ # sub = gr.Button("Pokreni")
133
+ #
134
+ # u.upload(upload_file, u, file_out)
135
+ # sub.click(rag, inp, out)
 
 
 
 
 
 
136
 
137
  iface.launch()