An integration package connecting QwQ and LangChain
Project description
langchain-qwq-modification
魔改langchain-qwq,提高兼容性:
- 为api_base设置别名base_url;
- 合并reasoning_content到content;
- 添加与标签
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:
DASHSCOPE_API_KEY: Your DashScope API key for accessing QwQ modelsDASHSCOPE_API_BASE: (Optional) API base URL, defaults to "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_qwq_modification-0.0.2.tar.gz.
File metadata
- Download URL: langchain_qwq_modification-0.0.2.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afdc5680dde071d0b8a9f096da0c062b005f34828116288cbe6ce7d1cdf90d46
|
|
| MD5 |
a9cf5ea3dd6ab613e4ada02dc9fdd66c
|
|
| BLAKE2b-256 |
d0b112e92f34cd2ce63f9b60621d4d3a353786897cc702bc2efb0462f72d90a4
|
File details
Details for the file langchain_qwq_modification-0.0.2-py3-none-any.whl.
File metadata
- Download URL: langchain_qwq_modification-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9640c44a3cea36b89b8d7ef812e3119bf2791006f90b20ecdf5c09ee2ef87ae
|
|
| MD5 |
843b91ae32d52fab6c1aae83877bc371
|
|
| BLAKE2b-256 |
61db61a7aab684444e603ff049e8f09eb8f076c3a24fb941d8ad3f6c343539bc
|