ag-cortex 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.
Files changed (162) hide show
  1. package/.agent/commands/test-browser.md +339 -0
  2. package/.agent/rules/00-constitution.md +46 -0
  3. package/.agent/rules/project-rules.md +49 -0
  4. package/.agent/skills/agent-browser/SKILL.md +223 -0
  5. package/.agent/skills/agent-native-architecture/SKILL.md +435 -0
  6. package/.agent/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
  7. package/.agent/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
  8. package/.agent/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
  9. package/.agent/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
  10. package/.agent/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
  11. package/.agent/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
  12. package/.agent/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
  13. package/.agent/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
  14. package/.agent/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
  15. package/.agent/skills/agent-native-architecture/references/product-implications.md +443 -0
  16. package/.agent/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
  17. package/.agent/skills/agent-native-architecture/references/self-modification.md +269 -0
  18. package/.agent/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
  19. package/.agent/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
  20. package/.agent/skills/agent-native-reviewer/SKILL.md +246 -0
  21. package/.agent/skills/andrew-kane-gem-writer/SKILL.md +184 -0
  22. package/.agent/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
  23. package/.agent/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
  24. package/.agent/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
  25. package/.agent/skills/andrew-kane-gem-writer/references/resources.md +119 -0
  26. package/.agent/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
  27. package/.agent/skills/ankane-readme-writer/SKILL.md +50 -0
  28. package/.agent/skills/architecture-strategist/SKILL.md +52 -0
  29. package/.agent/skills/best-practices-researcher/SKILL.md +100 -0
  30. package/.agent/skills/bug-reproduction-validator/SKILL.md +67 -0
  31. package/.agent/skills/code-simplicity-reviewer/SKILL.md +85 -0
  32. package/.agent/skills/coding-tutor/.claude-plugin/plugin.json +9 -0
  33. package/.agent/skills/coding-tutor/README.md +37 -0
  34. package/.agent/skills/coding-tutor/commands/quiz-me.md +1 -0
  35. package/.agent/skills/coding-tutor/commands/sync-tutorials.md +25 -0
  36. package/.agent/skills/coding-tutor/commands/teach-me.md +1 -0
  37. package/.agent/skills/coding-tutor/skills/coding-tutor/SKILL.md +214 -0
  38. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/create_tutorial.py +202 -0
  39. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/index_tutorials.py +203 -0
  40. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/quiz_priority.py +190 -0
  41. package/.agent/skills/coding-tutor/skills/coding-tutor/scripts/setup_tutorials.py +132 -0
  42. package/.agent/skills/compound-docs/SKILL.md +510 -0
  43. package/.agent/skills/compound-docs/assets/critical-pattern-template.md +34 -0
  44. package/.agent/skills/compound-docs/assets/resolution-template.md +93 -0
  45. package/.agent/skills/compound-docs/references/yaml-schema.md +65 -0
  46. package/.agent/skills/compound-docs/schema.yaml +176 -0
  47. package/.agent/skills/create-agent-skills/SKILL.md +299 -0
  48. package/.agent/skills/create-agent-skills/references/api-security.md +226 -0
  49. package/.agent/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
  50. package/.agent/skills/create-agent-skills/references/best-practices.md +404 -0
  51. package/.agent/skills/create-agent-skills/references/common-patterns.md +595 -0
  52. package/.agent/skills/create-agent-skills/references/core-principles.md +437 -0
  53. package/.agent/skills/create-agent-skills/references/executable-code.md +175 -0
  54. package/.agent/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
  55. package/.agent/skills/create-agent-skills/references/official-spec.md +185 -0
  56. package/.agent/skills/create-agent-skills/references/recommended-structure.md +168 -0
  57. package/.agent/skills/create-agent-skills/references/skill-structure.md +372 -0
  58. package/.agent/skills/create-agent-skills/references/using-scripts.md +113 -0
  59. package/.agent/skills/create-agent-skills/references/using-templates.md +112 -0
  60. package/.agent/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
  61. package/.agent/skills/create-agent-skills/templates/router-skill.md +73 -0
  62. package/.agent/skills/create-agent-skills/templates/simple-skill.md +33 -0
  63. package/.agent/skills/create-agent-skills/workflows/add-reference.md +96 -0
  64. package/.agent/skills/create-agent-skills/workflows/add-script.md +93 -0
  65. package/.agent/skills/create-agent-skills/workflows/add-template.md +74 -0
  66. package/.agent/skills/create-agent-skills/workflows/add-workflow.md +120 -0
  67. package/.agent/skills/create-agent-skills/workflows/audit-skill.md +138 -0
  68. package/.agent/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
  69. package/.agent/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
  70. package/.agent/skills/create-agent-skills/workflows/get-guidance.md +121 -0
  71. package/.agent/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
  72. package/.agent/skills/create-agent-skills/workflows/verify-skill.md +204 -0
  73. package/.agent/skills/data-integrity-guardian/SKILL.md +70 -0
  74. package/.agent/skills/data-migration-expert/SKILL.md +97 -0
  75. package/.agent/skills/deployment-verification-agent/SKILL.md +159 -0
  76. package/.agent/skills/design-implementation-reviewer/SKILL.md +85 -0
  77. package/.agent/skills/design-iterator/SKILL.md +197 -0
  78. package/.agent/skills/dhh-rails-reviewer/SKILL.md +45 -0
  79. package/.agent/skills/dhh-rails-style/SKILL.md +184 -0
  80. package/.agent/skills/dhh-rails-style/references/architecture.md +653 -0
  81. package/.agent/skills/dhh-rails-style/references/controllers.md +303 -0
  82. package/.agent/skills/dhh-rails-style/references/frontend.md +510 -0
  83. package/.agent/skills/dhh-rails-style/references/gems.md +266 -0
  84. package/.agent/skills/dhh-rails-style/references/models.md +359 -0
  85. package/.agent/skills/dhh-rails-style/references/testing.md +338 -0
  86. package/.agent/skills/dspy-ruby/SKILL.md +594 -0
  87. package/.agent/skills/dspy-ruby/assets/config-template.rb +359 -0
  88. package/.agent/skills/dspy-ruby/assets/module-template.rb +326 -0
  89. package/.agent/skills/dspy-ruby/assets/signature-template.rb +143 -0
  90. package/.agent/skills/dspy-ruby/references/core-concepts.md +265 -0
  91. package/.agent/skills/dspy-ruby/references/optimization.md +623 -0
  92. package/.agent/skills/dspy-ruby/references/providers.md +305 -0
  93. package/.agent/skills/every-style-editor/SKILL.md +134 -0
  94. package/.agent/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
  95. package/.agent/skills/figma-design-sync/SKILL.md +166 -0
  96. package/.agent/skills/file-todos/SKILL.md +251 -0
  97. package/.agent/skills/file-todos/assets/todo-template.md +155 -0
  98. package/.agent/skills/framework-docs-researcher/SKILL.md +83 -0
  99. package/.agent/skills/frontend-design/SKILL.md +42 -0
  100. package/.agent/skills/gemini-imagegen/SKILL.md +237 -0
  101. package/.agent/skills/gemini-imagegen/requirements.txt +2 -0
  102. package/.agent/skills/gemini-imagegen/scripts/compose_images.py +168 -0
  103. package/.agent/skills/gemini-imagegen/scripts/edit_image.py +157 -0
  104. package/.agent/skills/gemini-imagegen/scripts/gemini_images.py +265 -0
  105. package/.agent/skills/gemini-imagegen/scripts/generate_image.py +147 -0
  106. package/.agent/skills/gemini-imagegen/scripts/multi_turn_chat.py +215 -0
  107. package/.agent/skills/git-history-analyzer/SKILL.md +42 -0
  108. package/.agent/skills/git-worktree/SKILL.md +302 -0
  109. package/.agent/skills/git-worktree/scripts/worktree-manager.sh +345 -0
  110. package/.agent/skills/julik-frontend-races-reviewer/SKILL.md +222 -0
  111. package/.agent/skills/kieran-python-reviewer/SKILL.md +104 -0
  112. package/.agent/skills/kieran-rails-reviewer/SKILL.md +86 -0
  113. package/.agent/skills/kieran-typescript-reviewer/SKILL.md +95 -0
  114. package/.agent/skills/lint/SKILL.md +16 -0
  115. package/.agent/skills/pattern-recognition-specialist/SKILL.md +57 -0
  116. package/.agent/skills/performance-oracle/SKILL.md +110 -0
  117. package/.agent/skills/pr-comment-resolver/SKILL.md +69 -0
  118. package/.agent/skills/rclone/SKILL.md +150 -0
  119. package/.agent/skills/rclone/scripts/check_setup.sh +60 -0
  120. package/.agent/skills/repo-research-analyst/SKILL.md +113 -0
  121. package/.agent/skills/security-sentinel/SKILL.md +93 -0
  122. package/.agent/skills/skill-creator/SKILL.md +209 -0
  123. package/.agent/skills/skill-creator/scripts/init_skill.py +304 -0
  124. package/.agent/skills/skill-creator/scripts/package_skill.py +112 -0
  125. package/.agent/skills/skill-creator/scripts/quick_validate.py +72 -0
  126. package/.agent/skills/spec-flow-analyzer/SKILL.md +113 -0
  127. package/.agent/skills/test-agent/SKILL.md +4 -0
  128. package/.agent/workflows/agent-native-audit.md +277 -0
  129. package/.agent/workflows/ask-user-question.md +21 -0
  130. package/.agent/workflows/changelog.md +137 -0
  131. package/.agent/workflows/compound.md +202 -0
  132. package/.agent/workflows/create-agent-skill.md +8 -0
  133. package/.agent/workflows/deepen-plan-research.md +334 -0
  134. package/.agent/workflows/deepen-plan-synthesis.md +182 -0
  135. package/.agent/workflows/deepen-plan.md +79 -0
  136. package/.agent/workflows/feature-video.md +342 -0
  137. package/.agent/workflows/generate-command.md +162 -0
  138. package/.agent/workflows/heal-skill.md +142 -0
  139. package/.agent/workflows/lfg.md +20 -0
  140. package/.agent/workflows/plan-analysis.md +67 -0
  141. package/.agent/workflows/plan-next-steps.md +63 -0
  142. package/.agent/workflows/plan-review.md +33 -0
  143. package/.agent/workflows/plan-synthesis.md +106 -0
  144. package/.agent/workflows/plan.md +49 -0
  145. package/.agent/workflows/report-bug.md +150 -0
  146. package/.agent/workflows/reproduce-bug.md +99 -0
  147. package/.agent/workflows/resolve-parallel.md +34 -0
  148. package/.agent/workflows/resolve-pr-parallel.md +49 -0
  149. package/.agent/workflows/resolve-todo-parallel.md +35 -0
  150. package/.agent/workflows/review-analysis.md +145 -0
  151. package/.agent/workflows/review-synthesis.md +262 -0
  152. package/.agent/workflows/review.md +64 -0
  153. package/.agent/workflows/ship.md +90 -0
  154. package/.agent/workflows/test-command.md +3 -0
  155. package/.agent/workflows/triage.md +310 -0
  156. package/.agent/workflows/work.md +157 -0
  157. package/.agent/workflows/xcode-test.md +332 -0
  158. package/LICENSE +22 -0
  159. package/README.md +49 -0
  160. package/bin/ag-cortex.js +54 -0
  161. package/lib/core.js +165 -0
  162. package/package.json +31 -0
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Example DSPy Signature Template
4
+ # This template demonstrates best practices for creating type-safe signatures
5
+
6
+ class ExampleSignature < DSPy::Signature
7
+ # Clear, specific description of what this signature does
8
+ # Good: "Classify customer support emails into Technical, Billing, or General categories"
9
+ # Avoid: "Classify emails"
10
+ description "Describe what this signature accomplishes and what output it produces"
11
+
12
+ # Input fields: Define what data the LLM receives
13
+ input do
14
+ # Basic field with description
15
+ const :field_name, String, desc: "Clear description of this input field"
16
+
17
+ # Numeric fields
18
+ const :count, Integer, desc: "Number of items to process"
19
+ const :score, Float, desc: "Confidence score between 0.0 and 1.0"
20
+
21
+ # Boolean fields
22
+ const :is_active, T::Boolean, desc: "Whether the item is currently active"
23
+
24
+ # Array fields
25
+ const :tags, T::Array[String], desc: "List of tags associated with the item"
26
+
27
+ # Optional: Enum for constrained values
28
+ const :priority, T.enum(["Low", "Medium", "High"]), desc: "Priority level"
29
+ end
30
+
31
+ # Output fields: Define what data the LLM produces
32
+ output do
33
+ # Primary output
34
+ const :result, String, desc: "The main result of the operation"
35
+
36
+ # Classification result with enum
37
+ const :category, T.enum(["Technical", "Billing", "General"]),
38
+ desc: "Category classification - must be one of: Technical, Billing, General"
39
+
40
+ # Confidence/metadata
41
+ const :confidence, Float, desc: "Confidence score (0.0-1.0) for this classification"
42
+
43
+ # Optional reasoning (automatically added by ChainOfThought)
44
+ # const :reasoning, String, desc: "Step-by-step reasoning for the classification"
45
+ end
46
+ end
47
+
48
+ # Example with multimodal input (vision)
49
+ class VisionExampleSignature < DSPy::Signature
50
+ description "Analyze an image and answer questions about its content"
51
+
52
+ input do
53
+ const :image, DSPy::Image, desc: "The image to analyze"
54
+ const :question, String, desc: "Question about the image content"
55
+ end
56
+
57
+ output do
58
+ const :answer, String, desc: "Detailed answer to the question about the image"
59
+ const :confidence, Float, desc: "Confidence in the answer (0.0-1.0)"
60
+ end
61
+ end
62
+
63
+ # Example for complex analysis task
64
+ class SentimentAnalysisSignature < DSPy::Signature
65
+ description "Analyze the sentiment of text with nuanced emotion detection"
66
+
67
+ input do
68
+ const :text, String, desc: "The text to analyze for sentiment"
69
+ const :context, String, desc: "Additional context about the text source or situation"
70
+ end
71
+
72
+ output do
73
+ const :sentiment, T.enum(["Positive", "Negative", "Neutral", "Mixed"]),
74
+ desc: "Overall sentiment - must be Positive, Negative, Neutral, or Mixed"
75
+
76
+ const :emotions, T::Array[String],
77
+ desc: "List of specific emotions detected (e.g., joy, anger, sadness, fear)"
78
+
79
+ const :intensity, T.enum(["Low", "Medium", "High"]),
80
+ desc: "Intensity of the detected sentiment"
81
+
82
+ const :confidence, Float,
83
+ desc: "Confidence in the sentiment classification (0.0-1.0)"
84
+ end
85
+ end
86
+
87
+ # Example for code generation task
88
+ class CodeGenerationSignature < DSPy::Signature
89
+ description "Generate Ruby code based on natural language requirements"
90
+
91
+ input do
92
+ const :requirements, String,
93
+ desc: "Natural language description of what the code should do"
94
+
95
+ const :constraints, String,
96
+ desc: "Any specific requirements or constraints (e.g., libraries to use, style preferences)"
97
+ end
98
+
99
+ output do
100
+ const :code, String,
101
+ desc: "Complete, working Ruby code that fulfills the requirements"
102
+
103
+ const :explanation, String,
104
+ desc: "Brief explanation of how the code works and any important design decisions"
105
+
106
+ const :dependencies, T::Array[String],
107
+ desc: "List of required gems or dependencies"
108
+ end
109
+ end
110
+
111
+ # Usage Examples:
112
+ #
113
+ # Basic usage with Predict:
114
+ # predictor = DSPy::Predict.new(ExampleSignature)
115
+ # result = predictor.forward(
116
+ # field_name: "example value",
117
+ # count: 5,
118
+ # score: 0.85,
119
+ # is_active: true,
120
+ # tags: ["tag1", "tag2"],
121
+ # priority: "High"
122
+ # )
123
+ # puts result[:result]
124
+ # puts result[:category]
125
+ # puts result[:confidence]
126
+ #
127
+ # With Chain of Thought reasoning:
128
+ # predictor = DSPy::ChainOfThought.new(SentimentAnalysisSignature)
129
+ # result = predictor.forward(
130
+ # text: "I absolutely love this product! It exceeded all my expectations.",
131
+ # context: "Product review on e-commerce site"
132
+ # )
133
+ # puts result[:reasoning] # See the LLM's step-by-step thinking
134
+ # puts result[:sentiment]
135
+ # puts result[:emotions]
136
+ #
137
+ # With Vision:
138
+ # predictor = DSPy::Predict.new(VisionExampleSignature)
139
+ # result = predictor.forward(
140
+ # image: DSPy::Image.from_file("path/to/image.jpg"),
141
+ # question: "What objects are visible in this image?"
142
+ # )
143
+ # puts result[:answer]
@@ -0,0 +1,265 @@
1
+ # DSPy.rb Core Concepts
2
+
3
+ ## Philosophy
4
+
5
+ DSPy.rb enables developers to **program LLMs, not prompt them**. Instead of manually crafting prompts, define application requirements through code using type-safe, composable modules.
6
+
7
+ ## Signatures
8
+
9
+ Signatures define type-safe input/output contracts for LLM operations. They specify what data goes in and what data comes out, with runtime type checking.
10
+
11
+ ### Basic Signature Structure
12
+
13
+ ```ruby
14
+ class TaskSignature < DSPy::Signature
15
+ description "Brief description of what this signature does"
16
+
17
+ input do
18
+ const :field_name, String, desc: "Description of this input field"
19
+ const :another_field, Integer, desc: "Another input field"
20
+ end
21
+
22
+ output do
23
+ const :result_field, String, desc: "Description of the output"
24
+ const :confidence, Float, desc: "Confidence score (0.0-1.0)"
25
+ end
26
+ end
27
+ ```
28
+
29
+ ### Type Safety
30
+
31
+ Signatures support Sorbet types including:
32
+ - `String` - Text data
33
+ - `Integer`, `Float` - Numeric data
34
+ - `T::Boolean` - Boolean values
35
+ - `T::Array[Type]` - Arrays of specific types
36
+ - Custom enums and classes
37
+
38
+ ### Field Descriptions
39
+
40
+ Always provide clear field descriptions using the `desc:` parameter. These descriptions:
41
+ - Guide the LLM on expected input/output format
42
+ - Serve as documentation for developers
43
+ - Improve prediction accuracy
44
+
45
+ ## Modules
46
+
47
+ Modules are composable building blocks that use signatures to perform LLM operations. They can be chained together to create complex workflows.
48
+
49
+ ### Basic Module Structure
50
+
51
+ ```ruby
52
+ class MyModule < DSPy::Module
53
+ def initialize
54
+ super
55
+ @predictor = DSPy::Predict.new(MySignature)
56
+ end
57
+
58
+ def forward(input_hash)
59
+ @predictor.forward(input_hash)
60
+ end
61
+ end
62
+ ```
63
+
64
+ ### Module Composition
65
+
66
+ Modules can call other modules to create pipelines:
67
+
68
+ ```ruby
69
+ class ComplexWorkflow < DSPy::Module
70
+ def initialize
71
+ super
72
+ @step1 = FirstModule.new
73
+ @step2 = SecondModule.new
74
+ end
75
+
76
+ def forward(input)
77
+ result1 = @step1.forward(input)
78
+ result2 = @step2.forward(result1)
79
+ result2
80
+ end
81
+ end
82
+ ```
83
+
84
+ ## Predictors
85
+
86
+ Predictors are the core execution engines that take signatures and perform LLM inference. DSPy.rb provides several predictor types.
87
+
88
+ ### Predict
89
+
90
+ Basic LLM inference with type-safe inputs and outputs.
91
+
92
+ ```ruby
93
+ predictor = DSPy::Predict.new(TaskSignature)
94
+ result = predictor.forward(field_name: "value", another_field: 42)
95
+ # Returns: { result_field: "...", confidence: 0.85 }
96
+ ```
97
+
98
+ ### ChainOfThought
99
+
100
+ Automatically adds a reasoning field to the output, improving accuracy for complex tasks.
101
+
102
+ ```ruby
103
+ class EmailClassificationSignature < DSPy::Signature
104
+ description "Classify customer support emails"
105
+
106
+ input do
107
+ const :email_subject, String
108
+ const :email_body, String
109
+ end
110
+
111
+ output do
112
+ const :category, String # "Technical", "Billing", or "General"
113
+ const :priority, String # "High", "Medium", or "Low"
114
+ end
115
+ end
116
+
117
+ predictor = DSPy::ChainOfThought.new(EmailClassificationSignature)
118
+ result = predictor.forward(
119
+ email_subject: "Can't log in to my account",
120
+ email_body: "I've been trying to access my account for hours..."
121
+ )
122
+ # Returns: {
123
+ # reasoning: "This appears to be a technical issue...",
124
+ # category: "Technical",
125
+ # priority: "High"
126
+ # }
127
+ ```
128
+
129
+ ### ReAct
130
+
131
+ Tool-using agents with iterative reasoning. Enables autonomous problem-solving by allowing the LLM to use external tools.
132
+
133
+ ```ruby
134
+ class SearchTool < DSPy::Tool
135
+ def call(query:)
136
+ # Perform search and return results
137
+ { results: search_database(query) }
138
+ end
139
+ end
140
+
141
+ predictor = DSPy::ReAct.new(
142
+ TaskSignature,
143
+ tools: [SearchTool.new],
144
+ max_iterations: 5
145
+ )
146
+ ```
147
+
148
+ ### CodeAct
149
+
150
+ Dynamic code generation for solving problems programmatically. Requires the optional `dspy-code_act` gem.
151
+
152
+ ```ruby
153
+ predictor = DSPy::CodeAct.new(TaskSignature)
154
+ result = predictor.forward(task: "Calculate the factorial of 5")
155
+ # The LLM generates and executes Ruby code to solve the task
156
+ ```
157
+
158
+ ## Multimodal Support
159
+
160
+ DSPy.rb supports vision capabilities across compatible models using the unified `DSPy::Image` interface.
161
+
162
+ ```ruby
163
+ class VisionSignature < DSPy::Signature
164
+ description "Describe what's in an image"
165
+
166
+ input do
167
+ const :image, DSPy::Image
168
+ const :question, String
169
+ end
170
+
171
+ output do
172
+ const :description, String
173
+ end
174
+ end
175
+
176
+ predictor = DSPy::Predict.new(VisionSignature)
177
+ result = predictor.forward(
178
+ image: DSPy::Image.from_file("path/to/image.jpg"),
179
+ question: "What objects are visible in this image?"
180
+ )
181
+ ```
182
+
183
+ ### Image Input Methods
184
+
185
+ ```ruby
186
+ # From file path
187
+ DSPy::Image.from_file("path/to/image.jpg")
188
+
189
+ # From URL (OpenAI only)
190
+ DSPy::Image.from_url("https://example.com/image.jpg")
191
+
192
+ # From base64-encoded data
193
+ DSPy::Image.from_base64(base64_string, mime_type: "image/jpeg")
194
+ ```
195
+
196
+ ## Best Practices
197
+
198
+ ### 1. Clear Signature Descriptions
199
+
200
+ Always provide clear, specific descriptions for signatures and fields:
201
+
202
+ ```ruby
203
+ # Good
204
+ description "Classify customer support emails into Technical, Billing, or General categories"
205
+
206
+ # Avoid
207
+ description "Classify emails"
208
+ ```
209
+
210
+ ### 2. Type Safety
211
+
212
+ Use specific types rather than generic String when possible:
213
+
214
+ ```ruby
215
+ # Good - Use enums for constrained outputs
216
+ output do
217
+ const :category, T.enum(["Technical", "Billing", "General"])
218
+ end
219
+
220
+ # Less ideal - Generic string
221
+ output do
222
+ const :category, String, desc: "Must be Technical, Billing, or General"
223
+ end
224
+ ```
225
+
226
+ ### 3. Composable Architecture
227
+
228
+ Build complex workflows from simple, reusable modules:
229
+
230
+ ```ruby
231
+ class EmailPipeline < DSPy::Module
232
+ def initialize
233
+ super
234
+ @classifier = EmailClassifier.new
235
+ @prioritizer = EmailPrioritizer.new
236
+ @responder = EmailResponder.new
237
+ end
238
+
239
+ def forward(email)
240
+ classification = @classifier.forward(email)
241
+ priority = @prioritizer.forward(classification)
242
+ @responder.forward(classification.merge(priority))
243
+ end
244
+ end
245
+ ```
246
+
247
+ ### 4. Error Handling
248
+
249
+ Always handle potential type validation errors:
250
+
251
+ ```ruby
252
+ begin
253
+ result = predictor.forward(input_data)
254
+ rescue DSPy::ValidationError => e
255
+ # Handle validation error
256
+ logger.error "Invalid output from LLM: #{e.message}"
257
+ end
258
+ ```
259
+
260
+ ## Limitations
261
+
262
+ Current constraints to be aware of:
263
+ - No streaming support (single-request processing only)
264
+ - Limited multimodal support through Ollama for local deployments
265
+ - Vision capabilities vary by provider (see providers.md for compatibility matrix)