Add more functionality to signature description parsing
This commit is contained in:
46
main.py
Normal file
46
main.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from claude_dspy import ClaudeCode, ClaudeCodeConfig
|
||||
from pydantic import BaseModel
|
||||
import dspy
|
||||
|
||||
|
||||
class Output(BaseModel):
|
||||
files: list[str]
|
||||
|
||||
|
||||
class ClaudeCodeSignature(dspy.Signature):
|
||||
message: str = dspy.InputField(desc="Request to process")
|
||||
output: list[str] = dspy.OutputField(desc="List of files modified or created")
|
||||
|
||||
|
||||
def main():
|
||||
# create config
|
||||
config = ClaudeCodeConfig()
|
||||
|
||||
# create agent
|
||||
cc = ClaudeCode(
|
||||
config,
|
||||
signature=ClaudeCodeSignature,
|
||||
working_directory=".",
|
||||
permission_mode="acceptEdits",
|
||||
allowed_tools=["Read", "Glob", "Write"],
|
||||
)
|
||||
|
||||
# use it
|
||||
print("Running ClaudeCode...")
|
||||
result = cc(
|
||||
message="Create a new file called helloworld.txt with the alphabet backwards"
|
||||
)
|
||||
|
||||
print(f"Success: {result.output}")
|
||||
print(result.usage)
|
||||
|
||||
print(f"Session ID: {cc.session_id}")
|
||||
cc.push_to_hub(
|
||||
"farouk1/claude-code",
|
||||
with_code=True,
|
||||
commit_message="Add more functionality to signature description parsing",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user