Skip to main content

LangChain chat model wrappers that expose reasoning/thinking content in ag-ui-langgraph compatible format

Project description

langchain-openai-thinking-agui

为 LangChain 的 Chat 模型补充思考内容(reasoning/thinking)提取能力,输出格式与 ag-ui-langgraph 兼容。

支持所有 OpenAI 兼容接口的思考模型,包括 DeepSeek、Kimi 等。

安装

pip install langchain-openai-thinking-agui

使用

from langchain_openai_thinking_agui import ChatOpenAIWithThinking

model = ChatOpenAIWithThinking(
    model="deepseek-reasoner",
    base_url="https://api.deepseek.com/v1",
    api_key="your-api-key",
)

res = model.invoke("解释一下天空是蓝色的")
# res.content[0]["thinking"] 是思考内容
# res.content[1]["text"]    是正式回答

输出格式

思考内容以 Anthropic content blocks 格式存放在 AIMessage.content 中,ag-ui-langgraph 可自动识别并触发 THINKING_* 事件流:

[
    {"type": "text", "thinking": "<思考过程>", "index": 0},
    {"type": "text", "text": "<正式回答>"},
]

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_openai_thinking_agui-0.2.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file langchain_openai_thinking_agui-0.2.0.tar.gz.

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6755d6291f3f82014b493413c28c379b6f4b79adc04924a5f44c912e89dec0f1
MD5 e70712c1d0242bff550aff81978b1968
BLAKE2b-256 8796ed02b04c77f83c558370418f1c3cfcf8a2f4303e833dd7e7d954b9ae938c

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_openai_thinking_agui-0.2.0.tar.gz:

Publisher: publish.yml on ryanqduan/langchain-openai-thinking-agui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_openai_thinking_agui-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46a315a6dabe531b3e8349716e30478fab8eefe9ffa188e4757def9789ef243e
MD5 b01f0a8fced20266b36aed04842db89d
BLAKE2b-256 9a2d21b2f81be5277150586928a1f15bda3e0cd3f6681a42e17722e35a55ac9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_openai_thinking_agui-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ryanqduan/langchain-openai-thinking-agui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page