ai icon indicating copy to clipboard operation
ai copied to clipboard

Rendering a mock stream so that avoiding unecessary API calls

Open bici-dev opened this issue 1 year ago • 2 comments

Feature Description

I'm familiarizing with this new tool and it's unpractical having to trigger an api call to OpenAI each time I want to try something new. I would like to have the option of render a mock stream.

Use Case

Cost efficient development

Additional context

No response

bici-dev avatar Apr 19 '24 16:04 bici-dev

One option is to record and playback your OpenAI response, see this Gist for example: https://gist.github.com/unstubbable/ffa9028fcb6ea6f218579e9e7cebd403

unstubbable avatar Apr 26 '24 17:04 unstubbable

Thanks Hendrik!

aphxtwin avatar Apr 26 '24 18:04 aphxtwin

This can already be done, you can easily implement your own providers. During dev you can use the mock provider. Look at some of the community providers that are available.

https://sdk.vercel.ai/providers/community-providers/custom-providers#:~:text=You%20can%20write%20your%20own,to%20implement%20a%20custom%20provider.

https://github.com/vercel/ai/tree/main/packages/mistral

Use GPT to have it change the code for you. Use Calude Opus and put this in your prompt

think step by step, provide full code. Ensure you write strongly typed, immutable and declarative code. It is important to continue to following existing established best practices. After you’ve written the code review it against the original and provide feedback on how you can improve to be consistent with established conventions.

gruckion avatar Jun 01 '24 15:06 gruckion

Mock models are now exposed: https://sdk.vercel.ai/docs/ai-sdk-core/testing

lgrammel avatar Sep 19 '24 16:09 lgrammel