stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
13.82k stars 1.06k forks source link

Unwanted STDOUT output when using Claude adapter in DSPy #1195

Closed zirkonit closed 4 days ago

zirkonit commented 1 week ago

Hi! After switching to the dsp.Claude adapter in DSPy, I've noticed an undesirable behavior: the full configuration of every request, including the entire prompt, is being sent to stdout without my explicit request. This doesn't occur when using OpenAI adapters.

Here's a minimal example to demonstrate the issue:

import dspy
from dotenv import load_dotenv
from dspy.evaluate.evaluate import Evaluate
from dsp import Claude

load_dotenv("./env/api_keys.env")
model = Claude(model="claude-3-5-sonnet-20240620", max_tokens=4096)
dspy.settings.configure(lm=model)

class GenerateAnswer(dspy.Signature):
    """Please greet the user."""

    answer = dspy.OutputField(desc="The greeting.")

answer = dspy.Predict(GenerateAnswer)()

The output:

% python minimal-example.py
{'temperature': 0.0, 'max_tokens': 4096, 'top_p': 1.0, 'top_k': 1, 'model': 'claude-3-5-sonnet-20240620', 'messages': [{'role': 'user', 'content': 'Please greet the user.\n\n---\n\nFollow the following format.\n\nAnswer: The greeting.\n\n---\n\nAnswer:'}]}

This output is very disruptive, cluttering my evaluation runs. I haven't been able to find a way to configure or disable this behavior. Is there a way to suppress this unwanted stdout output?

I'm using DSPy version 2.4.5

arnavsinghvi11 commented 5 days ago

Hi @zirkonit , I believe this earlier version of DSPy didn't have logging auto-suppressed. I would recommend upgrading to the latest DSPy version 2.4.10 or adding some logging suppression statements to avoid seeing the prompt api input each time.

okhat commented 4 days ago

yup new versions are better