Add more functionality to signature description parsing

This commit is contained in:
2025-12-06 01:51:24 -05:00
parent 65d832fd0e
commit 443184c1b3

View File

@@ -75,21 +75,17 @@ print(result.usage) # Token usage
```python
from modaic import AutoProgram
from claude_dspy import ClaudeCodeConfig
import dspy
class MySignature(dspy.Signature):
message: str = dspy.InputField(desc="Request to process")
answer: str = dspy.OutputField(desc="Response")
# Create config with custom model
config = ClaudeCodeConfig(model="claude-opus-4-5-20251101")
# Load with custom configuration
# Model comes from config, other params are kwargs
agent = AutoProgram.from_precompiled(
"farouk1/claude-code",
config=config,
config={"model": "claude-opus-4-5-20251101"},
signature=MySignature,
working_directory=".",
permission_mode="acceptEdits",
@@ -99,24 +95,24 @@ agent = AutoProgram.from_precompiled(
## Local Development
For local development and creating your own agents:
For local development and hacking on this project:
### Basic String Output
```python
from claude_dspy import ClaudeCode, ClaudeCodeConfig
# Create config
# create config
config = ClaudeCodeConfig()
# Create agent
# create agent
agent = ClaudeCode(
config,
signature="message:str -> answer:str",
working_directory="."
)
# Use it
# use it
result = agent(message="What files are in this directory?")
print(result.answer) # String response
print(result.trace) # Execution items
@@ -168,7 +164,7 @@ result = agent(message="Test my agent")
print(result.answer)
# Push to Modaic Hub
agent.push_to_hub("your-username/your-agent-name")
agent.push_to_hub("{USERNAME}/your-agent-name")
```
## API Reference
@@ -200,14 +196,7 @@ class ClaudeCode(PrecompiledProgram):
def __init__(
self,
config: ClaudeCodeConfig,
signature: str | type[Signature], # Required
working_directory: str = ".", # Default: "."
permission_mode: str | None = None, # Optional
allowed_tools: list[str] | None = None, # Optional
disallowed_tools: list[str] | None = None, # Optional
sandbox: dict[str, Any] | None = None, # Optional
system_prompt: str | dict | None = None, # Optional
api_key: str | None = None, # Optional (uses env var)
**kwargs,
)
```
@@ -933,7 +922,7 @@ Your signature has too many or too few fields. ClaudeCode expects exactly one in
# L Wrong - multiple inputs
sig = dspy.Signature('context:str, question:str -> answer:str')
#  Correct - single input
# Correct - single input
sig = dspy.Signature('message:str -> answer:str')
```