mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-04 03:00:48 -04:00
updating agent_test
This commit is contained in:
@@ -1,39 +1,52 @@
|
||||
"""Prompts for generic agent."""
|
||||
|
||||
from textwrap import dedent
|
||||
from typing import ClassVar
|
||||
from pydantic import BaseModel
|
||||
from langchain.prompts import PromptTemplate
|
||||
|
||||
AGENT_EXECUTION_PROMPT = PromptTemplate.from_template(
|
||||
"""You are {role}.
|
||||
{backstory}
|
||||
class Prompts(BaseModel):
|
||||
"""Prompts for generic agent."""
|
||||
|
||||
Your main goal is: {goal}
|
||||
TASK_SLICE: ClassVar[str] = dedent("""\
|
||||
Begin!
|
||||
|
||||
TOOLS:
|
||||
------
|
||||
Current Task: {input}
|
||||
{agent_scratchpad}
|
||||
""")
|
||||
|
||||
You have access to the following tools:
|
||||
ROLE_PLAYING_SLICE: ClassVar[str] = dedent("""\
|
||||
You are {role}.
|
||||
{backstory}
|
||||
|
||||
{tools}
|
||||
Your main goal is: {goal}
|
||||
""")
|
||||
|
||||
To use a tool, please use the following format:
|
||||
TOOLS_SLICE: ClassVar[str] = dedent("""\
|
||||
TOOLS:
|
||||
------
|
||||
|
||||
```
|
||||
Thought: Do I need to use a tool? Yes
|
||||
Action: the action to take, should be one of [{tool_names}]
|
||||
Action Input: the input to the action
|
||||
Observation: the result of the action
|
||||
```
|
||||
You have access to the following tools:
|
||||
|
||||
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
|
||||
{tools}
|
||||
|
||||
```
|
||||
Thought: Do I need to use a tool? No
|
||||
Final Answer: [your response here]
|
||||
```
|
||||
To use a tool, please use the following format:
|
||||
|
||||
Begin!
|
||||
```
|
||||
Thought: Do I need to use a tool? Yes
|
||||
Action: the action to take, should be one of [{tool_names}]
|
||||
Action Input: the input to the action
|
||||
Observation: the result of the action
|
||||
```
|
||||
|
||||
Current Task: {input}
|
||||
{agent_scratchpad}
|
||||
"""
|
||||
)
|
||||
When you have a response for your task, or if you do not need to use a tool, you MUST use the format:
|
||||
|
||||
```
|
||||
Thought: Do I need to use a tool? No
|
||||
Final Answer: [your response here]
|
||||
```
|
||||
""")
|
||||
|
||||
AGENT_EXECUTION_PROMPT: ClassVar[str] = PromptTemplate.from_template(
|
||||
ROLE_PLAYING_SLICE + TOOLS_SLICE + TASK_SLICE
|
||||
)
|
||||
@@ -5,14 +5,12 @@ import pytest
|
||||
from langchain.chat_models import ChatOpenAI as OpenAI
|
||||
|
||||
from ..crewai import Agent
|
||||
from ..crewai import prompts
|
||||
|
||||
def test_agent_creation():
|
||||
agent = Agent(
|
||||
role="test role",
|
||||
goal="test goal",
|
||||
backstory="test backstory",
|
||||
tools=[],
|
||||
backstory="test backstory"
|
||||
)
|
||||
|
||||
assert agent.role == "test role"
|
||||
@@ -24,8 +22,7 @@ def test_agent_default_value():
|
||||
agent = Agent(
|
||||
role="test role",
|
||||
goal="test goal",
|
||||
backstory="test backstory",
|
||||
tools=[],
|
||||
backstory="test backstory"
|
||||
)
|
||||
|
||||
assert isinstance(agent.llm, OpenAI)
|
||||
@@ -38,8 +35,7 @@ def test_agent_execution():
|
||||
agent = Agent(
|
||||
role="test role",
|
||||
goal="test goal",
|
||||
backstory="test backstory",
|
||||
tools=[],
|
||||
backstory="test backstory"
|
||||
)
|
||||
|
||||
output = agent.execute("How much is 1 + 1?")
|
||||
|
||||
Reference in New Issue
Block a user