Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize ChatModel docstrings and integration docs #22296

Open
baskaryan opened this issue May 29, 2024 · 2 comments
Open

Standardize ChatModel docstrings and integration docs #22296

baskaryan opened this issue May 29, 2024 · 2 comments
Labels
🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder documentation Improvements or additions to documentation help wanted Good issue for contributors integration-docs

Comments

@baskaryan
Copy link
Collaborator

baskaryan commented May 29, 2024

Issue

To make our chat model integrations as easy to use as possible we need to make sure the docs for them are thorough and standardized. There are two parts to this: updating the chat model docstrings and updating the actual integration docs.

This needs to be done for each ChatModel integration, ideally with one PR per ChatModel.

Related to broader issues #21983 and #22005.

Docstrings

Each ChatModel class docstring should have the sections shown in the Appendix below. The sections should have input and output code blocks when relevant. See ChatOpenAI docstrings and corresponding API reference for an example.

To build a preview of the API docs for the package you're working on run (from root of repo):

make api_docs_clean; make api_docs_quick_preview API_PKG=openai

where API_PKG= should be the parent directory that houses the edited package (e.g. community, openai, anthropic, huggingface, together, mistralai, groq, fireworks, etc.). This should be quite fast for all the partner packages.

Doc pages

Each ChatModel docs page should follow this template. See ChatOpenAI for an example.

You can use the langchain-cli to quickly get started with a new chat model integration docs page (run from root of repo):

poetry run pip install -e libs/cli
poetry run langchain-cli integration create-doc --name "foo-bar" --name-class FooBar --destination-dir ./docs/docs/integrations/chat/

where --name is the integration package name without the "langchain-" prefix and --name-class is the class name without the "Chat" prefix. This will create a template doc with some autopopulated fields at docs/docs/integrations/chat/foo_bar.ipynb.

To build a preview of the docs you can run (from root):

make docs_clean
make docs_build
cd docs/build/output-new
yarn
yarn start

Appendix

Expected sections for the ChatModel class docstring.

    """__ModuleName__ chat model integration.

    Setup:
      ...

    Key init args — completion params:
      ...

    Key init args — client params:
      ...
    
    See full list of supported init args and their descriptions in the params section.

    Instantiate:
      ...

    Invoke:
      ...

    # Delete if token-level streaming not supported.
    Stream:
      ...

    # TODO: Delete if native async isn't supported.
    Async:
      ...

    # TODO: Delete if .bind_tools() isn't supported.
    Tool calling:
      ...

      See ``Chat__ModuleName__.bind_tools()`` method for more.

    # TODO: Delete if .with_structured_output() isn't supported.
    Structured output:
      ...

      See ``Chat__ModuleName__.with_structured_output()`` for more.

    # TODO: Delete if JSON mode response format isn't supported.
    JSON mode:
      ...

    # TODO: Delete if image inputs aren't supported.
    Image input:
      ...

    # TODO: Delete if audio inputs aren't supported.
    Audio input:
      ...

    # TODO: Delete if video inputs aren't supported.
    Video input:
      ...

    # TODO: Delete if token usage metadata isn't supported.
    Token usage:
      ...

    # TODO: Delete if logprobs aren't supported.
    Logprobs:
      ...

    Response metadata
      ...

    """  # noqa: E501
@baskaryan baskaryan added documentation Improvements or additions to documentation help wanted Good issue for contributors labels May 29, 2024
@baskaryan baskaryan pinned this issue May 29, 2024
@dosubot dosubot bot added 🔌: openai Primarily related to OpenAI integrations 🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder labels May 29, 2024
@baskaryan baskaryan removed the 🔌: openai Primarily related to OpenAI integrations label May 29, 2024
@chaityacshah
Copy link

hi @baskaryan, i'm interested in this. where would I find more info for the fields in Doc pages that aren't autopopulated?

@anilkumarKanasani
Copy link

Hi @chaityacshah, I am interested to contribute to this issue. I am doing open source contribution for the first time. Can we both together take up this task ?

baskaryan added a commit that referenced this issue Jun 4, 2024
Related to #22296

And update anthropic to accept base_url
baskaryan added a commit that referenced this issue Jun 10, 2024
**Updated ChatHuggingFace doc string as per issue #22296**:
"langchain_huggingface: updated docstring for ChatHuggingFace in
langchain_huggingface to match that of the description (in the appendix)
provided in issue #22296. "

**Issue:** This PR is in response to issue #22296, and more specifically
ChatHuggingFace model. In particular, this PR updates the docstring for
langchain/libs/partners/hugging_face/langchain_huggingface/chat_models/huggingface.py
by adding the following sections: Instantiate, Invoke, Stream, Async,
Tool calling, and Response metadata. I used the template from the
Anthropic implementation and referenced the Appendix of the original
issue post. I also noted that: langchain_community hugging face llms do
not work with langchain_huggingface's ChatHuggingFace model (at least
for me); the .stream(messages) functionality of ChatHuggingFace only
returned a block of response.

---------

Co-authored-by: lucast2021 <[email protected]>
Co-authored-by: Bagatur <[email protected]>
baskaryan added a commit that referenced this issue Jun 14, 2024
Updated ChatGroq doc string as per issue
https://github.com/langchain-ai/langchain/issues/22296:"langchain_groq:
updated docstring for ChatGroq in langchain_groq to match that of the
description (in the appendix) provided in issue
#22296. "

