Skip to main content

A utility for reading configurations from a YAML file to run Langchain.

Project description

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 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

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_roleplay-0.0.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_roleplay-0.0.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_roleplay-0.0.1.tar.gz.

File metadata

  • Download URL: langchain_roleplay-0.0.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for langchain_roleplay-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ce50d88a80b70f372582e9380662ac1e181c5b7bccfbd087ea4168557b2b64d8
MD5 4ce931450c6cd5182939e49a93df4711
BLAKE2b-256 32d760b6b63ef953a3c523ba9ec5490bc8f6eff50454a2f154678734b79f2c51

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_roleplay-0.0.1.tar.gz:

Publisher: publish.yml on maye76/roleplay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_roleplay-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_roleplay-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 510bd663040cb9c287beba2233f410b544acfb288a2fbc49947ba94e7eb50897
MD5 7352ce8a2d5bdcf8d313bb71cdf2d723
BLAKE2b-256 15bee322b57717fbac2dcfcbe74515e5e699738abc80450c9620020039508796

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_roleplay-0.0.1-py3-none-any.whl:

Publisher: publish.yml on maye76/roleplay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page