rafaaa2105 commited on
Commit
b3972fa
1 Parent(s): 4e5ce8c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from autollm import AutoQueryEngine
3
+ import os
4
+
5
+ def query_engine(api_key, llm_model, documents):
6
+ api_key = os.getenv("HUGGINGFACE_API_KEY")
7
+ llm_api_base = "https://api-inference.huggingface.co/models/"
8
+
9
+ query_engine = AutoQueryEngine.from_defaults(
10
+ documents=documents,
11
+ llm_model=llm_model,
12
+ llm_api_base=llm_api_base,
13
+ )
14
+
15
+ return query_engine
16
+
17
+ interface = gr.Blocks()
18
+
19
+ with interface:
20
+ gr.Markdown("# AutoQueryEngine Interface")
21
+ llm_model = gr.Textbox(label="LLM Model", value="mistralai/Mixtral-8x7B-Instruct-v0.1")
22
+ documents = gr.Textbox(label="Documents (comma-separated paths or URLs)")
23
+ query = gr.Textbox(label="Query")
24
+ output = gr.Textbox(label="Output")
25
+
26
+ query_btn = gr.Button("Query")
27
+ query_btn.click(fn=query_engine, inputs=[api_key, llm_model, documents], outputs=output)
28
+
29
+ interface.launch()