A multi-bot simulation package with multi-turn conversation and self-play and role-play capabilities
Project description
MultiBot Simulation for Self-Play
SelfPlay is a Python package that allows you to simulate conversations between multiple chatbots. The package includes an orchestrator bot to determine the order of responses based on a given goal.Introducing SelfPlay Project – a versatile and intelligent chatbot package designed to enhance your conversational AI capabilities. With features enabling multi-turn self-chat and seamless interaction between two chatbots, this package leverages the power of LLMs to deliver insightful and dynamic conversations. Perfect for developers, educators, and businesses looking to integrate advanced chatbot functionalities, My Chatbot Project offers robust logging, error handling, and easy customization to meet your unique needs.
Features
- Simulate conversations among multiple bots
- Orchestrator bot to manage conversation flow
- Provides Memory for LLM conversations
- Multi-turn Conversations with control for maximum turns
- Ability to export conversation as a neatly formatted html
- Easy-to-use API
Installation
You can install the package via pip:
pip install selfplay
Usage
Example 1: Multi-turn Self Chat
In this example, the chatbot will perform a self-chat to simulate a conversation with itself. This can be useful for improving response accuracy and testing conversational flows.
import os
from selfplay.chatbot import Chatbot
# Set OpenAI credentials
os.environ["AZURE_OPENAI_API_KEY"] = "8jsd899fs000sdf7632"
os.environ["AZURE_OPENAI_API_ENDPOINT"] = "https://server.openai.azure.com"
os.environ["AZURE_OPENAI_API_VERSION"] = "2023-12-01-preview"
#self-chat multi-turn conversation
bot = Chatbot(name="default", sys_msg="you are a helpful assistant and honest in repsones. you give short and concise response.")
bot.chat("what is the capital of California")
bot.chat("how about Oregon?")
bot.chat("How many live here?")
print(bot)
Example 2: Chat with Another Bot
In this example, two chatbots, one acting as a teacher and the other as a student, interact with each other. This showcases how you can simulate educational or customer service interactions.
import os
from selfplay.chatbot import Chatbot
# Set OpenAI credentials
os.environ["AZURE_OPENAI_API_KEY"] = "8jsd899fs000sdf7632"
os.environ["AZURE_OPENAI_API_ENDPOINT"] = "https://server.openai.azure.com"
os.environ["AZURE_OPENAI_API_VERSION"] = "2023-12-01-preview"
# Initialize chatbots with specific roles and system messages
teacher = Chatbot(
name="Teacher",
sys_msg="You are a helpful teacher with extensive knowledge of science and math. "
"You ask thoughtful questions to motivate and invoke students' curiosity and depth. "
"Provide concise, crisp, and clear replies."
)
student = Chatbot(
name="Student",
sys_msg="You are a student trying to learn from a teacher. "
"Ask clarifying questions until the topic is clear to you."
)
#Interact between the teacher and student chatbots
response = teacher.interact(
student, #who to interact with
start="I'm a 4th grader and I don't seem to quite understand what complex numbers are.",
num_turns=2, #max_turns in conversation
filename="/Users/dpiskala/Downloads/teacher-student.html" #export the chat results in a well-formatted html file.
)
print(response)
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 selfplay-0.1.0.tar.gz.
File metadata
- Download URL: selfplay-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
277729577aa58f4ab892c72bf890c3b4d3e0986f3a330e9d8baf07ec3cdaf4b4
|
|
| MD5 |
90fbd96b998036c2653a7d1b743ac9a5
|
|
| BLAKE2b-256 |
ffbd97c94024512b82a1dc380bbcc2b2d3220ce88926846dce1ebad812d42024
|
File details
Details for the file selfplay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: selfplay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d8bc2661146f212cbb4d8a88781ec171663a14afb8b1bc25e6be9f08644ee00
|
|
| MD5 |
703a5a15190825c283a58ce61d86835f
|
|
| BLAKE2b-256 |
4eb6d6535e249736d247dde67fdc75bb2503800b76aa4bad34a14fa490586766
|