Spaces:
Runtime error
Runtime error
Commit
•
b2a42bc
1
Parent(s):
e21ecdd
Update app.py
Browse files
app.py
CHANGED
@@ -4,20 +4,19 @@ import os
|
|
4 |
import spaces
|
5 |
|
6 |
@spaces.GPU
|
7 |
-
def query_engine(llm_model, document):
|
8 |
api_key = os.getenv("HUGGINGFACE_API_KEY")
|
9 |
llm_api_base = "https://api-inference.huggingface.co/models/"
|
10 |
|
11 |
-
|
12 |
-
content = document.value.decode("utf-8")
|
13 |
-
docs.append(content)
|
14 |
|
15 |
query_engine = AutoQueryEngine.from_defaults(
|
16 |
-
documents=
|
17 |
llm_model=llm_model,
|
18 |
llm_api_base=llm_api_base,
|
19 |
)
|
20 |
-
|
|
|
21 |
|
22 |
interface = gr.Blocks()
|
23 |
with interface:
|
@@ -27,5 +26,5 @@ with interface:
|
|
27 |
query = gr.Textbox(label="Query")
|
28 |
output = gr.Textbox(label="Output")
|
29 |
query_btn = gr.Button("Query")
|
30 |
-
query_btn.click(fn=query_engine, inputs=[llm_model, document], outputs=output)
|
31 |
interface.launch()
|
|
|
4 |
import spaces
|
5 |
|
6 |
@spaces.GPU
|
7 |
+
def query_engine(llm_model, document, query):
|
8 |
api_key = os.getenv("HUGGINGFACE_API_KEY")
|
9 |
llm_api_base = "https://api-inference.huggingface.co/models/"
|
10 |
|
11 |
+
content = str(document)
|
|
|
|
|
12 |
|
13 |
query_engine = AutoQueryEngine.from_defaults(
|
14 |
+
documents=[content],
|
15 |
llm_model=llm_model,
|
16 |
llm_api_base=llm_api_base,
|
17 |
)
|
18 |
+
response = query_engine.query(query)
|
19 |
+
return response
|
20 |
|
21 |
interface = gr.Blocks()
|
22 |
with interface:
|
|
|
26 |
query = gr.Textbox(label="Query")
|
27 |
output = gr.Textbox(label="Output")
|
28 |
query_btn = gr.Button("Query")
|
29 |
+
query_btn.click(fn=query_engine, inputs=[llm_model, document, query], outputs=output)
|
30 |
interface.launch()
|