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.2.tar.gz (3.5 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.2.tar.gz.

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a788317fcd3ef184d31726eb3bfe3f0f6c7b8e0653ba03b4bff519fa102fa276
MD5 951633d705c0a3e7b7c6b800e4050893
BLAKE2b-256 d12a18e795499ba357b05602329007b93f912af4dad75b3717e3e172e412593a

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_openai_thinking_agui-0.2.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d744fcb01b7cff439c2599ba03cfb16cd75556fe7da787e2ef4fff5f5b41542
MD5 7187331db7239b27a63a75922f5d6104
BLAKE2b-256 f49856421d5307eaa9b35f98f58f955ae0ed4425a8af52db4740011113ed3784

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_openai_thinking_agui-0.2.2-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