shoom013 commited on
Commit
534531a
1 Parent(s): 1da1b16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -107,9 +107,31 @@ 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
  iface.launch()
 
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
+ name = Path(filepath).name
118
+ documents = SimpleDirectoryReader(file).load_data()
119
+ index = VectorStoreIndex.from_documents(documents)
120
+ query_engine = index.as_query_engine()
121
+ return filepath
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(label="Pokreni")
133
+
134
+ u.upload(upload_file, u, file_out)
135
+ sub.click(rag, inp, out)
136
+
137
  iface.launch()