Idiomatic way to build chatgpt apps using async generators in python
Project description
turbo-chat
Idiomatic way to build chatgpt apps using async generators in python
Installation
pip install turbo-chat
Example
from turbo_chat import *
# Horoscope app
@turbo()
async def horoscope(context: dict):
yield System(content="You are a fortune teller")
yield User(content=f"My zodiac sign is {context['zodiac']}")
input = yield GetUserInput(message="What do you want to know?")
yield User(content=input)
value = yield Generate(settings={"temperature": 0.9})
print(f"generated: {value}")
# Testing
app = horoscope({"zodiac": "pisces"})
output, done = await run(app)
assert isinstance(output, GetUserInput)
assert not done
user_input = "Tell me my fortune"
output, done = await run(app, user_input)
assert isinstance(output, str)
assert done
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
turbo_chat-0.1.1.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for turbo_chat-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 466b6632c4fd9b8834b85e34261d6aa49b059fdb8ce81c774871efb6ca81d64d |
|
MD5 | cdfa84b3c5c6ba73ca7d598a7b242f96 |
|
BLAKE2b-256 | 0b51101fe80d47e7b3bb6a79f6ec953022a9eae977b600767f4752da50855e7b |