Closed alelordelo closed 3 months ago
If you run the demo you can trigger function call by saying "Create an image of a cow" You will see that the arguments is just a string, a JSON string. So for example for "Create an image of a cow" prompt the arguments will be:
{"count": 1, "prompt": "cow"}
This will be a string so you need to convert the string to a dictionary, and then you will be able to get the specific arguments as you would get values from a dictionary.
NOTE: the arguments are defined in the tool that you send in the request.
thanks @jamesrochabrun , got it working now.
The challenge is to parse in realtime the streamed JSON chunks. Did you parsing this to work in realtime? Im woking on it, buts its quite challenging...
this library handles that, but its JS.... https://www.mikeborozdin.com/post/json-streaming-from-openai
I see what you are saying, nope I did not found a Swift solution to handle JSON on stream, I may find time to build something but not on my current plans, if you find something let me know!
@jamesrochabrun I found this: https://zachwaugh.com/posts/streaming-messages-chatgpt-swift-asyncsequence
Not sure if it would also work for parsing function call arguments, will have a look
I also created a stack overflow thread so we can maybe get some help
https://stackoverflow.com/questions/78928283/json-parsing-in-chunks-in-swift#78928283
Thanks for this amazing library! : )
On Assistant V2 API with streaming support, how can we fetch a specific functionCallOutput.argument on a message?
Example: