Spaces:
Sleeping
Sleeping
Martin Bär
commited on
Commit
·
ba66f78
1
Parent(s):
ed424a9
Add instrumentor.start()
Browse files- basic_agent.py +5 -4
basic_agent.py
CHANGED
@@ -9,13 +9,14 @@ from llama_index.readers.web import SimpleWebPageReader
|
|
9 |
from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool
|
10 |
from langfuse.llama_index import LlamaIndexInstrumentor
|
11 |
|
|
|
|
|
|
|
|
|
12 |
class BasicAgent:
|
13 |
def __init__(self):
|
14 |
llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
|
15 |
|
16 |
-
# Langfuse
|
17 |
-
self.instrumentor = LlamaIndexInstrumentor()
|
18 |
-
|
19 |
# Initialize tools
|
20 |
tool_spec = DuckDuckGoSearchToolSpec()
|
21 |
search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
|
@@ -51,5 +52,5 @@ class BasicAgent:
|
|
51 |
|
52 |
async def __call__(self, question: str) -> str:
|
53 |
response = await self.agent.run(user_msg=question) # ctx=self.ctx)
|
54 |
-
|
55 |
return response.response.content
|
|
|
9 |
from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool
|
10 |
from langfuse.llama_index import LlamaIndexInstrumentor
|
11 |
|
12 |
+
# Langfuse
|
13 |
+
instrumentor = LlamaIndexInstrumentor()
|
14 |
+
instrumentor.start()
|
15 |
+
|
16 |
class BasicAgent:
|
17 |
def __init__(self):
|
18 |
llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
|
19 |
|
|
|
|
|
|
|
20 |
# Initialize tools
|
21 |
tool_spec = DuckDuckGoSearchToolSpec()
|
22 |
search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
|
|
|
52 |
|
53 |
async def __call__(self, question: str) -> str:
|
54 |
response = await self.agent.run(user_msg=question) # ctx=self.ctx)
|
55 |
+
instrumentor.flush()
|
56 |
return response.response.content
|