Spaces:
Running
Running
fix: explicitly importing the HF_TOKEN in all agents as it's stored in secrets.
Browse files
src/insurance_assistants/agents.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from pathlib import Path
|
2 |
|
3 |
-
from dotenv import find_dotenv, load_dotenv
|
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
from smolagents import (
|
6 |
CodeAgent,
|
@@ -17,7 +18,7 @@ from smolagents import (
|
|
17 |
from src.insurance_assistants.complex_rag import RAG
|
18 |
from src.insurance_assistants.consts import PROMPT_PREFIX
|
19 |
|
20 |
-
_ = load_dotenv(dotenv_path=find_dotenv())
|
21 |
rag_app = RAG()
|
22 |
# FIXME Comment the following if you want to reprocess everything
|
23 |
rag_app.vectordb_id = "policy_wordings"
|
@@ -35,6 +36,7 @@ class InsuranceInfoRetriever(Tool):
|
|
35 |
client = InferenceClient(
|
36 |
provider="hyperbolic",
|
37 |
bill_to="VitalNest",
|
|
|
38 |
)
|
39 |
results = rag_app.search_documents(query)
|
40 |
img_paths = [Path(res[0]) for res in results]
|
@@ -73,7 +75,8 @@ class InsuranceInfoRetriever(Tool):
|
|
73 |
|
74 |
insurance_agent = CodeAgent(
|
75 |
tools=[InsuranceInfoRetriever(), FinalAnswerTool()],
|
76 |
-
model=InferenceClientModel(bill_to="VitalNest", temperature=0.1
|
|
|
77 |
additional_authorized_imports=["os", "requests", "bs4", "pil", "base64", "io"],
|
78 |
max_steps=1,
|
79 |
verbosity_level=-1,
|
@@ -83,7 +86,8 @@ insurance_agent = CodeAgent(
|
|
83 |
)
|
84 |
websearch_agent = ToolCallingAgent(
|
85 |
model=InferenceClientModel(
|
86 |
-
model_id="Qwen/Qwen3-30B-A3B", bill_to="VitalNest", temperature=0.1
|
|
|
87 |
),
|
88 |
tools=[
|
89 |
VisitWebpageTool(max_output_length=20_000),
|
@@ -99,7 +103,8 @@ websearch_agent = ToolCallingAgent(
|
|
99 |
|
100 |
wikipedia_agent = ToolCallingAgent(
|
101 |
model=InferenceClientModel(
|
102 |
-
model_id="Qwen/Qwen3-30B-A3B", bill_to="VitalNest", temperature=0.1
|
|
|
103 |
),
|
104 |
tools=[
|
105 |
WikipediaSearchTool(user_agent="WikiAssistant (merlin@example.com)"),
|
@@ -118,6 +123,7 @@ manager_agent = CodeAgent(
|
|
118 |
model_id="Qwen/Qwen3-235B-A22B",
|
119 |
bill_to="VitalNest",
|
120 |
temperature=0.1,
|
|
|
121 |
),
|
122 |
managed_agents=[websearch_agent, wikipedia_agent, insurance_agent],
|
123 |
max_steps=10,
|
|
|
1 |
from pathlib import Path
|
2 |
|
3 |
+
# from dotenv import find_dotenv, load_dotenv
|
4 |
+
import os
|
5 |
from huggingface_hub import InferenceClient
|
6 |
from smolagents import (
|
7 |
CodeAgent,
|
|
|
18 |
from src.insurance_assistants.complex_rag import RAG
|
19 |
from src.insurance_assistants.consts import PROMPT_PREFIX
|
20 |
|
21 |
+
# _ = load_dotenv(dotenv_path=find_dotenv())
|
22 |
rag_app = RAG()
|
23 |
# FIXME Comment the following if you want to reprocess everything
|
24 |
rag_app.vectordb_id = "policy_wordings"
|
|
|
36 |
client = InferenceClient(
|
37 |
provider="hyperbolic",
|
38 |
bill_to="VitalNest",
|
39 |
+
token=os.getenv("HF_TOKEN")
|
40 |
)
|
41 |
results = rag_app.search_documents(query)
|
42 |
img_paths = [Path(res[0]) for res in results]
|
|
|
75 |
|
76 |
insurance_agent = CodeAgent(
|
77 |
tools=[InsuranceInfoRetriever(), FinalAnswerTool()],
|
78 |
+
model=InferenceClientModel(bill_to="VitalNest", temperature=0.1,
|
79 |
+
token=os.getenv("HF_TOKEN")),
|
80 |
additional_authorized_imports=["os", "requests", "bs4", "pil", "base64", "io"],
|
81 |
max_steps=1,
|
82 |
verbosity_level=-1,
|
|
|
86 |
)
|
87 |
websearch_agent = ToolCallingAgent(
|
88 |
model=InferenceClientModel(
|
89 |
+
model_id="Qwen/Qwen3-30B-A3B", bill_to="VitalNest", temperature=0.1,
|
90 |
+
token=os.getenv("HF_TOKEN")
|
91 |
),
|
92 |
tools=[
|
93 |
VisitWebpageTool(max_output_length=20_000),
|
|
|
103 |
|
104 |
wikipedia_agent = ToolCallingAgent(
|
105 |
model=InferenceClientModel(
|
106 |
+
model_id="Qwen/Qwen3-30B-A3B", bill_to="VitalNest", temperature=0.1,
|
107 |
+
token=os.getenv("HF_TOKEN")
|
108 |
),
|
109 |
tools=[
|
110 |
WikipediaSearchTool(user_agent="WikiAssistant (merlin@example.com)"),
|
|
|
123 |
model_id="Qwen/Qwen3-235B-A22B",
|
124 |
bill_to="VitalNest",
|
125 |
temperature=0.1,
|
126 |
+
token=os.getenv("HF_TOKEN")
|
127 |
),
|
128 |
managed_agents=[websearch_agent, wikipedia_agent, insurance_agent],
|
129 |
max_steps=10,
|
src/insurance_assistants/ui.py
CHANGED
@@ -213,6 +213,7 @@ class UI:
|
|
213 |
gr.Markdown(
|
214 |
value="""#### <span style="color:red"> The `interrupt` button doesn't stop the process instantaneously.</span>
|
215 |
<span style="color:green">You can continue to use the application upon pressing the interrupt button.</span>
|
|
|
216 |
<span style="color:violet">PRECISE PROMPT == ACCURATE RESULTS.</span>
|
217 |
"""
|
218 |
)
|
|
|
213 |
gr.Markdown(
|
214 |
value="""#### <span style="color:red"> The `interrupt` button doesn't stop the process instantaneously.</span>
|
215 |
<span style="color:green">You can continue to use the application upon pressing the interrupt button.</span>
|
216 |
+
|
217 |
<span style="color:violet">PRECISE PROMPT == ACCURATE RESULTS.</span>
|
218 |
"""
|
219 |
)
|