Issue: This PR is in response to issue
#22296, and more
specifically the ChatGroq model. In particular, this PR updates the
docstring for langchain/libs/partners/groq/langchain_groq/chat_model.py
by adding the following sections: Instantiate, Invoke, Stream, Async,
Tool calling, Structured Output, and Response metadata. I used the
template from the Anthropic implementation and referenced the Appendix
of the original issue post. I also noted that: `usage_metadata `returns
none for all ChatGroq models I tested; there is no mention of image
input in the ChatGroq documentation; unlike that of ChatHuggingFace,
`.stream(messages)` for ChatGroq returned blocks of output.

---------

Co-authored-by: lucast2021 <[email protected]>
Co-authored-by: Bagatur <[email protected]>
ccurme pushed a commit that referenced this issue Jun 15, 2024
- **Description:** Update ZhipuAI ChatModel rich docstring
- **Issue:** the issue #22296
hinthornw pushed a commit that referenced this issue Jun 20, 2024
Related to #22296

And update anthropic to accept base_url
hinthornw pushed a commit that referenced this issue Jun 20, 2024
**Updated ChatHuggingFace doc string as per issue #22296**:
"langchain_huggingface: updated docstring for ChatHuggingFace in
langchain_huggingface to match that of the description (in the appendix)
provided in issue #22296. "

**Issue:** This PR is in response to issue #22296, and more specifically
ChatHuggingFace model. In particular, this PR updates the docstring for
langchain/libs/partners/hugging_face/langchain_huggingface/chat_models/huggingface.py
by adding the following sections: Instantiate, Invoke, Stream, Async,
Tool calling, and Response metadata. I used the template from the
Anthropic implementation and referenced the Appendix of the original
issue post. I also noted that: langchain_community hugging face llms do
not work with langchain_huggingface's ChatHuggingFace model (at least
for me); the .stream(messages) functionality of ChatHuggingFace only
returned a block of response.

---------

Co-authored-by: lucast2021 <[email protected]>
Co-authored-by: Bagatur <[email protected]>
hinthornw pushed a commit that referenced this issue Jun 20, 2024
Updated ChatGroq doc string as per issue
https://github.com/langchain-ai/langchain/issues/22296:"langchain_groq:
updated docstring for ChatGroq in langchain_groq to match that of the
description (in the appendix) provided in issue
#22296. "

Issue: This PR is in response to issue
#22296, and more
specifically the ChatGroq model. In particular, this PR updates the
docstring for langchain/libs/partners/groq/langchain_groq/chat_model.py
by adding the following sections: Instantiate, Invoke, Stream, Async,
Tool calling, Structured Output, and Response metadata. I used the
template from the Anthropic implementation and referenced the Appendix
of the original issue post. I also noted that: `usage_metadata `returns
none for all ChatGroq models I tested; there is no mention of image
input in the ChatGroq documentation; unlike that of ChatHuggingFace,
`.stream(messages)` for ChatGroq returned blocks of output.

---------

Co-authored-by: lucast2021 <[email protected]>
Co-authored-by: Bagatur <[email protected]>
hinthornw pushed a commit that referenced this issue Jun 20, 2024
- **Description:** Update ZhipuAI ChatModel rich docstring
- **Issue:** the issue #22296
ccurme pushed a commit that referenced this issue Jun 24, 2024
- **Description:** Update QianfanChatEndpoint ChatModel rich docstring
- **Issue:** the issue #22296
Josephasafg pushed a commit to joshc-ai21/langchain that referenced this issue Jun 25, 2024
)

- **Description:** Update QianfanChatEndpoint ChatModel rich docstring
- **Issue:** the issue langchain-ai#22296
baskaryan added a commit that referenced this issue Jul 1, 2024
baskaryan added a commit that referenced this issue Jul 2, 2024
baskaryan added a commit that referenced this issue Jul 2, 2024
mandos21 pushed a commit to mandos21/langchain that referenced this issue Jul 8, 2024
)

- **Description:** Update QianfanChatEndpoint ChatModel rich docstring
- **Issue:** the issue langchain-ai#22296
eyurtsev pushed a commit that referenced this issue Jul 11, 2024
- **Description:** Add MiniMaxChat rich docstrings.
- **Issue:** the issue #22296
ccurme pushed a commit that referenced this issue Jul 17, 2024
- **Description:** Add ChatBaichuan rich docstrings.
- **Issue:** the issue #22296
baskaryan pushed a commit that referenced this issue Jul 20, 2024
- **Description:** 
  - Add `ChatSparkLLM` docstrings, the issue #22296 
  - To support `stream` method
isahers1 added a commit that referenced this issue Jul 25, 2024
Part of #22296

---------

Co-authored-by: isaac hershenson <[email protected]>
isahers1 added a commit that referenced this issue Jul 25, 2024
part of #22296

---------

Co-authored-by: isaac hershenson <[email protected]>
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
- **Description:** 
  - Add `ChatSparkLLM` docstrings, the issue langchain-ai#22296 
  - To support `stream` method
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
olgamurraft pushed a commit to olgamurraft/langchain that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder documentation Improvements or additions to documentation help wanted Good issue for contributors integration-docs
Projects
None yet
Development

No branches or pull requests

4 participants