Skip to main content

An integration package connecting QwQ and LangChain

Project description

langchain-qwq魔改,提高兼容性

  1. 为api_base设置别名base_url;
  2. 合并reasoning_content到content;
  3. 添加与标签

langchain-qwq

This package contains the LangChain integration with QwQ

Installation

pip install -U langchain-qwq

And you should configure credentials by setting the following environment variables:

Chat Models

ChatQwQ class exposes chat models from QwQ. The integration works directly with a standard API key without requiring the Tongyi dependency.

from langchain_qwq_modification import ChatQwQ

llm = ChatQwQ()
llm.invoke("Sing a ballad of LangChain.")

Advanced Usage

Streaming

llm = ChatQwQ(model="qwq-plus")
for chunk in llm.stream("Write a short poem about AI"):
    print(chunk.content, end="")

Async Support

llm = ChatQwQ(model="qwq-plus")
response = await llm.ainvoke("What is the capital of France?")
print(response.content)

# Streaming
async for chunk in llm.astream("Tell me about quantum computing"):
    print(chunk.content, end="")

Access to Reasoning Content

response = llm.invoke("Explain how photosynthesis works")
content = response.content
reasoning = response.additional_kwargs.get("reasoning_content", "")

Tool Calls

from langchain_core.tools import tool

@tool
def get_current_weather(location: str, unit: str = "fahrenheit"):
    """Get the current weather in a given location"""
    return f"72 degrees and sunny in {location}"

llm = ChatQwQ(model="qwq-plus")
llm_with_tools = llm.bind_tools([get_current_weather])
response = llm_with_tools.invoke("What's the weather in San Francisco?")

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_qwq_modification-0.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

langchain_qwq_modification-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_qwq_modification-0.0.1.tar.gz.

File metadata

File hashes

Hashes for langchain_qwq_modification-0.0.1.tar.gz
Algorithm Hash digest
SHA256 84cf53a00b4afb5cbd159474d0913006590b9e1df1ca9150523671217ef5da7a
MD5 dc0c14011976a0a4e1fbee8b0a3af03b
BLAKE2b-256 f5d35bc4653b247bd8aa7534ad70af3f01129e3f39c4c8951e0c7c84d2969f2d

See more details on using hashes here.

File details

Details for the file langchain_qwq_modification-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_qwq_modification-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13fb6f3d4ee75819472b212365cad24cabde0d3a2aab17e27d9f4de03aa5a1df
MD5 5b5b1700f1aef72b7e1ec6cee29dc42d
BLAKE2b-256 7cdf5457a00a03b681d5f59bcdd54ea65b7a7d6566284358c203f7234d07783c

See more details on using hashes here.

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