Skip to content

Conversation

@azai91
Copy link
Contributor

@azai91 azai91 commented Nov 18, 2025

This PR adds a Google-style docstring for ChatAdapter class and constructor
in dspy/adapters/chat_adapter.py.

Behavior verified in IPython (returns a NEW Signature class with same fields and new instructions).
No logic changes.

Help on function __init__ in module dspy.adapters.chat_adapter:

__init__(self, callbacks=None, use_native_function_calling: bool = False, native_response_types=None, use_json_adapter_fallback: bool = True)
    Args:
        callbacks: List of callback functions to execute during `format()` and `parse()` methods. Callbacks can be
            used for logging, monitoring, or custom processing. Defaults to None (empty list).
        use_native_function_calling: Whether to enable native function calling capabilities when the LM supports it.
            If True, the adapter will automatically configure function calling when input fields contain `dspy.Tool`
            or `list[dspy.Tool]` types. Defaults to False.
        native_response_types: List of output field types that should be handled by native LM features rather than
            adapter parsing. For example, `dspy.Citations` can be populated directly by citation APIs
            (e.g., Anthropic's citation feature). Defaults to `[Citations]`.
        use_json_adapter_fallback: Whether to automatically fallback to JSONAdapter if the ChatAdapter fails.
            If True, when an error occurs (except ContextWindowExceededError), the adapter will retry using
            JSONAdapter. Defaults to True.

Refs: #9063

@azai91
Copy link
Contributor Author

azai91 commented Nov 18, 2025

@chenmoneygithub can you review this PR when you get the chance?

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@onel
Copy link

onel commented Nov 21, 2025

I was also thinking of helping with chat adapter and happy to see work has started.

@chenmoneygithub I think this is a super important module and the docs should include an example, what do you think?
I also think the other methods on the class should be documented as well.
I can help with that if needed

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that the doc patching doesn't work well with mkdocs. Pushed a commit to just copy over the args.

Thanks again for the PR!

@chenmoneygithub chenmoneygithub merged commit 02b148e into stanfordnlp:main Nov 22, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants