An integration package connecting QwQ and LangChain
Project description
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 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-0.0.7.tar.gz
(9.9 kB
view details)
Built Distribution
File details
Details for the file langchain_qwq-0.0.7.tar.gz
.
File metadata
- Download URL: langchain_qwq-0.0.7.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f01563a40176eb43da8e6765fa914aa10b3c05a6430f4761c1f80943adb3bb5e |
|
MD5 | bc39c62f26a5a527efa248c2cf4da33f |
|
BLAKE2b-256 | 5c014541821ef59941976abdee2b4e8726d7ca1a4656f34cf28850bdbddf6c55 |
File details
Details for the file langchain_qwq-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: langchain_qwq-0.0.7-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ff5460f6d8f6b5ee9c34ee8a71076f8e4f7c286bb27d9e53072730d9ef7ff75 |
|
MD5 | 5ab6308c6eab9510cb0bb3ad97a3e5d6 |
|
BLAKE2b-256 | 754cea56a57b54f6d1c237b7d7fc748c202ad0c8216fd67899ba5270bad78299 |