Skip to main content

Roleplay

License: MIT Python 3

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

  1. 创建配置文件 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
  1. 创建llm配置文件 test.llm.yaml
name: deepseek
base_url: 'https://api.deepseek.com'
api_key: sk-xxx # 替换为你的API Key
  1. 创建工具配置文件 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' # 自行实现
  1. 在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

Metadata

Release files for langchain-roleplay 0.0.3

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-roleplay 0.0.3
File Size Uploaded
langchain_roleplay-0.0.3.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-roleplay 0.0.3
File Interpreter ABI Platform
langchain_roleplay-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / langchain_roleplay-0.0.3.tar.gz

Download URL langchain_roleplay-0.0.3.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6457f73d60b90fe81f9804871d6b9c3f30062b7afbd450bdef67ec9a0dcb1643
BLAKE2b-256 checksum
How to use checksums
1a387e2854056de4e2355d0fe68180802e459ea1263fd5a51afee590963a07c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release files / langchain_roleplay-0.0.3-py3-none-any.whl

Download URL langchain_roleplay-0.0.3-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
720824ea498a2309488edce5059f72b0a8aa51d2477d4b166aed7b8e3a5c0070
BLAKE2b-256 checksum
How to use checksums
de52577faa9ca5fc1c6d62c6779379c57e794beaf224771aadd7b04d1ad27e81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

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