move connect debug prints
This commit is contained in:
@@ -312,37 +312,54 @@ class ClaudeCode(PrecompiledProgram):
|
|||||||
"""
|
"""
|
||||||
prompt_parts = []
|
prompt_parts = []
|
||||||
|
|
||||||
# add signature docstring if present
|
# add signature docstring if present (skip auto-generated dspy docs)
|
||||||
if self.signature.__doc__:
|
if self.signature.__doc__:
|
||||||
doc = self.signature.__doc__.strip()
|
doc = self.signature.__doc__.strip()
|
||||||
if doc:
|
prompt_parts.append(doc)
|
||||||
prompt_parts.append(f"Task: {doc}")
|
|
||||||
|
|
||||||
# add input field description if present
|
# extract input field info from FieldInfo
|
||||||
# DSPy fields store desc in json_schema_extra
|
|
||||||
input_desc = None
|
input_desc = None
|
||||||
|
input_prefix = None
|
||||||
if (
|
if (
|
||||||
hasattr(self.input_field, "json_schema_extra")
|
hasattr(self.input_field, "json_schema_extra")
|
||||||
and self.input_field.json_schema_extra
|
and self.input_field.json_schema_extra
|
||||||
):
|
):
|
||||||
input_desc = self.input_field.json_schema_extra.get("desc")
|
input_desc = self.input_field.json_schema_extra.get("desc")
|
||||||
|
input_prefix = self.input_field.json_schema_extra.get("prefix")
|
||||||
|
|
||||||
# add the actual input value
|
# format input field with prefix if available, otherwise use field name
|
||||||
prompt_parts.append(f"{self.input_field_name}: {input_value}")
|
if input_prefix:
|
||||||
|
input_label = input_prefix.rstrip(":")
|
||||||
|
else:
|
||||||
|
input_label = f"{self.input_field_name.replace('_', ' ').title()}:"
|
||||||
|
|
||||||
|
# add input with description on same line if available
|
||||||
if input_desc:
|
if input_desc:
|
||||||
prompt_parts.append(f"({input_desc})")
|
prompt_parts.append(f"{input_label}: {input_value}\nDescription: {input_desc}")
|
||||||
|
else:
|
||||||
# add output field description if present
|
prompt_parts.append(f"{input_label}: {input_value}")
|
||||||
|
|
||||||
|
# extract output field info from FieldInfo
|
||||||
output_desc = None
|
output_desc = None
|
||||||
|
output_prefix = None
|
||||||
if (
|
if (
|
||||||
hasattr(self.output_field, "json_schema_extra")
|
hasattr(self.output_field, "json_schema_extra")
|
||||||
and self.output_field.json_schema_extra
|
and self.output_field.json_schema_extra
|
||||||
):
|
):
|
||||||
output_desc = self.output_field.json_schema_extra.get("desc")
|
output_desc = self.output_field.json_schema_extra.get("desc")
|
||||||
|
output_prefix = self.output_field.json_schema_extra.get("prefix")
|
||||||
|
|
||||||
|
# format output field with prefix if available, otherwise use field name
|
||||||
|
if output_prefix:
|
||||||
|
output_label = output_prefix.rstrip(":")
|
||||||
|
else:
|
||||||
|
output_label = f"{self.output_field_name.replace('_', ' ').title()}:"
|
||||||
|
|
||||||
|
# add output field with description
|
||||||
if output_desc:
|
if output_desc:
|
||||||
prompt_parts.append(f"\nPlease produce the following output: {output_desc}")
|
prompt_parts.append(f"{output_label}:\nDescription: {output_desc}")
|
||||||
|
else:
|
||||||
|
prompt_parts.append(f"{output_label}")
|
||||||
|
|
||||||
# the schema is passed through ClaudeAgentOptions and enforced by the SDK
|
# the schema is passed through ClaudeAgentOptions and enforced by the SDK
|
||||||
|
|
||||||
|
|||||||
1
main.py
1
main.py
@@ -16,7 +16,6 @@ class OutputResult(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class ClaudeCodeSignature(dspy.Signature):
|
class ClaudeCodeSignature(dspy.Signature):
|
||||||
"""Signature for Claude Code"""
|
|
||||||
query: str = dspy.InputField(desc="Query to process")
|
query: str = dspy.InputField(desc="Query to process")
|
||||||
output: OutputResult = dspy.OutputField(desc="Result of the query")
|
output: OutputResult = dspy.OutputField(desc="Result of the query")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user