svpino / openai-function-calling

An example of using Function Calling with OpenAI's API
55 stars 4 forks source link

Question on one of the lines of code #1

Closed dfinke closed 1 year ago

dfinke commented 1 year ago

First, thank you for the content you provide. It has taught me so much.

I was able to port this great example to another language and got it to work.

The line of code below was tough. Initially I looked at it and just assumed it was json. I implemented variations of "content" : {"request": "27"} OpenAI would error saying it expected a string.

I got it to work after closer inspection. This is just a string that looks like json in a json element.

How did you figure this out? Is there documentation?

Feels like I'll have many missteps creating new OpenAI function specs and interacting with GPT.

 "content": f'{{"result": {str(result)} }}'}