๐ค FCrew is a next-generation framework for creating AI agents with long-term memory and advanced prompt management. Based on CrewAI, it adds sophisticated memory, contextualization, and learning capabilities, allowing agents to maintain consistency in their interactions and learn from their experiences.
- ๐ Advanced prompt management with versioning
- ๐ง Long-term memory with intelligent forgetting
- ๐ค Advanced agent collaboration
- ๐ญ Personality and emotion system
- ๐ Reinforcement learning
- ๐ Automatic interaction contextualization
- ๐ Vector memory optimization
from fcrew.personality import AgentPersonality
# Create a personality
personality = AgentPersonality()
# Adjust traits
personality.traits["openness"].value = 0.8
personality.traits["extraversion"].value = 0.6
# Process interactions
personality.process_interaction("Excellent work!")
response = personality.adjust_response("Thank you for your feedback.")from fcrew.learning import ReinforcementLearning
# Create learning system
learning = ReinforcementLearning()
# Learn from experiences
learning.update(Experience(
state={"context": 0.5},
action="ask_question",
reward=1.0,
next_state={"context": 0.8}
))
# Get best action
action = learning.get_action({"context": 0.5})from fcrew.collaboration import CollaborationNetwork, Skill
# Create network
network = CollaborationNetwork()
# Add agents with their skills
network.add_agent("agent1", {
"analysis": Skill(name="analysis", level=0.8, description="Data analysis")
})
# Create optimal teams
team = network.create_optimal_team(
task_requirements={"analysis": 0.7},
team_size=2
)from fcrew import EnhancedAgent, AgentPersonality, ReinforcementLearning
# Agent configuration
agent = EnhancedAgent(
role="Analyst",
goal="Analyze data",
personality=AgentPersonality(
traits={
"openness": 0.8,
"conscientiousness": 0.9
}
),
learning_system=ReinforcementLearning(),
prompt_storage_path="~/.fcrew/prompts",
memory_storage_path="~/.fcrew/memory"
)
# Use advanced capabilities
agent.personality.process_interaction("Excellent work!")
agent.learning_system.update(experience)from fcrew import Crew, CollaborationNetwork
# Create collaboration network
network = CollaborationNetwork()
# Add agents to network
network.add_agent("analyst", {
"analysis": Skill(name="analysis", level=0.8),
"reporting": Skill(name="reporting", level=0.7)
})
network.add_agent("researcher", {
"research": Skill(name="research", level=0.9),
"analysis": Skill(name="analysis", level=0.6)
})
# Create crew with collaboration
crew = Crew(
agents=[analyst, researcher],
collaboration_network=network,
process=Process.sequential
)
# Execute with automatic collaboration optimization
result = crew.kickoff(
optimize_collaborations=True,
task_requirements={
"analysis": 0.7,
"research": 0.8
}
)# Configure personality traits
agent.personality.traits["openness"].value = 0.9
agent.personality.emotional_state.joy = 0.8
# Execute task with personality
response = agent.execute_task(
task,
context={"mood": "positive"},
adjust_personality=True
)
# Analyze learning performance
performance = agent.learning_system.analyze_performance()
print(f"Average reward: {performance['average_reward']}")- More Natural Interactions: Agents respond in a more human and contextual way
- Behavioral Consistency: Maintains consistent personality across interactions
- Emotional Adaptation: Responses adapted to interaction's emotional context
- Emotional History: Traceability of agents' emotional evolution
- Continuous Improvement: Agents learn from their experiences
- Decision Optimization: Action choices based on past successes
- Contextual Adaptation: Context-specific learning
- Performance Measurement: Quantitative learning tracking
- Optimal Teams: Automatic team creation based on skills
- Synergies: Identification and exploitation of agent complementarities
- Collaborative History: Tracking and improving collaborations
- Network Analysis: Visualization and optimization of agent relationships
agent = EnhancedAgent(
role="Customer Support",
personality=AgentPersonality(
traits={"empathy": 0.9}
)
)
agent.personality.process_interaction("I'm very frustrated with this problem!")
response = agent.execute_task(task, adjust_personality=True)crew = Crew(
agents=[researcher, analyst, writer],
collaboration_network=network,
learning_enabled=True
)
# Team improves over tasks
for task in research_tasks:
result = crew.kickoff(task)
crew.learn_from_execution(task, result)assistant = EnhancedAgent(
role="Personal Assistant",
personality=AgentPersonality(),
learning_system=ReinforcementLearning()
)
# Assistant learns user preferences
assistant.remember(
content="User prefers concise responses",
importance=0.9
)
assistant.personality.adapt_to_user_preferences()- Python 3.10 or higher
- 2GB minimum disk space (for prompt and memory storage)
- OpenAI API key (or other compatible LLM)
- Recommended RAM: 8GB minimum
dependencies = [
"pydantic>=2.4.2",
"openai>=1.13.3",
"chromadb>=0.5.23",
"tiktoken>=0.7.0"
]FCrew is compatible with several language model providers:
| Provider | Supported Models | Configuration |
|---|---|---|
| OpenAI | O1-mini, O1, O1 pro, O3-mini, O3-mini-high, GPT-4o, GPT-3.5 | API key required |
| Anthropic | Sonnet, Haiku | API key required |
| Ollama | All models | Local installation |
| LlamaCpp | All compatible models | Local installation |
- Creation and management of prompt templates
- Automatic prompt versioning
- Dynamic variables in templates
- Change history
- Persistent prompt storage
- Semantic memory search
- Intelligent forgetting mechanism based on importance
- Automatic memory consolidation
- Contextual information retrieval
- Optimized vector storage
pip install fcrew (not implemented for now, you have to use the source instead or compile it)from fcrew import FCrewConfig
# Configuration via JSON file
config = FCrewConfig.load_from_file("fcrew_config.json")
# Or programmatic configuration
config = FCrewConfig(
prompt_storage_path="~/.fcrew/prompts",
memory_storage_path="~/.fcrew/memory",
max_memories=10000
)from crewai import Task, Crew, Process
from crewai.agents import EnhancedAgent
import os
# Create storage paths
base_path = os.path.expanduser("~/.fcrew")
prompts_path = os.path.join(base_path, "prompts")
memory_path = os.path.join(base_path, "memory")
# Create agent
agent = EnhancedAgent(
role="AI Analyst",
goal="Analyze AI trends",
backstory="Expert in data analysis and AI trends",
prompt_storage_path=prompts_path,
memory_storage_path=memory_path
)# Create template
agent.create_prompt_template(
name="trend_analysis",
content="""
Analyze trends in ${domain} focusing on:
1. Recent innovations
2. Market impact
3. Future perspectives
Historical context:
${relevant_memories}
""",
variables=["domain"]
)
# Use template
result = agent.use_prompt_template(
"trend_analysis",
domain="artificial intelligence"
)# Store information
agent.remember(
content="GPT-4 has shown advanced reasoning capabilities",
importance=0.9,
context={"domain": "LLM", "date": "2024"}
)
# Memory is automatically used during task execution
task = Task(
description="Analyze LLM evolution",
agent=agent
)# Create crew with multiple agents
researcher = EnhancedAgent(
role="Researcher",
goal="Research latest advances",
prompt_storage_path=prompts_path,
memory_storage_path=memory_path
)
analyst = EnhancedAgent(
role="Analyst",
goal="Analyze implications",
prompt_storage_path=prompts_path,
memory_storage_path=memory_path
)
# Define tasks
research_task = Task(
description="Research latest AI advances",
agent=researcher
)
analysis_task = Task(
description="Analyze findings implications",
agent=analyst
)
# Create crew
crew = Crew(
agents=[researcher, analyst],
tasks=[research_task, analysis_task],
process=Process.sequential,
verbose=True
)
# Execute
result = crew.kickoff()Agents in the same crew can share memory using the same storage path:
memory_path = "~/.fcrew/shared_memory"
agent1 = EnhancedAgent(..., memory_storage_path=memory_path)
agent2 = EnhancedAgent(..., memory_storage_path=memory_path)Similarly for prompts:
prompts_path = "~/.fcrew/shared_prompts"
agent1 = EnhancedAgent(..., prompt_storage_path=prompts_path)
agent2 = EnhancedAgent(..., prompt_storage_path=prompts_path)agent.remember(
content="Critical information",
importance=1.0, # Maximum importance
context={"type": "critical"}
)-
Prompt Organization
- Create reusable templates
- Use variables for flexibility
- Document your templates
-
Memory Management
- Set appropriate importance levels
- Use relevant contexts
- Share memory when it makes sense
-
Configuration
- Use different storage paths for different projects
- Adjust max_memories according to your needs
- Enable debug mode for development
Contributions are welcome! To contribute:
- Fork the project
- Create a feature branch
- Submit a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Vector storage error
Solution: Check disk space and storage folder permissions -
Non-persistent memory
Solution: Ensure storage path is absolute and accessible -
Slow searches
Solution: Adjust max_memories or use optimized index
-
Unresolved variables
# Incorrect template.format(wrong_var="value") # Correct template.format(expected_var="value")
-
Missing versions
Solution: Verify prompt storage is properly initialized
- Use memory to learn preferences
- Custom prompts per user
- Maintain context between sessions
- Shared memory between agents
- Specialized templates per document type
- Historical context preservation
- Remember previous interactions
- Context-adapted prompts
- Information sharing between agents
- Progressive knowledge accumulation
- Structured templates for consistency
- Memory to avoid redundancy
- Average response time: < 2s
- Storage capacity: ~1M memories
- Search accuracy: ~95%
- Maximum prompt size: 100KB
- Maximum agents per crew: 50
- Maximum shared memory size: 10GB
- Installation
pip install fcrew- Minimal Configuration
from fcrew import FCrewConfig, EnhancedAgent, Task, Crew
# Basic configuration
config = FCrewConfig(
prompt_storage_path="~/.fcrew/prompts",
memory_storage_path="~/.fcrew/memory"
)
# Create agent with memory
agent = EnhancedAgent(
role="Assistant",
goal="Help user",
prompt_storage_path=config.effective_prompt_storage_path,
memory_storage_path=config.effective_memory_storage_path
)
# Create and execute task
task = Task(description="Greet user", agent=agent)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()- Environment Variables
# .env
OPENAI_API_KEY=sk-...
FCREW_DEBUG=false
FCREW_MEMORY_PATH=~/.fcrew/memory
FCREW_PROMPTS_PATH=~/.fcrew/prompts