No project description provided
Project description
langchain-wenxin - Langchain Baidu WENXINWORKSHOP wrapper
Table of Contents
Installation
pip install langchain-wenxin
Document
WENXINWORKSHOP API: https://cloud.baidu.com/doc/WENXINWORKSHOP/s/flfmc9do2
How to use
export BAIDU_API_KEY="xxxxx"
export BAIDU_SECRET_KEY="xxxxx"
from langchain_wenxin.llms import Wenxin
# Wenxin model
llm = Wenxin(model="ernie-bot-turbo")
print(llm("你好"))
# stream call
for i in llm.stream("你好"):
print(i)
# async call
import asyncio
print(asyncio.run(llm._acall("你好")))
# Wenxin chat model
from langchain_wenxin.chat_models import ChatWenxin
from langchain.schema import HumanMessage
llm = ChatWenxin()
print(llm([HumanMessage(content="你好")]))
# Wenxin embeddings model
from langchain_wenxin.embeddings import WenxinEmbeddings
wenxin_embed = WenxinEmbeddings(truncate="END")
print(wenxin_embed.embed_query("hello"))
print(wenxin_embed.embed_documents(["hello"]))
Support models:
- ernie-bot: Standard model, https://cloud.baidu.com/doc/WENXINWORKSHOP/s/jlil56u11
- Also named
wenxinfor compatibility.
- Also named
- ernie-bot-turbo: Fast model, https://cloud.baidu.com/doc/WENXINWORKSHOP/s/4lilb2lpf
- Also named
eb-instantfor compatibility.
- Also named
- other endpoints: eg: bloomz_7b1 or other custom endpoint.
Qianfan Private
You can set BAIDU_API_URL and BAIDU_ACCESS_CODE in environment variables.
Development
# Create virtual environment
hatch env create
# Activate virtual environment
hatch shell
# Run test
export BAIDU_API_KEY="xxxxxxxx"
export BAIDU_SECRET_KEY="xxxxxxxx"
hatch run test
License
langchain-wenxin is distributed under the terms of the MIT license.
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_wenxin-0.10.2.tar.gz.
File metadata
- Download URL: langchain_wenxin-0.10.2.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb62c8f1fbae77bac12d887f386b29d0693590696b406384868fb2a4335a33d
|
|
| MD5 |
ab7a2ec197af1cfa9c6c7d30cb909173
|
|
| BLAKE2b-256 |
b5a467822691ca19c46a308daa2a6afba0acb69ffc12e9d4d4515905cf5ce69c
|
File details
Details for the file langchain_wenxin-0.10.2-py3-none-any.whl.
File metadata
- Download URL: langchain_wenxin-0.10.2-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa0c6a19e88ee0dcd6356f4fdde8d2a606386b02b6deb3846ce94641523d0a5
|
|
| MD5 |
04b7f776023034b78d8c514870b03a4c
|
|
| BLAKE2b-256 |
f998a69d2203f08727445f23cae2a89d1adb3a52d28f5c46948f94df8ffb4212
|