45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from claude_dspy import ClaudeCode, ClaudeCodeConfig
|
|
from pydantic import BaseModel, Field
|
|
from modaic import AutoProgram
|
|
import dspy
|
|
|
|
|
|
class ErrorReport(BaseModel):
|
|
error: str = Field(..., description="Error message")
|
|
timestamp: str = Field(..., description="Timestamp of error")
|
|
line_located: int | None = Field(
|
|
..., description="Line number where error occurred"
|
|
)
|
|
file_located: str | None = Field(..., description="File where error occurred")
|
|
description: str = Field(..., description="Description of errors")
|
|
reccomedated_fixes: list[str] = Field(..., description="List of recommended fixes")
|
|
|
|
|
|
class ClaudeCodeSignature(dspy.Signature):
|
|
log_file: str = dspy.InputField(desc="Log file to process")
|
|
output: list[ErrorReport] = dspy.OutputField(desc="list of error reports created")
|
|
|
|
|
|
def main():
|
|
# create config
|
|
config = ClaudeCodeConfig()
|
|
|
|
# create agent
|
|
cc = ClaudeCode(
|
|
config,
|
|
signature=ClaudeCodeSignature,
|
|
working_directory=".",
|
|
permission_mode="acceptEdits",
|
|
allowed_tools=["Read", "Write", "Bash"],
|
|
)
|
|
|
|
cc.push_to_hub(
|
|
"farouk1/claude-code",
|
|
with_code=True,
|
|
commit_message="Use structured outputs with Pydantic models instead of text parsing",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|