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

Structured Output Support for Chat Deepseek #29494

Conversation

keenborder786
Copy link
Contributor

@keenborder786 keenborder786 commented Jan 30, 2025

I have added support for structured output for ChatDeepSeek as per their official documentation: https://api-docs.deepseek.com/guides/json_mode

Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2025 11:16am

@keenborder786 keenborder786 changed the title Structure Output Support for Chat Deepseek Structured Output Support for Chat Deepseek Jan 30, 2025
@keenborder786 keenborder786 marked this pull request as ready for review January 31, 2025 00:47
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 31, 2025
@keenborder786
Copy link
Contributor Author

@ccurme

Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

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

ChatDeepSeek should already support structured output since it inherits from BaseChatOpenAI.

from langchain_deepseek import ChatDeepSeek
from pydantic import BaseModel, Field

class Joke(BaseModel):
    """Joke to tell user."""

    setup: str = Field(description="question to set up a joke")
    punchline: str = Field(description="answer to resolve the joke")

llm = ChatDeepSeek(model="deepseek-chat").with_structured_output(Joke)
result = llm.invoke("Tell me a joke about cats.")

@ccurme ccurme closed this Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants