AbanteAI / spice

accelerant
Apache License 2.0
4 stars 2 forks source link

Converter added to get_response #80

Closed jakethekoenig closed 6 months ago

jakethekoenig commented 6 months ago

Similar to validator a converter can be passed and if so it will be called on output and added to the result field of the SpiceResponse. Example of use:

import asyncio
from spice import Spice, print_stream                           
client = Spice()
a = asyncio.run(client.get_response([{"role":"user", "content": "what is your favorite number? Please respond with just one two digit number. This is a test of your ability to follow instructions"}], model="gpt-3.5-turbo", retries=2, streaming_callback=print_stream))
a.text # '42'
a.result # 42

I want to use this with pydantic models and their parse_raw class method.