mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-05 19:47:45 +00:00
Fix Agent API (#5483)
* Fix agent.yml for new modules * Fix ConversationalAgent docstrings
This commit is contained in:
parent
540d0fad97
commit
37bdfddff5
@ -6,6 +6,8 @@ loaders:
|
||||
processors:
|
||||
- type: filter
|
||||
expression: "name not in ['print_text']"
|
||||
- type: filter
|
||||
expression:
|
||||
documented_only: true
|
||||
do_not_filter_modules: false
|
||||
skip_empty_modules: true
|
||||
|
||||
@ -17,14 +17,15 @@ class ConversationalAgent(Agent):
|
||||
If no tools are provided, the agent will be initialized to have a basic chat application.
|
||||
|
||||
Here is an example how you can create a chat application with tools:
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
from haystack.agents.conversational import ConversationalAgent
|
||||
from haystack.nodes import PromptNode
|
||||
from haystack.agents.base import ToolsManager, Tool
|
||||
from haystack.agents.base import Tool
|
||||
|
||||
# Initialize a PromptNode and a ToolsManager with the desired tools
|
||||
# Initialize a PromptNode and the desired tools
|
||||
prompt_node = PromptNode("gpt-3.5-turbo", api_key=os.environ.get("OPENAI_API_KEY"), max_length=256)
|
||||
tools = [Tool(name="ExampleTool", pipeline_or_node=example_tool_node)]
|
||||
|
||||
@ -38,10 +39,11 @@ class ConversationalAgent(Agent):
|
||||
break
|
||||
else:
|
||||
assistant_response = agent.run(user_input)
|
||||
print("\nAssistant:", assistant_response)
|
||||
print("Assistant:", assistant_response)
|
||||
```
|
||||
|
||||
If you don't want to have any tools in your chat app, you can create a ConversationalAgent only with a PromptNode:
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user