Skip to main content

An integration package connecting QwQ and LangChain

Project description

langchain-qwq-modification

魔改langchain-qwq,提高兼容性:

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

Installation

pip install -U langchain-qwq-modification

以下为原版langchain-qwq的readme


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.2.tar.gz (10.6 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.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for langchain_qwq_modification-0.0.2.tar.gz
Algorithm Hash digest
SHA256 afdc5680dde071d0b8a9f096da0c062b005f34828116288cbe6ce7d1cdf90d46
MD5 a9cf5ea3dd6ab613e4ada02dc9fdd66c
BLAKE2b-256 d0b112e92f34cd2ce63f9b60621d4d3a353786897cc702bc2efb0462f72d90a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_qwq_modification-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9640c44a3cea36b89b8d7ef812e3119bf2791006f90b20ecdf5c09ee2ef87ae
MD5 843b91ae32d52fab6c1aae83877bc371
BLAKE2b-256 61db61a7aab684444e603ff049e8f09eb8f076c3a24fb941d8ad3f6c343539bc

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