Metadata-Version: 2.3
Name: typechatpy
Version: 0.4.0
Summary: 
Author: FFengIll
Author-email: fengyouzheng@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: loguru (>=0.7.3,<0.8.0)
Requires-Dist: pydantic (>=2.1.1,<3.0.0)
Description-Content-Type: text/markdown

# Typechat.py

A python implement to makes it easy to build natural language interfaces using types.

# Install
`pip install typechatpy`

# Usage
## Simple
see [simple](example/simple).

```python
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](example).

```python
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](example/simple) for more detail (the `response` sample as bellow).

```json
{
  "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
- [x] translator
- [ ] validator
- [ ] ~~llm interact~~

# Ref
- [pydantic](https://github.com/pydantic/pydantic)
- [typechat](https://github.com/microsoft/TypeChat)
