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