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.1.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.1.tar.gz.

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f8d3f7db70e790eaa14e94be4318c5b9a8a498e890251062e5d9d4888ef09251
MD5 af994b0421f72556cd5a2dd6d092b324
BLAKE2b-256 b7f7f266ed76cb1797afc24b54b9bb6cb512ba97fc1c9863367554b5332bd102

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for langchain_openai_thinking_agui-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b86074b1f1e1dbdd1ab348948d4d59888ff83826cc15c023f14289f2c261a0a
MD5 71d4d8d121a86a93703a6728d5f5de15
BLAKE2b-256 5bb7f0fbb841d93a24df72990c9e588444c8162ffb4da09488a5ccb4185ebfa5

See more details on using hashes here.

Provenance

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