mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +00:00
Add inject_date flag to Agent for automatic date injection (#2870)
* feat: Add inject_date flag to Agent for automatic date injection Co-Authored-By: Joe Moura <joao@crewai.com> * feat: Add date_format parameter and error handling to inject_date feature Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Update test implementation for inject_date feature Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Add date format validation to prevent invalid formats Co-Authored-By: Joe Moura <joao@crewai.com> * docs: Update documentation for inject_date feature Co-Authored-By: Joe Moura <joao@crewai.com> * unnecesary * new tests --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Joe Moura <joao@crewai.com> Co-authored-by: João Moura <joaomdmoura@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9945da7dbe
commit
c1672613bc
@@ -58,6 +58,8 @@ The Visual Agent Builder enables:
|
||||
| **Embedder** _(optional)_ | `embedder` | `Optional[Dict[str, Any]]` | Configuration for the embedder used by the agent. |
|
||||
| **Knowledge Sources** _(optional)_ | `knowledge_sources` | `Optional[List[BaseKnowledgeSource]]` | Knowledge sources available to the agent. |
|
||||
| **Use System Prompt** _(optional)_ | `use_system_prompt` | `Optional[bool]` | Whether to use system prompt (for o1 model support). Default is True. |
|
||||
| **Inject Date** _(optional)_ | `inject_date` | `bool` | Whether to automatically inject the current date into tasks. Default is False. |
|
||||
| **Date Format** _(optional)_ | `date_format` | `str` | Format string for date when inject_date is enabled. Default is "%Y-%m-%d" (ISO format). |
|
||||
|
||||
## Creating Agents
|
||||
|
||||
@@ -226,6 +228,18 @@ custom_agent = Agent(
|
||||
)
|
||||
```
|
||||
|
||||
#### Date-Aware Agent
|
||||
```python Code
|
||||
date_aware_agent = Agent(
|
||||
role="Market Analyst",
|
||||
goal="Track market movements with precise date references",
|
||||
backstory="Expert in time-sensitive financial analysis and reporting",
|
||||
inject_date=True, # Automatically inject current date into tasks
|
||||
date_format="%B %d, %Y", # Format as "May 21, 2025"
|
||||
verbose=True
|
||||
)
|
||||
```
|
||||
|
||||
### Parameter Details
|
||||
|
||||
#### Critical Parameters
|
||||
@@ -332,6 +346,12 @@ When `memory` is enabled, the agent will maintain context across multiple intera
|
||||
- Main `llm` for complex reasoning
|
||||
- `function_calling_llm` for efficient tool usage
|
||||
|
||||
### Date Awareness
|
||||
- Use `inject_date: true` to provide agents with current date awareness
|
||||
- Customize the date format with `date_format` using standard Python datetime format codes
|
||||
- Valid format codes include: %Y (year), %m (month), %d (day), %B (full month name), etc.
|
||||
- Invalid date formats will be logged as warnings and will not modify the task description
|
||||
|
||||
### Model Compatibility
|
||||
- Set `use_system_prompt: false` for older models that don't support system messages
|
||||
- Ensure your chosen `llm` supports the features you need (like function calling)
|
||||
|
||||
Reference in New Issue
Block a user