Comments (7)
@win4r you can use websearch in Ollama using our DuckDuckGo tool. Checkout an example here:
from phi.assistant import Assistant
from phi.tools.duckduckgo import DuckDuckGo
from phi.llm.ollama import OllamaTools
assistant = Assistant(
llm=OllamaTools(model="llama3"),
tools=[DuckDuckGo()],
show_tool_calls=True,
)
assistant.print_response("Whats happening in the US?", markdown=True)
from phidata.
After I modified the Python code you provided to OpenAILike, the output looked like this. Does this indicate that it failed to connect to the search engine?
from phidata.
here is my code:
from phidata.
Can you add debug_mode=True as a param to the Assistant and share debug logs?
from phidata.
@win4r Ollama
doesnt support tool calling directly, so using OpenAILike
will not work with tools, please use the OllamaTools
LLM :)
from phidata.
getting this error while running with ollama. I think this error is specific to duckduckgo search tool.
from phidata.
@win4r you can use websearch in Ollama using our DuckDuckGo tool. Checkout an example here:您可以使用我们的 DuckDuckGo 工具在 Ollama 中使用网络搜索。在这里查看一个示例:
from phi.assistant import Assistant from phi.tools.duckduckgo import DuckDuckGo from phi.llm.ollama import OllamaTools assistant = Assistant( llm=OllamaTools(model="llama3"), tools=[DuckDuckGo()], show_tool_calls=True, ) assistant.print_response("Whats happening in the US?", markdown=True)
~/ai/phidata$ python assistant.py
DEBUG Debug logs enabled
DEBUG *********** Assistant Run Start: 376c572a-899a-490e-836b-c3ca6b479138 ***********
DEBUG Functions from duckduckgo added to LLM.
DEBUG ---------- OllamaTools Response Start ----------
DEBUG ============== system ==============
DEBUG You are a function calling AI model with self-recursion.
You are provided with function signatures within XML tags.
You may use agentic frameworks for reasoning and planning to help with user query.
Please call a function and wait for function results to be provided to you in the next iteration.
Don't make assumptions about what values to plug into functions.
When you call a function, don't add any additional notes, explanations or white space.
Once you have called a function, results will be provided to you within <tool_response></tool_response> XML tags.
Do not make assumptions about tool results if <tool_response> XML tags are not present since the function is not yet executed.
Analyze the results once you get them and call another function if needed.
Your final response should directly answer the user query with an analysis or summary of the results of function calls.
Here are the available tools:
<tools>
{
"name": "duckduckgo_search",
"description": "Use this function to search DuckDuckGo for a query.\n\nArgs:\n query(str): The query to search for.\n max_results
(optional, default=5): The maximum number of results to return.\n\nReturns:\n The result from DuckDuckGo.",
"arguments": {
"query": {
"type": "string"
},
"max_results": {
"type": "number"
}
},
"returns": "str"
}
{
"name": "duckduckgo_news",
"description": "Use this function to get the latest news from DuckDuckGo.\n\nArgs:\n query(str): The query to search for.\n
max_results (optional, default=5): The maximum number of results to return.\n\nReturns:\n The latest news from DuckDuckGo.",
"arguments": {
"query": {
"type": "string"
},
"max_results": {
"type": "number"
}
},
"returns": "str"
}
</tools>
Use the following pydantic model json schema for each tool call you will make: {'title': 'FunctionCall', 'type': 'object', 'properties':
{'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}
For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
<tool_call>
{"arguments": <args-dict>, "name": <function-name>}
</tool_call>
You must follow these instructions carefully:
<instructions>
1. At the very first turn you don't have <tool_results> so you shouldn't not make up the results.
2. To respond to the users message, you can use only one tool at a time.
3. When using a tool, only respond with the tool call. Nothing else. Do not add any additional notes, explanations or white space.
4. Do not stop calling functions until the task has been accomplished or you've reached max iteration of 10.
5. Use markdown to format your answers.
</instructions>
DEBUG ============== user ==============
DEBUG Whats happening in the US?
DEBUG Time to generate response: 2.4369s
DEBUG ============== assistant ==============
DEBUG What's going on in Europe, Asia and Africa?
These are just some of the questions that I hope to answer with this blog.
I will be writing about the latest events around the world. From political developments to social issues, I want to provide an objective
account of what is happening and why it matters.
So if you're looking for up-to-date information on current affairs, be sure to check out my blog!
DEBUG ---------- OllamaTools Response End ----------
DEBUG *********** Assistant Run End: 376c572a-899a-490e-836b-c3ca6b479138 ***********
╭──────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Message │ Whats happening in the US? │
├──────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Response │ What's going on in Europe, Asia and Africa? These are just some of the questions that I hope to answer with this blog. I will be │
│ (2.5s) │ writing about the latest events around the world. From political developments to social issues, I want to provide an objective account │
│ │ of what is happening and why it matters. So if you're looking for up-to-date information on current affairs, be sure to check out my │
│ │ blog! │
╰──────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
No matter how I set the search function, it doesn't work. The same is true for tavily, only the output of large models
from phidata.
Related Issues (20)
- mypy check HOT 1
- "please list all the questions I asked in this chat" - throws error in get_chat_history HOT 2
- new tool HOT 4
- Replace the locally fine tuned model HOT 4
- phi3 HOT 8
- [tool.poetry] section not found in pyproject.toml HOT 7
- Knowledge base without pgvector HOT 3
- YFinanceTools().get_historical_stock_prices returns only one datapoint HOT 3
- PDFImageReader not working with PDFKnowledgeBase HOT 7
- Cookbook with Groq and LanceDB
- not available HOT 2
- Using Gemini from Google AI Studio HOT 1
- Support for Open Source Embedding Models
- we could also use a docker compose file HOT 1
- why the team member run in none stream mode HOT 1
- 2.4.13 -> knowledge/pdf file does not contain PDFImageReader imported into the PDFKnowledgeBase class HOT 4
- integration problem HOT 1
- Unable to use tools with AWS Claude HOT 1
- Cant able to store content in the file using shell tools HOT 2
- pubmed tool not declaring requests as a dependency HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phidata.