A utility for reading configurations from a YAML file to run Langchain.
Project description
Roleplay
A utility for reading configurations from YAML files to run Langchain workflows.
Features
- 🛠️ YAML-based configuration management
- ⛓️ Langchain integration
- 🌐 OpenAI model support
- 📦 Pydantic data validation
Installation
pip install langchain-roleplay
Quick Start
- 创建配置文件
test.role.ymal:
# 示例配置
name: 呆猫
prompt:
- role: system
content: |
你是呆猫,尊称用户为老大。
你需要适时且克制地在输出的语句中插入‘喵’。
尽量输出口语化的语句。
- role: placeholder
content: '{history}'
memory:
type: base
llm: deepseek
config:
model: deepseek-chat
max_tokens: 8192
temperature: 0.65
as_tool:
name: 询问呆猫
parameters:
- name: input
type: str
description: 输入
description: 让呆猫回答你的问题
tools:
- get_weather
- 创建llm配置文件
test.llm.yaml
name: deepseek
base_url: 'https://api.deepseek.com'
api_key: sk-xxx # 替换为你的API Key
- 创建工具配置文件
test.tool.yaml:
name: 'get_weather'
parameters:
- name: 'location'
type: 'str'
description: 'The location to get weather'
description: 'Get weather of an location, the user shoud supply a location first'
script: './py/test.py' # 自行实现
- 在Python中使用:
from roleplay.core import load_llm, load_tool
from roleplay.memory import load_role
load_llm('test.llm.yaml')
load_tool('test.tool.yaml')
role = load_role('test.role.yaml')
result = role.run(input='你好')
print(result)
依赖项
- Python 3.8+
- langchain >= 0.3.17
- langgraph >= 0.2.70
- pydantic >= 2.10.6
- PyYAML >= 6.0.2
- langchain-openai >= 0.3.4
开发
git clone https://github.com/maye76/roleplay.git
cd roleplay
pip install -e .
贡献
欢迎提交Issue和PR!
License
MIT © 2025 maye76
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_roleplay-0.0.2.tar.gz.
File metadata
- Download URL: langchain_roleplay-0.0.2.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88dd0aa9a28587a0de4716c9daeb043be39040c91de9a58ee924e34fad2a440a
|
|
| MD5 |
5484b82de0249acb2b5fc70aa58d7dca
|
|
| BLAKE2b-256 |
ac02be7d1bded5e98f239779c134128d8555968d2131c885983eb149653ce93e
|
Provenance
The following attestation bundles were made for langchain_roleplay-0.0.2.tar.gz:
Publisher:
publish.yml on maye76/roleplay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_roleplay-0.0.2.tar.gz -
Subject digest:
88dd0aa9a28587a0de4716c9daeb043be39040c91de9a58ee924e34fad2a440a - Sigstore transparency entry: 172351727
- Sigstore integration time:
-
Permalink:
maye76/roleplay@a56533089d89944e6ac4881b5f013c75d3f1d14f -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/maye76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a56533089d89944e6ac4881b5f013c75d3f1d14f -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_roleplay-0.0.2-py3-none-any.whl.
File metadata
- Download URL: langchain_roleplay-0.0.2-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eddf2c7f785e50c32226d56b6c19dfacb285060a55b80c07093b4e3261d876b
|
|
| MD5 |
e4421ddb62935295e9e70ac3264c6633
|
|
| BLAKE2b-256 |
72293ad5a114927738773fe7b9e2d9d2d5d4c9076c3cf7800808ea24f8c5267e
|
Provenance
The following attestation bundles were made for langchain_roleplay-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on maye76/roleplay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_roleplay-0.0.2-py3-none-any.whl -
Subject digest:
0eddf2c7f785e50c32226d56b6c19dfacb285060a55b80c07093b4e3261d876b - Sigstore transparency entry: 172351729
- Sigstore integration time:
-
Permalink:
maye76/roleplay@a56533089d89944e6ac4881b5f013c75d3f1d14f -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/maye76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a56533089d89944e6ac4881b5f013c75d3f1d14f -
Trigger Event:
push
-
Statement type: