Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import torch
|
|
| 5 |
from transformers import pipeline
|
| 6 |
import gradio as gr
|
| 7 |
from huggingface_hub import InferenceClient
|
|
|
|
| 8 |
|
| 9 |
docs = load_document("docs")
|
| 10 |
chunks = []
|
|
@@ -38,27 +39,37 @@ summarize_tool = DocumentSummarizationTool(
|
|
| 38 |
summarization_pipeline=summarization_pipeline
|
| 39 |
)
|
| 40 |
|
| 41 |
-
model = InferenceClientModel("
|
| 42 |
-
|
| 43 |
-
# client=InferenceClient()
|
| 44 |
-
# )
|
| 45 |
|
| 46 |
agent = CodeAgent(
|
| 47 |
tools=[doc_tool, summarize_tool, DuckDuckGoSearchTool(), CodeExecutionTool()],
|
| 48 |
model=model,
|
| 49 |
-
stream_outputs=True
|
| 50 |
)
|
| 51 |
|
| 52 |
-
def
|
|
|
|
| 53 |
return agent.run(query)
|
| 54 |
|
| 55 |
iface = gr.Interface(
|
| 56 |
-
fn=
|
| 57 |
inputs="text",
|
| 58 |
outputs="text",
|
| 59 |
title="Document QA Agent"
|
| 60 |
)
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from transformers import pipeline
|
| 6 |
import gradio as gr
|
| 7 |
from huggingface_hub import InferenceClient
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
docs = load_document("docs")
|
| 11 |
chunks = []
|
|
|
|
| 39 |
summarization_pipeline=summarization_pipeline
|
| 40 |
)
|
| 41 |
|
| 42 |
+
model = InferenceClientModel(client=InferenceClient(model="google/flan-t5-large")) # naveensharma16/document-based-assistant
|
| 43 |
+
print("Loaded model:", model)
|
|
|
|
|
|
|
| 44 |
|
| 45 |
agent = CodeAgent(
|
| 46 |
tools=[doc_tool, summarize_tool, DuckDuckGoSearchTool(), CodeExecutionTool()],
|
| 47 |
model=model,
|
| 48 |
+
stream_outputs=False # True
|
| 49 |
)
|
| 50 |
|
| 51 |
+
def predict(query: str):
|
| 52 |
+
"""GAIA entrypoint"""
|
| 53 |
return agent.run(query)
|
| 54 |
|
| 55 |
iface = gr.Interface(
|
| 56 |
+
fn=predict,
|
| 57 |
inputs="text",
|
| 58 |
outputs="text",
|
| 59 |
title="Document QA Agent"
|
| 60 |
)
|
| 61 |
|
| 62 |
+
# def agent_interface(query):
|
| 63 |
+
# return agent.run(query)
|
| 64 |
|
| 65 |
+
# iface = gr.Interface(
|
| 66 |
+
# fn=agent_interface,
|
| 67 |
+
# inputs="text",
|
| 68 |
+
# outputs="text",
|
| 69 |
+
# title="Document QA Agent"
|
| 70 |
+
# )
|
| 71 |
+
|
| 72 |
+
if __name__ == "__main__":
|
| 73 |
+
if os.getenv("RUN_GAIA", "true") == "true":
|
| 74 |
+
run_gaia_test("naveensharma16")
|
| 75 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|