Skip to content

System Prompt Does Not Utilize dspy.Signature Docstring (__doc__) #1836

@yanmxa

Description

@yanmxa

The dspy.Signature class docstring (doc) is not dynamically parsed or integrated into the system prompt.

Steps to Reproduce:

  1. Define a dspy.Signature subclass with a detailed docstring, e.g.,:
class KubeEngineer(dspy.Signature):
    """
    You are a Kubernetes engineer. Your task is to solve the given issue or perform the actions to interact with the Kubernetes cluster. 
    Use tools or kubectl commands to achieve the desired outcomes.
    
    Try to identify the following variables from the provided task or issue:
    - Cluster name
    - Resource type (e.g., Pod, Service, Deployment)
    - Resource name
    - Namespace
    """

    task: str = dspy.InputField(
        desc="The task or issue to address within the Kubernetes cluster."
    )
    answer: str = dspy.OutputField(
        desc="The final solution or output for the given task."
    )
  1. Run the following code:
lm = dspy.LM(
    model="llama-3.1-70b-versatile",
    api_base="https://api.groq.com/openai/v1",
    api_key=os.getenv("GROQ_API_KEY"),
)
with dspy.context(lm=lm):
    react = dspy.ReAct(KubeEngineer, tools=[kube_executor_with_configs.kubectl_cmd])
    result = react(
        task="***"
    )
print(lm.history)
  1. The system prompt in the output
{
  "prompt": None,
  "messages": [
    {
      "role": "system",
      "content": "Your input fields are:\n1. `task` (str): The task or issue to address within the Kubernetes cluster.\n2. `trajectory` (str)\n\nYour output fields are:\n1. `reasoning` (str)\n2. `answer` (str): The final solution or output for the given task.\n\nAll interactions will be structured in the following way, with the appropriate values filled in.\n\n[[ ## task ## ]]\n{task}\n\n[[ ## trajectory ## ]]\n{trajectory}\n\n[[ ## reasoning ## ]]\n{reasoning}\n\n[[ ## answer ## ]]\n{answer}\n\n[[ ## completed ## ]]\n\nIn adhering to this structure, your objective is: \n        Given the fields `task`, produce the fields `answer`."
    },
    {
      "role": "user",
      "content": "...."
    }
  ]
}

Current Behavior:

The system prompt does not include the docstring from the KubeEngineer class.

Expected Output:

image
{
  "prompt": None,
  "messages": [
    {
      "role": "system",
      "content": "You are a Kubernetes engineer. Your task is to solve the given issue or perform the actions to interact with the Kubernetes cluster. Use tools or kubectl commands to achieve the desired outcomes.\n\nTry to identify the following variables from the provided task or issue:\n- Cluster name\n- Resource type (e.g., Pod, Service, Deployment)\n- Resource name\n- Namespace ..."
    },
    {"role": "user", "content": "...."}
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions