How to trigger a method call from the API response?

Is that possible in some fashion?

If, for example, I had a load of prompts that had an artist name and song title as the prompt and a file path as the completion is it possible to have the api reliably return the file path when asked about the song?

I wrote a skill for Alexa that had remote desktop capabilities. I essentially want to crop Alexa off that and replace it with OpenAI’s API. So, I have an AI that successfully understands the verbal command to copy and paste and I have functions that will copy and paste when called.

How do I make the call?! I’m guessing it’ll be parsing the string in some fashion for key words since that’s all there is to work with isn’t there?

You can specify in the prompt a list of functions or classes that you have available and ask it to send a flag that will trigger one of those functions.

For example:

You are an AI with access to the following classes and their methods:

  1. CustomClass1:

    • method1(arg: string)
    • method2(arg: string)
    • method3()
  2. CustomClass2:

    • method1(goalName: string, idea: string)
    • method2(resourceType: string, amount: number)
    • method3(goalName: string, steps: string)
    • method4(goalName: string)

Respond in a valid JSON format:
class: “Name of the class”,
method: “Name of the method”
args: [list of arguments]

You can ask it to return the response in yaml, json, markdown, whatever structure you’d like. This way you can integrate OpenAI with anything.

1 Like