No project description provided
Project description
Typechat.py
A python implement to makes it easy to build natural language interfaces using types.
Install
pip install typechatpy
Usage
Simple
see simple.
from typing import List
from pydantic import BaseModel
from typechatpy import translate
class VenueData(BaseModel):
venue: str
description: str
class Response(BaseModel):
data: List[VenueData]
prompt = "Provide 3 suggestions for specific places to go to in Seattle on a rainy day."
def main():
# you can set template or use the default (json type).
res = translate(prompt, Response, VenueData, template=None)
print(res)
if __name__ == "__main__":
main()
General
see more in example.
from typing import List
from pydantic import BaseModel
from typechatpy.translator import Translator
class VenueData(BaseModel):
venue: str
description: str
class Response(BaseModel):
data: List[VenueData]
prompt = "Provide 3 suggestions for specific places to go to in Seattle on a rainy day."
def main():
t = Translator()
# manual set
res = t.generate(prompt, Response, VenueData)
# auto analyse
res = t.generate(prompt, auto=True)
# set from globals
res = t.generate(prompt, *globals().values())
print(res)
if __name__ == "__main__":
main()
Example
see simple for more detail (the response sample as bellow).
{
"data": [
{
"venue": "Seattle Art Museum",
"description": "Explore the extensive collection of art from around the world at the Seattle Art Museum. From contemporary art to ancient artifacts, there is something for everyone to enjoy."
},
{
"venue": "Pike Place Market",
"description": "Indulge in a unique shopping experience at Pike Place Market. Browse through local produce, crafts, and specialty shops, and enjoy a variety of delicious food options."
},
{
"venue": "Chihuly Garden and Glass",
"description": "Marvel at the stunning glass artworks created by Dale Chihuly at the Chihuly Garden and Glass exhibit. The vibrant colors and intricate designs are sure to captivate your senses."
}
]
}
TODO
- translator
- validator
-
llm interact
Ref
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
typechatpy-0.4.0.tar.gz
(3.2 kB
view details)
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 typechatpy-0.4.0.tar.gz.
File metadata
- Download URL: typechatpy-0.4.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a87fd33ed66df0a5f36f11eddcf745a1a7522d5a33dd5dbe609e193cf3167552
|
|
| MD5 |
3ac2129fcff6441fb02b9a00eca13acf
|
|
| BLAKE2b-256 |
2a2381907d2d257dcbc9d864ba8224425e7f00b47daadf892b63ef28f5b6f281
|
File details
Details for the file typechatpy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: typechatpy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0322604a4cad5727920078845a936ef4ed60943dd907af3a6a4eb62aecf1188b
|
|
| MD5 |
19059c8d472e743ca3113dd948238b55
|
|
| BLAKE2b-256 |
1629751ea63d615fb6956a49a85b81b5cd0ec1c44d0a01f5ebf91ba81e5969c8
|