mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
Update to Pydantic v2: Transitioned all references from pydantic.v1 to pydantic (v2), ensuring compatibility with the latest Pydantic features and improvements. Affected components include agent tools, prompts, crew, and task modules. Refactoring & Alignment with Pydantic Standards: Refactored the agent module away from traditional __init__ to align more closely with Pydantic best practices. Updated the crew module to Pydantic v2 and enhanced configurations, allowing JSON and dictionary inputs. Additionally, some (not all) exceptions have been migrated to leverage Pydantic's error-handling capabilities. Enhancements to Validators and Typings: Improved validators and type annotations across multiple modules, enhancing code readability and maintainability. Streamlined the validation process in line with Pydantic v2's methodologies. Import and Configuration Adjustments: Updated to test-related absolute imports due to issues with Pytest finding packages through relative imports.
88 lines
1.9 KiB
Python
88 lines
1.9 KiB
Python
"""Prompts for generic agent."""
|
|
|
|
from textwrap import dedent
|
|
from typing import ClassVar
|
|
|
|
from langchain.prompts import PromptTemplate
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class Prompts(BaseModel):
|
|
"""Prompts for generic agent."""
|
|
|
|
TASK_SLICE: ClassVar[str] = dedent(
|
|
"""\
|
|
Begin! This is VERY important to you, your job depends on it!
|
|
|
|
Current Task: {input}
|
|
{agent_scratchpad}
|
|
"""
|
|
)
|
|
|
|
MEMORY_SLICE: ClassVar[str] = dedent(
|
|
"""\
|
|
This is the summary of your work so far:
|
|
{chat_history}
|
|
"""
|
|
)
|
|
|
|
ROLE_PLAYING_SLICE: ClassVar[str] = dedent(
|
|
"""\
|
|
You are {role}.
|
|
{backstory}
|
|
|
|
Your personal goal is: {goal}
|
|
"""
|
|
)
|
|
|
|
TOOLS_SLICE: ClassVar[str] = dedent(
|
|
"""\
|
|
|
|
TOOLS:
|
|
------
|
|
You have access to the following tools:
|
|
|
|
{tools}
|
|
|
|
To use a tool, please use the exact following format:
|
|
|
|
```
|
|
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
|
|
```
|
|
|
|
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]
|
|
```
|
|
"""
|
|
)
|
|
|
|
VOTING_SLICE: ClassVar[str] = dedent(
|
|
"""\
|
|
You are working on a crew with your co-workers and need to decide who will execute the task.
|
|
|
|
These are your format instructions:
|
|
{format_instructions}
|
|
|
|
These are your co-workers and their roles:
|
|
{coworkers}
|
|
"""
|
|
)
|
|
|
|
TASK_EXECUTION_WITH_MEMORY_PROMPT: ClassVar[str] = PromptTemplate.from_template(
|
|
ROLE_PLAYING_SLICE + TOOLS_SLICE + MEMORY_SLICE + TASK_SLICE
|
|
)
|
|
|
|
TASK_EXECUTION_PROMPT: ClassVar[str] = PromptTemplate.from_template(
|
|
ROLE_PLAYING_SLICE + TOOLS_SLICE + TASK_SLICE
|
|
)
|
|
|
|
CONSENSUNS_VOTING_PROMPT: ClassVar[str] = PromptTemplate.from_template(
|
|
ROLE_PLAYING_SLICE + VOTING_SLICE + TASK_SLICE
|
|
)
|