AbanteAI / spice

accelerant
Apache License 2.0
4 stars 2 forks source link

Validator and streaming_callback for get_response #68

Closed jakethekoenig closed 7 months ago

jakethekoenig commented 7 months ago

A test for this is added. This is the first test so pytest, pytest_asyncio and WrappedTestClient is added. WrappedTestClient is a convenience WrappedClient which behaves like Openai's wrapped client except you pass in your desired output in the constructor.

Try with:

from spice import Spice, print_stream
client = Spice()
await client.get_response([{"role":"user","content":"write a random word"}],
                                             model="gpt-3.5-turbo",
                                             streaming_callback=print_stream,
                                             validator=(lambda x: len(x)%4 == 1),
                                             retries=3)