49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
from claude_dspy import ClaudeCode, ClaudeCodeConfig
|
|
from pydantic import BaseModel, Field
|
|
from typing import Literal
|
|
from modaic import AutoProgram
|
|
import dspy
|
|
|
|
class AffectedFile(BaseModel):
|
|
file_name: str = Field(..., description="Name of the file")
|
|
action: Literal["created", "updated", "deleted", "renamed"] = Field(..., description="Action taken on the file")
|
|
|
|
|
|
class OutputResult(BaseModel):
|
|
success: bool = Field(..., description="Whether or not execution of the query was successful")
|
|
message: str = Field(..., description="Message")
|
|
affected_files: list[AffectedFile] = Field(..., description="List of files affected by the query")
|
|
|
|
|
|
class ClaudeCodeSignature(dspy.Signature):
|
|
query: str = dspy.InputField(desc="Query to process")
|
|
output: OutputResult = dspy.OutputField(desc="Result of the query")
|
|
|
|
|
|
def main():
|
|
# create config
|
|
config = ClaudeCodeConfig()
|
|
|
|
# create agent
|
|
cc = ClaudeCode(
|
|
config,
|
|
signature=ClaudeCodeSignature,
|
|
working_directory=".",
|
|
permission_mode="acceptEdits",
|
|
allowed_tools=["Read", "Write", "Bash"],
|
|
)
|
|
"""
|
|
result = cc(query="list the files in this directory")
|
|
output = result.output
|
|
print(output)
|
|
"""
|
|
cc.push_to_hub(
|
|
"modaic/claude-code",
|
|
with_code=True,
|
|
commit_message="move connect debug prints",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|