Skip to main content

langchain-wenxin - Langchain Baidu WENXINWORKSHOP wrapper

PyPI - Version PyPI - Python Version


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:

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.

Metadata

Release files for langchain-wenxin 0.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-wenxin 0.10.2
File Size Uploaded
langchain_wenxin-0.10.2.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-wenxin 0.10.2
File Interpreter ABI Platform
langchain_wenxin-0.10.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.7 kB

Release files / langchain_wenxin-0.10.2.tar.gz

Download URL langchain_wenxin-0.10.2.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3cb62c8f1fbae77bac12d887f386b29d0693590696b406384868fb2a4335a33d
BLAKE2b-256 checksum
How to use checksums
b5a467822691ca19c46a308daa2a6afba0acb69ffc12e9d4d4515905cf5ce69c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release files / langchain_wenxin-0.10.2-py3-none-any.whl

Download URL langchain_wenxin-0.10.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7aa0c6a19e88ee0dcd6356f4fdde8d2a606386b02b6deb3846ce94641523d0a5
BLAKE2b-256 checksum
How to use checksums
f998a69d2203f08727445f23cae2a89d1adb3a52d28f5c46948f94df8ffb4212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release history Release notifications | RSS feed

This release

0.10.2 This release

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page