rails_ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec_status +96 -0
- data/AGENT_GUIDE.md +513 -0
- data/Appraisals +49 -0
- data/COMMERCIAL_LICENSE_TEMPLATE.md +92 -0
- data/FEATURES.md +204 -0
- data/LEGAL_PROTECTION_GUIDE.md +222 -0
- data/LICENSE +62 -0
- data/LICENSE_SUMMARY.md +74 -0
- data/MIT-LICENSE +62 -0
- data/PERFORMANCE.md +300 -0
- data/PROVIDERS.md +495 -0
- data/README.md +454 -0
- data/Rakefile +11 -0
- data/SPEED_OPTIMIZATIONS.md +217 -0
- data/STRUCTURE.md +139 -0
- data/USAGE_GUIDE.md +288 -0
- data/app/channels/ai_stream_channel.rb +33 -0
- data/app/components/ai/prompt_component.rb +25 -0
- data/app/controllers/concerns/ai/context_aware.rb +77 -0
- data/app/controllers/concerns/ai/streaming.rb +41 -0
- data/app/helpers/ai_helper.rb +164 -0
- data/app/jobs/ai/generate_embedding_job.rb +25 -0
- data/app/jobs/ai/generate_summary_job.rb +25 -0
- data/app/models/concerns/ai/embeddable.rb +38 -0
- data/app/views/rails_ai/dashboard/index.html.erb +51 -0
- data/config/routes.rb +19 -0
- data/lib/generators/rails_ai/install/install_generator.rb +38 -0
- data/lib/rails_ai/agents/agent_manager.rb +258 -0
- data/lib/rails_ai/agents/agent_team.rb +243 -0
- data/lib/rails_ai/agents/base_agent.rb +331 -0
- data/lib/rails_ai/agents/collaboration.rb +238 -0
- data/lib/rails_ai/agents/memory.rb +116 -0
- data/lib/rails_ai/agents/message_bus.rb +95 -0
- data/lib/rails_ai/agents/specialized_agents.rb +391 -0
- data/lib/rails_ai/agents/task_queue.rb +111 -0
- data/lib/rails_ai/cache.rb +14 -0
- data/lib/rails_ai/config.rb +40 -0
- data/lib/rails_ai/context.rb +7 -0
- data/lib/rails_ai/context_analyzer.rb +86 -0
- data/lib/rails_ai/engine.rb +48 -0
- data/lib/rails_ai/events.rb +9 -0
- data/lib/rails_ai/image_context.rb +110 -0
- data/lib/rails_ai/performance.rb +231 -0
- data/lib/rails_ai/provider.rb +8 -0
- data/lib/rails_ai/providers/anthropic_adapter.rb +256 -0
- data/lib/rails_ai/providers/base.rb +60 -0
- data/lib/rails_ai/providers/dummy_adapter.rb +29 -0
- data/lib/rails_ai/providers/gemini_adapter.rb +509 -0
- data/lib/rails_ai/providers/openai_adapter.rb +535 -0
- data/lib/rails_ai/providers/secure_anthropic_adapter.rb +206 -0
- data/lib/rails_ai/providers/secure_openai_adapter.rb +284 -0
- data/lib/rails_ai/railtie.rb +48 -0
- data/lib/rails_ai/redactor.rb +12 -0
- data/lib/rails_ai/security/api_key_manager.rb +82 -0
- data/lib/rails_ai/security/audit_logger.rb +46 -0
- data/lib/rails_ai/security/error_handler.rb +62 -0
- data/lib/rails_ai/security/input_validator.rb +176 -0
- data/lib/rails_ai/security/secure_file_handler.rb +45 -0
- data/lib/rails_ai/security/secure_http_client.rb +177 -0
- data/lib/rails_ai/security.rb +0 -0
- data/lib/rails_ai/version.rb +5 -0
- data/lib/rails_ai/window_context.rb +103 -0
- data/lib/rails_ai.rb +502 -0
- data/monitoring/ci_setup_guide.md +214 -0
- data/monitoring/enhanced_monitoring_script.rb +237 -0
- data/monitoring/google_alerts_setup.md +42 -0
- data/monitoring_log_20250921.txt +0 -0
- data/monitoring_script.rb +161 -0
- data/rails_ai.gemspec +54 -0
- data/scripts/security_scanner.rb +353 -0
- data/setup_monitoring.sh +163 -0
- data/wiki/API-Documentation.md +734 -0
- data/wiki/Architecture-Overview.md +672 -0
- data/wiki/Contributing-Guide.md +407 -0
- data/wiki/Development-Setup.md +532 -0
- data/wiki/Home.md +278 -0
- data/wiki/Installation-Guide.md +527 -0
- data/wiki/Quick-Start.md +186 -0
- data/wiki/README.md +135 -0
- data/wiki/Release-Process.md +467 -0
- metadata +385 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 21e16f74e31a61abfafa0bf67dfe9b9c59005c71d207fb9d4551794bd5b885a8
|
4
|
+
data.tar.gz: 76c9b6bb38d931997c63b377ab067399b3a1657bfb93ecbd151a2ac9dd3994cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f72623380eab92995c6714a79b774e63bdc258f4c9429cc7e01d4f7d881642611bdb678894e15201cb4bb93b2b29df7dbbe4b3bcd397004ecb5af18fb17ee58a
|
7
|
+
data.tar.gz: 940c00badedd07db315bb50cdae77ec3bce446efa2e57a119b735e28319d2804ff5bb308635d2f65643fb8836272eaed6a4ce0003d8bcde905a8082fa1cbba4e
|
data/.rspec_status
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/agents/agent_manager_spec.rb[1:1:1] | passed | 0.00045 seconds |
|
4
|
+
./spec/agents/agent_manager_spec.rb[1:2:1] | passed | 0.00071 seconds |
|
5
|
+
./spec/agents/agent_manager_spec.rb[1:3:1] | passed | 0.00005 seconds |
|
6
|
+
./spec/agents/agent_manager_spec.rb[1:4:1] | passed | 0.00006 seconds |
|
7
|
+
./spec/agents/agent_manager_spec.rb[1:4:2] | passed | 0.00004 seconds |
|
8
|
+
./spec/agents/agent_manager_spec.rb[1:5:1] | passed | 0.0012 seconds |
|
9
|
+
./spec/agents/agent_manager_spec.rb[1:6:1] | passed | 0.00005 seconds |
|
10
|
+
./spec/agents/agent_manager_spec.rb[1:7:1] | passed | 0.00413 seconds |
|
11
|
+
./spec/agents/base_agent_spec.rb[1:1:1] | passed | 0.00064 seconds |
|
12
|
+
./spec/agents/base_agent_spec.rb[1:2:1] | passed | 0.00041 seconds |
|
13
|
+
./spec/agents/base_agent_spec.rb[1:3:1] | passed | 0.00038 seconds |
|
14
|
+
./spec/agents/base_agent_spec.rb[1:4:1] | passed | 0.00004 seconds |
|
15
|
+
./spec/agents/base_agent_spec.rb[1:4:2] | passed | 0.00004 seconds |
|
16
|
+
./spec/agents/base_agent_spec.rb[1:5:1] | passed | 0.00004 seconds |
|
17
|
+
./spec/agents/base_agent_spec.rb[1:6:1] | passed | 0.00003 seconds |
|
18
|
+
./spec/agents/base_agent_spec.rb[1:7:1] | passed | 0.00003 seconds |
|
19
|
+
./spec/agents/base_agent_spec.rb[1:8:1] | passed | 0.00002 seconds |
|
20
|
+
./spec/agents/base_agent_spec.rb[1:8:2] | passed | 0.00002 seconds |
|
21
|
+
./spec/agents/base_agent_spec.rb[1:9:1] | passed | 0.00003 seconds |
|
22
|
+
./spec/agents/specialized_agents_spec.rb[1:1:1] | passed | 0.00003 seconds |
|
23
|
+
./spec/agents/specialized_agents_spec.rb[1:2:1] | passed | 0.00014 seconds |
|
24
|
+
./spec/agents/specialized_agents_spec.rb[1:3:1] | passed | 0.00003 seconds |
|
25
|
+
./spec/agents/specialized_agents_spec.rb[2:1:1] | passed | 0.00003 seconds |
|
26
|
+
./spec/agents/specialized_agents_spec.rb[2:2:1] | passed | 0.00003 seconds |
|
27
|
+
./spec/agents/specialized_agents_spec.rb[2:3:1] | passed | 0.00002 seconds |
|
28
|
+
./spec/agents/specialized_agents_spec.rb[3:1:1] | passed | 0.00003 seconds |
|
29
|
+
./spec/agents/specialized_agents_spec.rb[3:2:1] | passed | 0.00002 seconds |
|
30
|
+
./spec/agents/specialized_agents_spec.rb[3:3:1] | passed | 0.00002 seconds |
|
31
|
+
./spec/agents/specialized_agents_spec.rb[4:1:1] | passed | 0.00003 seconds |
|
32
|
+
./spec/agents/specialized_agents_spec.rb[4:2:1] | passed | 0.00007 seconds |
|
33
|
+
./spec/context_aware_spec.rb[1:1:1] | passed | 0.00936 seconds |
|
34
|
+
./spec/context_aware_spec.rb[1:2:1] | passed | 0.00507 seconds |
|
35
|
+
./spec/context_aware_spec.rb[1:3:1] | passed | 0.00724 seconds |
|
36
|
+
./spec/context_aware_spec.rb[2:1:1] | passed | 0.0047 seconds |
|
37
|
+
./spec/context_aware_spec.rb[2:2:1] | passed | 0.00028 seconds |
|
38
|
+
./spec/context_aware_spec.rb[3:1:1] | passed | 0.00074 seconds |
|
39
|
+
./spec/context_aware_spec.rb[3:2:1] | passed | 0.00005 seconds |
|
40
|
+
./spec/context_aware_spec.rb[3:3:1] | passed | 0.00004 seconds |
|
41
|
+
./spec/context_aware_spec.rb[4:1:1] | passed | 0.00976 seconds |
|
42
|
+
./spec/context_aware_spec.rb[4:2:1] | passed | 0.01248 seconds |
|
43
|
+
./spec/context_aware_spec.rb[4:3:1] | passed | 0.01347 seconds |
|
44
|
+
./spec/performance_spec.rb[1:1:1] | passed | 0.01002 seconds |
|
45
|
+
./spec/performance_spec.rb[1:2:1] | passed | 0.01623 seconds |
|
46
|
+
./spec/performance_spec.rb[1:3:1] | passed | 0.00566 seconds |
|
47
|
+
./spec/performance_spec.rb[1:4:1] | passed | 0.3507 seconds |
|
48
|
+
./spec/performance_spec.rb[1:5:1] | passed | 0.01103 seconds |
|
49
|
+
./spec/performance_spec.rb[1:6:1] | passed | 0.03256 seconds |
|
50
|
+
./spec/performance_spec.rb[1:7:1] | passed | 0.00387 seconds |
|
51
|
+
./spec/providers/anthropic_adapter_spec.rb[1:1:1] | passed | 0.00033 seconds |
|
52
|
+
./spec/providers/anthropic_adapter_spec.rb[1:2:1] | passed | 0.0001 seconds |
|
53
|
+
./spec/providers/anthropic_adapter_spec.rb[1:3:1] | passed | 0.00017 seconds |
|
54
|
+
./spec/providers/anthropic_adapter_spec.rb[1:4:1] | passed | 0.00011 seconds |
|
55
|
+
./spec/providers/anthropic_adapter_spec.rb[1:5:1] | passed | 0.0013 seconds |
|
56
|
+
./spec/providers/anthropic_adapter_spec.rb[1:5:2] | passed | 0.00015 seconds |
|
57
|
+
./spec/providers/anthropic_adapter_spec.rb[1:5:3] | passed | 0.00011 seconds |
|
58
|
+
./spec/providers/anthropic_adapter_spec.rb[1:6:1] | passed | 0.0001 seconds |
|
59
|
+
./spec/providers/gemini_adapter_spec.rb[1:1:1] | passed | 0.00008 seconds |
|
60
|
+
./spec/providers/gemini_adapter_spec.rb[1:2:1] | passed | 0.00009 seconds |
|
61
|
+
./spec/providers/gemini_adapter_spec.rb[1:3:1] | passed | 0.00007 seconds |
|
62
|
+
./spec/providers/gemini_adapter_spec.rb[1:4:1] | passed | 0.00007 seconds |
|
63
|
+
./spec/providers/gemini_adapter_spec.rb[1:5:1] | passed | 0.00008 seconds |
|
64
|
+
./spec/providers/gemini_adapter_spec.rb[1:6:1] | passed | 0.00007 seconds |
|
65
|
+
./spec/providers/gemini_adapter_spec.rb[1:7:1] | passed | 0.00007 seconds |
|
66
|
+
./spec/providers/gemini_adapter_spec.rb[1:8:1] | passed | 0.00006 seconds |
|
67
|
+
./spec/providers/gemini_adapter_spec.rb[1:9:1] | passed | 0.00008 seconds |
|
68
|
+
./spec/providers/openai_adapter_spec.rb[1:1:1] | passed | 0.00008 seconds |
|
69
|
+
./spec/providers/openai_adapter_spec.rb[1:2:1] | passed | 0.00007 seconds |
|
70
|
+
./spec/providers/openai_adapter_spec.rb[1:3:1] | passed | 0.00008 seconds |
|
71
|
+
./spec/providers/openai_adapter_spec.rb[1:4:1] | passed | 0.00013 seconds |
|
72
|
+
./spec/providers/openai_adapter_spec.rb[1:5:1] | passed | 0.00008 seconds |
|
73
|
+
./spec/providers/openai_adapter_spec.rb[1:6:1] | passed | 0.00007 seconds |
|
74
|
+
./spec/providers/openai_adapter_spec.rb[1:7:1] | passed | 0.00008 seconds |
|
75
|
+
./spec/providers/openai_adapter_spec.rb[1:8:1] | passed | 0.00006 seconds |
|
76
|
+
./spec/providers/openai_adapter_spec.rb[1:9:1] | passed | 0.00006 seconds |
|
77
|
+
./spec/providers/openai_adapter_spec.rb[1:10:1] | passed | 0.00006 seconds |
|
78
|
+
./spec/providers/openai_adapter_spec.rb[1:11:1] | passed | 0.00008 seconds |
|
79
|
+
./spec/providers/openai_adapter_spec.rb[1:12:1] | passed | 0.00009 seconds |
|
80
|
+
./spec/providers/openai_adapter_spec.rb[1:13:1] | passed | 0.00008 seconds |
|
81
|
+
./spec/rails_ai_spec.rb[1:1:1] | passed | 0.00005 seconds |
|
82
|
+
./spec/rails_ai_spec.rb[1:1:2] | passed | 0.00091 seconds |
|
83
|
+
./spec/rails_ai_spec.rb[1:2:1] | passed | 0.00005 seconds |
|
84
|
+
./spec/rails_ai_spec.rb[1:2:2] | passed | 0.00003 seconds |
|
85
|
+
./spec/rails_ai_spec.rb[1:3:1] | passed | 0.00468 seconds |
|
86
|
+
./spec/rails_ai_spec.rb[1:3:2] | passed | 0.00592 seconds |
|
87
|
+
./spec/rails_ai_spec.rb[1:3:3] | passed | 0.00519 seconds |
|
88
|
+
./spec/rails_ai_spec.rb[1:4:1] | passed | 0.00546 seconds |
|
89
|
+
./spec/rails_ai_spec.rb[1:4:2] | passed | 0.00443 seconds |
|
90
|
+
./spec/rails_ai_spec.rb[1:4:3] | passed | 0.00592 seconds |
|
91
|
+
./spec/rails_ai_spec.rb[1:4:4] | passed | 0.00488 seconds |
|
92
|
+
./spec/rails_ai_spec.rb[1:5:1] | passed | 0.00567 seconds |
|
93
|
+
./spec/rails_ai_spec.rb[1:5:2] | passed | 0.00434 seconds |
|
94
|
+
./spec/rails_ai_spec.rb[1:5:3] | passed | 0.00448 seconds |
|
95
|
+
./spec/rails_ai_spec.rb[1:6:1] | passed | 0.00411 seconds |
|
96
|
+
./spec/rails_ai_spec.rb[1:6:2] | passed | 0.0045 seconds |
|
data/AGENT_GUIDE.md
ADDED
@@ -0,0 +1,513 @@
|
|
1
|
+
# Agent AI System Guide
|
2
|
+
|
3
|
+
Rails AI now includes a powerful Agent AI system that allows you to create multiple autonomous agents that can collaborate, pass tasks between each other, and work together to solve complex problems.
|
4
|
+
|
5
|
+
## 🚀 Quick Start
|
6
|
+
|
7
|
+
### Basic Agent Creation
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# Create a basic agent
|
11
|
+
agent = RailsAi.create_agent(
|
12
|
+
name: "MyAgent",
|
13
|
+
role: "Assistant",
|
14
|
+
capabilities: [:analysis, :writing, :research]
|
15
|
+
)
|
16
|
+
|
17
|
+
# Start the agent
|
18
|
+
agent.start!
|
19
|
+
|
20
|
+
# Give the agent a task
|
21
|
+
task = {
|
22
|
+
id: "task_1",
|
23
|
+
description: "Analyze market trends for AI technology",
|
24
|
+
required_capabilities: [:analysis, :research]
|
25
|
+
}
|
26
|
+
|
27
|
+
agent.assign_task(task)
|
28
|
+
```
|
29
|
+
|
30
|
+
### Specialized Agents
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Research Agent - Specialized in information gathering
|
34
|
+
research_agent = RailsAi.create_research_agent(name: "ResearchBot")
|
35
|
+
|
36
|
+
# Creative Agent - Specialized in creative tasks
|
37
|
+
creative_agent = RailsAi.create_creative_agent(name: "CreativeBot")
|
38
|
+
|
39
|
+
# Technical Agent - Specialized in technical problem-solving
|
40
|
+
tech_agent = RailsAi.create_technical_agent(name: "TechBot")
|
41
|
+
|
42
|
+
# Coordinator Agent - Specialized in managing other agents
|
43
|
+
coordinator = RailsAi.create_coordinator_agent(name: "CoordinatorBot")
|
44
|
+
```
|
45
|
+
|
46
|
+
## 🤖 Agent Types
|
47
|
+
|
48
|
+
### 1. Base Agent
|
49
|
+
The foundation for all agents with core functionality.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
agent = RailsAi.create_agent(
|
53
|
+
name: "BaseAgent",
|
54
|
+
role: "General Purpose",
|
55
|
+
capabilities: [:analysis, :communication, :problem_solving],
|
56
|
+
memory_size: 1000,
|
57
|
+
max_concurrent_tasks: 3
|
58
|
+
)
|
59
|
+
```
|
60
|
+
|
61
|
+
### 2. Research Agent
|
62
|
+
Specialized in gathering and analyzing information.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
research_agent = RailsAi.create_research_agent(name: "ResearchBot")
|
66
|
+
|
67
|
+
# Conduct research
|
68
|
+
research_result = research_agent.research_topic("quantum computing", depth: :deep)
|
69
|
+
|
70
|
+
# Fact check claims
|
71
|
+
fact_check_result = research_agent.fact_check("AI will replace all jobs by 2030")
|
72
|
+
```
|
73
|
+
|
74
|
+
### 3. Creative Agent
|
75
|
+
Specialized in creative tasks and ideation.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
creative_agent = RailsAi.create_creative_agent(name: "CreativeBot")
|
79
|
+
|
80
|
+
# Brainstorm ideas
|
81
|
+
ideas = creative_agent.brainstorm("sustainable energy solutions", quantity: 10)
|
82
|
+
|
83
|
+
# Write stories
|
84
|
+
story = creative_agent.write_story("A time traveler discovers their future", genre: :sci_fi, length: :medium)
|
85
|
+
|
86
|
+
# Design concepts
|
87
|
+
design = creative_agent.design_concept("eco-friendly smartphone", style: :modern)
|
88
|
+
```
|
89
|
+
|
90
|
+
### 4. Technical Agent
|
91
|
+
Specialized in technical problem-solving and system design.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
tech_agent = RailsAi.create_technical_agent(name: "TechBot")
|
95
|
+
|
96
|
+
# Solve technical problems
|
97
|
+
solution = tech_agent.solve_problem("Database performance optimization", approach: :systematic)
|
98
|
+
|
99
|
+
# Review code
|
100
|
+
code_review = tech_agent.code_review(ruby_code, language: :ruby)
|
101
|
+
|
102
|
+
# Design systems
|
103
|
+
system_design = tech_agent.design_system("microservices architecture for e-commerce")
|
104
|
+
```
|
105
|
+
|
106
|
+
### 5. Coordinator Agent
|
107
|
+
Specialized in managing and coordinating other agents.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
coordinator = RailsAi.create_coordinator_agent(name: "CoordinatorBot")
|
111
|
+
|
112
|
+
# Coordinate complex tasks
|
113
|
+
coordination_plan = coordinator.coordinate_task(complex_task, available_agents)
|
114
|
+
|
115
|
+
# Resolve conflicts
|
116
|
+
resolution = coordinator.resolve_conflict("Agent disagreement on approach", involved_agents)
|
117
|
+
|
118
|
+
# Optimize workflows
|
119
|
+
optimization = coordinator.optimize_workflow(workflow_description, constraints)
|
120
|
+
```
|
121
|
+
|
122
|
+
## 🏢 Agent Teams
|
123
|
+
|
124
|
+
### Creating Teams
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
# Create a team with multiple agents
|
128
|
+
team = RailsAi.create_agent_team(
|
129
|
+
"MarketingTeam",
|
130
|
+
[research_agent, creative_agent, coordinator],
|
131
|
+
strategy: :collaborative
|
132
|
+
)
|
133
|
+
|
134
|
+
# Assign tasks to the team
|
135
|
+
team.assign_task({
|
136
|
+
description: "Create a comprehensive marketing strategy",
|
137
|
+
type: :creative
|
138
|
+
})
|
139
|
+
```
|
140
|
+
|
141
|
+
### Team Strategies
|
142
|
+
|
143
|
+
- **`:round_robin`** - Tasks assigned in rotation
|
144
|
+
- **`:capability_based`** - Tasks assigned based on required capabilities
|
145
|
+
- **`:load_balanced`** - Tasks assigned to least busy agents
|
146
|
+
- **`:collaborative`** - All agents work together on tasks
|
147
|
+
|
148
|
+
### Team Collaboration
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
# Collaborative task execution
|
152
|
+
collaboration_result = team.collaborate_on_task({
|
153
|
+
description: "Design a new product",
|
154
|
+
type: :creative
|
155
|
+
})
|
156
|
+
|
157
|
+
# Team meetings
|
158
|
+
meeting = team.team_meeting("Q4 strategy planning")
|
159
|
+
|
160
|
+
# Knowledge sharing
|
161
|
+
team.share_knowledge("ResearchBot", "Market analysis shows 30% growth in AI sector")
|
162
|
+
```
|
163
|
+
|
164
|
+
## 🔄 Agent Communication
|
165
|
+
|
166
|
+
### Direct Communication
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
# Send message between agents
|
170
|
+
RailsAi.send_agent_message("ResearchBot", "CreativeBot", {
|
171
|
+
type: :research_findings,
|
172
|
+
data: "AI market will reach $1.8T by 2030"
|
173
|
+
})
|
174
|
+
|
175
|
+
# Broadcast message to all agents
|
176
|
+
RailsAi.broadcast_agent_message("CoordinatorBot", {
|
177
|
+
type: :status_update,
|
178
|
+
message: "All systems operational"
|
179
|
+
})
|
180
|
+
```
|
181
|
+
|
182
|
+
### Agent Memory
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
# Agents remember important information
|
186
|
+
agent.remember("project_deadline", "2024-12-31", importance: :critical)
|
187
|
+
agent.remember("client_preferences", "Prefers detailed reports", importance: :high)
|
188
|
+
|
189
|
+
# Recall information
|
190
|
+
deadline = agent.recall("project_deadline")
|
191
|
+
preferences = agent.recall("client_preferences")
|
192
|
+
|
193
|
+
# Search memory
|
194
|
+
relevant_memories = agent.memory.search("project")
|
195
|
+
```
|
196
|
+
|
197
|
+
## 📋 Task Management
|
198
|
+
|
199
|
+
### Task Submission
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
# Submit task to the system
|
203
|
+
task = RailsAi.submit_task({
|
204
|
+
id: "task_001",
|
205
|
+
description: "Analyze customer feedback data",
|
206
|
+
required_capabilities: [:analysis, :data_processing],
|
207
|
+
priority: :high,
|
208
|
+
deadline: 1.hour.from_now
|
209
|
+
})
|
210
|
+
|
211
|
+
# Auto-assign to best agent
|
212
|
+
RailsAi.auto_assign_task(task)
|
213
|
+
|
214
|
+
# Manually assign to specific agent
|
215
|
+
RailsAi.assign_task(task, "ResearchBot")
|
216
|
+
```
|
217
|
+
|
218
|
+
### Task Delegation
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
# Agent delegates task to another agent
|
222
|
+
agent1.delegate_task(task, agent2, reason: "Requires specialized knowledge")
|
223
|
+
|
224
|
+
# Accept delegated task
|
225
|
+
agent2.accept_delegated_task(delegation_message)
|
226
|
+
```
|
227
|
+
|
228
|
+
## 🎯 Agent Collaboration
|
229
|
+
|
230
|
+
### Multi-Agent Collaboration
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
# Orchestrate collaboration between multiple agents
|
234
|
+
collaboration = RailsAi.orchestrate_collaboration(
|
235
|
+
{
|
236
|
+
description: "Develop a new AI product",
|
237
|
+
type: :problem_solving
|
238
|
+
},
|
239
|
+
["ResearchBot", "TechBot", "CreativeBot"]
|
240
|
+
)
|
241
|
+
|
242
|
+
# Check collaboration status
|
243
|
+
if collaboration.is_complete?
|
244
|
+
result = collaboration.summary
|
245
|
+
puts "Collaboration completed: #{result[:duration]} seconds"
|
246
|
+
end
|
247
|
+
```
|
248
|
+
|
249
|
+
### Workflow Phases
|
250
|
+
|
251
|
+
The collaboration system supports different workflow types:
|
252
|
+
|
253
|
+
- **`:analysis`** - Data gathering → Pattern recognition → Synthesis
|
254
|
+
- **`:creative`** - Brainstorming → Refinement → Finalization
|
255
|
+
- **`:problem_solving`** - Problem analysis → Solution generation → Evaluation → Implementation
|
256
|
+
- **`:general`** - Discussion → Consensus → Execution
|
257
|
+
|
258
|
+
## 📊 Monitoring and Health
|
259
|
+
|
260
|
+
### System Status
|
261
|
+
|
262
|
+
```ruby
|
263
|
+
# Check overall system status
|
264
|
+
status = RailsAi.agent_system_status
|
265
|
+
puts "Active agents: #{status[:active_agents]}"
|
266
|
+
puts "Pending tasks: #{status[:pending_tasks]}"
|
267
|
+
|
268
|
+
# Health check
|
269
|
+
health = RailsAi.agent_health_check
|
270
|
+
puts "System healthy: #{health[:system_healthy]}"
|
271
|
+
```
|
272
|
+
|
273
|
+
### Agent Status
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
# Individual agent status
|
277
|
+
agent_status = agent.status
|
278
|
+
puts "Agent state: #{agent_status[:state]}"
|
279
|
+
puts "Active tasks: #{agent_status[:active_tasks]}"
|
280
|
+
puts "Memory usage: #{agent_status[:memory_usage]}%"
|
281
|
+
|
282
|
+
# Agent health
|
283
|
+
health = agent.health_check
|
284
|
+
puts "Memory healthy: #{health[:memory_healthy]}"
|
285
|
+
puts "No stuck tasks: #{health[:no_stuck_tasks]}"
|
286
|
+
```
|
287
|
+
|
288
|
+
## 🔧 Advanced Configuration
|
289
|
+
|
290
|
+
### Agent Configuration
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
# Create agent with custom configuration
|
294
|
+
agent = RailsAi.create_agent(
|
295
|
+
name: "CustomAgent",
|
296
|
+
role: "Specialist",
|
297
|
+
capabilities: [:analysis, :research],
|
298
|
+
memory_size: 2000,
|
299
|
+
max_concurrent_tasks: 5,
|
300
|
+
max_task_duration: 1.hour
|
301
|
+
)
|
302
|
+
```
|
303
|
+
|
304
|
+
### Agent Manager Configuration
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
# Start the agent system
|
308
|
+
RailsAi.start_agents!
|
309
|
+
|
310
|
+
# Stop the agent system
|
311
|
+
RailsAi.stop_agents!
|
312
|
+
|
313
|
+
# Pause/Resume
|
314
|
+
RailsAi.agent_manager.pause!
|
315
|
+
RailsAi.agent_manager.resume!
|
316
|
+
```
|
317
|
+
|
318
|
+
## 🎨 Real-World Examples
|
319
|
+
|
320
|
+
### Content Creation Pipeline
|
321
|
+
|
322
|
+
```ruby
|
323
|
+
# Create specialized agents
|
324
|
+
researcher = RailsAi.create_research_agent(name: "ContentResearcher")
|
325
|
+
writer = RailsAi.create_creative_agent(name: "ContentWriter")
|
326
|
+
editor = RailsAi.create_technical_agent(name: "ContentEditor")
|
327
|
+
|
328
|
+
# Create content team
|
329
|
+
content_team = RailsAi.create_agent_team(
|
330
|
+
"ContentTeam",
|
331
|
+
[researcher, writer, editor],
|
332
|
+
strategy: :collaborative
|
333
|
+
)
|
334
|
+
|
335
|
+
# Content creation workflow
|
336
|
+
def create_blog_post(topic)
|
337
|
+
# Research phase
|
338
|
+
research_task = {
|
339
|
+
description: "Research #{topic} for blog post",
|
340
|
+
type: :analysis
|
341
|
+
}
|
342
|
+
content_team.assign_task(research_task)
|
343
|
+
|
344
|
+
# Writing phase
|
345
|
+
writing_task = {
|
346
|
+
description: "Write blog post about #{topic}",
|
347
|
+
type: :creative,
|
348
|
+
dependencies: [research_task[:id]]
|
349
|
+
}
|
350
|
+
content_team.assign_task(writing_task)
|
351
|
+
|
352
|
+
# Editing phase
|
353
|
+
editing_task = {
|
354
|
+
description: "Edit and optimize blog post",
|
355
|
+
type: :problem_solving,
|
356
|
+
dependencies: [writing_task[:id]]
|
357
|
+
}
|
358
|
+
content_team.assign_task(editing_task)
|
359
|
+
end
|
360
|
+
```
|
361
|
+
|
362
|
+
### Customer Support System
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
# Create support agents
|
366
|
+
triage_agent = RailsAi.create_agent(
|
367
|
+
name: "TriageAgent",
|
368
|
+
role: "Support Triage",
|
369
|
+
capabilities: [:classification, :routing]
|
370
|
+
)
|
371
|
+
|
372
|
+
technical_agent = RailsAi.create_technical_agent(name: "TechSupport")
|
373
|
+
billing_agent = RailsAi.create_agent(
|
374
|
+
name: "BillingAgent",
|
375
|
+
role: "Billing Support",
|
376
|
+
capabilities: [:billing, :account_management]
|
377
|
+
)
|
378
|
+
|
379
|
+
# Support workflow
|
380
|
+
def handle_support_ticket(ticket)
|
381
|
+
# Triage the ticket
|
382
|
+
triage_result = triage_agent.think("Classify this support ticket: #{ticket[:description]}")
|
383
|
+
|
384
|
+
case triage_result
|
385
|
+
when /technical/
|
386
|
+
technical_agent.assign_task(ticket)
|
387
|
+
when /billing/
|
388
|
+
billing_agent.assign_task(ticket)
|
389
|
+
else
|
390
|
+
# Escalate to human
|
391
|
+
Rails.logger.info("Ticket requires human intervention: #{ticket[:id]}")
|
392
|
+
end
|
393
|
+
end
|
394
|
+
```
|
395
|
+
|
396
|
+
### Research and Development
|
397
|
+
|
398
|
+
```ruby
|
399
|
+
# Create R&D team
|
400
|
+
researcher = RailsAi.create_research_agent(name: "R&D_Researcher")
|
401
|
+
architect = RailsAi.create_technical_agent(name: "SystemArchitect")
|
402
|
+
prototyper = RailsAi.create_creative_agent(name: "PrototypeDesigner")
|
403
|
+
coordinator = RailsAi.create_coordinator_agent(name: "R&D_Coordinator")
|
404
|
+
|
405
|
+
# R&D workflow
|
406
|
+
def develop_new_feature(requirements)
|
407
|
+
# Research phase
|
408
|
+
research_task = {
|
409
|
+
description: "Research existing solutions for #{requirements[:feature]}",
|
410
|
+
type: :analysis
|
411
|
+
}
|
412
|
+
researcher.assign_task(research_task)
|
413
|
+
|
414
|
+
# Architecture phase
|
415
|
+
architecture_task = {
|
416
|
+
description: "Design architecture for #{requirements[:feature]}",
|
417
|
+
type: :problem_solving,
|
418
|
+
dependencies: [research_task[:id]]
|
419
|
+
}
|
420
|
+
architect.assign_task(architecture_task)
|
421
|
+
|
422
|
+
# Prototype phase
|
423
|
+
prototype_task = {
|
424
|
+
description: "Create prototype for #{requirements[:feature]}",
|
425
|
+
type: :creative,
|
426
|
+
dependencies: [architecture_task[:id]]
|
427
|
+
}
|
428
|
+
prototyper.assign_task(prototype_task)
|
429
|
+
|
430
|
+
# Coordination
|
431
|
+
coordinator.coordinate_task(requirements, [researcher, architect, prototyper])
|
432
|
+
end
|
433
|
+
```
|
434
|
+
|
435
|
+
## 🚀 Best Practices
|
436
|
+
|
437
|
+
### 1. Agent Design
|
438
|
+
- **Single Responsibility**: Each agent should have a clear, focused role
|
439
|
+
- **Capability Matching**: Ensure agents have the right capabilities for their tasks
|
440
|
+
- **Memory Management**: Use appropriate memory sizes and importance levels
|
441
|
+
|
442
|
+
### 2. Task Management
|
443
|
+
- **Clear Descriptions**: Provide detailed task descriptions with required capabilities
|
444
|
+
- **Priority Handling**: Use appropriate priority levels for task scheduling
|
445
|
+
- **Dependency Management**: Handle task dependencies properly
|
446
|
+
|
447
|
+
### 3. Communication
|
448
|
+
- **Structured Messages**: Use consistent message formats and types
|
449
|
+
- **Error Handling**: Implement proper error handling for failed communications
|
450
|
+
- **Monitoring**: Monitor agent communication patterns and health
|
451
|
+
|
452
|
+
### 4. Performance
|
453
|
+
- **Resource Management**: Monitor memory usage and task queues
|
454
|
+
- **Load Balancing**: Distribute tasks evenly across available agents
|
455
|
+
- **Caching**: Use appropriate caching for frequently accessed information
|
456
|
+
|
457
|
+
### 5. Security
|
458
|
+
- **Input Validation**: Validate all inputs to agents
|
459
|
+
- **Access Control**: Implement proper access controls for agent operations
|
460
|
+
- **Audit Logging**: Log all agent activities for security auditing
|
461
|
+
|
462
|
+
## 🔍 Troubleshooting
|
463
|
+
|
464
|
+
### Common Issues
|
465
|
+
|
466
|
+
#### Agent Not Responding
|
467
|
+
```ruby
|
468
|
+
# Check agent health
|
469
|
+
health = agent.health_check
|
470
|
+
if !health[:last_activity_recent]
|
471
|
+
Rails.logger.warn("Agent #{agent.name} may be stuck")
|
472
|
+
agent.resume! # Try to resume
|
473
|
+
end
|
474
|
+
```
|
475
|
+
|
476
|
+
#### Memory Issues
|
477
|
+
```ruby
|
478
|
+
# Check memory usage
|
479
|
+
if agent.memory.usage_percentage > 90
|
480
|
+
Rails.logger.warn("Agent #{agent.name} memory usage high")
|
481
|
+
agent.memory.clear! # Clear old memories
|
482
|
+
end
|
483
|
+
```
|
484
|
+
|
485
|
+
#### Task Queue Backup
|
486
|
+
```ruby
|
487
|
+
# Check task queue status
|
488
|
+
status = RailsAi.agent_system_status
|
489
|
+
if status[:pending_tasks] > 100
|
490
|
+
Rails.logger.warn("Task queue backing up")
|
491
|
+
# Consider adding more agents or increasing capacity
|
492
|
+
end
|
493
|
+
```
|
494
|
+
|
495
|
+
### Debug Mode
|
496
|
+
|
497
|
+
```ruby
|
498
|
+
# Enable debug logging
|
499
|
+
Rails.logger.level = :debug
|
500
|
+
|
501
|
+
# Check agent states
|
502
|
+
RailsAi.list_agents.each do |agent_status|
|
503
|
+
puts "#{agent_status[:name]}: #{agent_status[:state]}"
|
504
|
+
end
|
505
|
+
```
|
506
|
+
|
507
|
+
---
|
508
|
+
|
509
|
+
**Rails AI Agent System enables powerful multi-agent collaboration!** 🤖
|
510
|
+
|
511
|
+
**Create autonomous agents that work together to solve complex problems!** 🚀
|
512
|
+
|
513
|
+
**Build intelligent systems with specialized agent teams!** ✨
|
data/Appraisals
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise "rails-5-2" do
|
4
|
+
gem "rails", "~> 5.2.0"
|
5
|
+
gem "actioncable", "~> 5.2.0"
|
6
|
+
gem "activejob", "~> 5.2.0"
|
7
|
+
gem "view_component", "~> 2.0"
|
8
|
+
gem "rack-attack", "~> 5.0"
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise "rails-6-0" do
|
12
|
+
gem "rails", "~> 6.0.0"
|
13
|
+
gem "actioncable", "~> 6.0.0"
|
14
|
+
gem "activejob", "~> 6.0.0"
|
15
|
+
gem "view_component", "~> 2.0"
|
16
|
+
gem "rack-attack", "~> 6.0"
|
17
|
+
end
|
18
|
+
|
19
|
+
appraise "rails-6-1" do
|
20
|
+
gem "rails", "~> 6.1.0"
|
21
|
+
gem "actioncable", "~> 6.1.0"
|
22
|
+
gem "activejob", "~> 6.1.0"
|
23
|
+
gem "view_component", "~> 2.0"
|
24
|
+
gem "rack-attack", "~> 6.0"
|
25
|
+
end
|
26
|
+
|
27
|
+
appraise "rails-7-0" do
|
28
|
+
gem "rails", "~> 7.0.0"
|
29
|
+
gem "actioncable", "~> 7.0.0"
|
30
|
+
gem "activejob", "~> 7.0.0"
|
31
|
+
gem "view_component", "~> 3.0"
|
32
|
+
gem "rack-attack", "~> 6.0"
|
33
|
+
end
|
34
|
+
|
35
|
+
appraise "rails-7-1" do
|
36
|
+
gem "rails", "~> 7.1.0"
|
37
|
+
gem "actioncable", "~> 7.1.0"
|
38
|
+
gem "activejob", "~> 7.1.0"
|
39
|
+
gem "view_component", "~> 3.0"
|
40
|
+
gem "rack-attack", "~> 6.0"
|
41
|
+
end
|
42
|
+
|
43
|
+
appraise "rails-8-0" do
|
44
|
+
gem "rails", "~> 8.0.0"
|
45
|
+
gem "actioncable", "~> 8.0.0"
|
46
|
+
gem "activejob", "~> 8.0.0"
|
47
|
+
gem "view_component", "~> 4.0"
|
48
|
+
gem "rack-attack", "~> 7.0"
|
49
|
+
end
|