The purpose of custom functions is to give solution partners a fast and easy way to integrate AI functions into other parts of their solution without the hassle of storing semantic memory or choosing and updating ai models.
Examples of AI function created using custom functions. Could be:
Preselecting the best values in forms.
Drafting replies to a customer support inquiry.
Semantic function are created beforehand by sending an instruction template to the API.
If any information could be used to improve BAIAs answers this can be stored in custom information sets through the API as well. Examples of custom information sets could be:
Sample answers from earlier interactions.
Relevant information such as opening times, return policies etc.
varquestion="Hvad tid lukker I i dag?";//What time do you close today?varreply=awaitclient.CallAndWaitCustomFunctionAsync("customer-service",new(){Parameters={{"name","Jens Jensen"},{"language","Danish (Denmark)"},{"today",DateTimeOffset.Now.ToString("G")},{"question",question}{"orders","none"}},Retrievals=[ new () { CustomInformationSetId = "my-facts", Handle = "facts", Phrase = question } ]});Console.WriteLine(reply.Result);
This will give an helpful answer about opening times in danish.
Example of asynchronous custom function call
Custom function can be used in multiple fashions. They can also return more structured data.
varoperation=awaitclient.CallCustomFunctionAsync("classify",new(){Parameters={{"email","I ordered a chair from you last month, but now 2 legs fell off. the order number was 1237137223."},}});
After this the status and result of the task can be collected using the returned operation id.
varresult=awaitclient.GetCustomFunctionResultAsync("classify",operation.Id);varreply=result.Result.Split("\n",StringSplitOptions.TrimEntries);if(Enum.TryParse<EmailType>(reply[^1],outvaremailType)){Console.WriteLine($"Email was classified as: {emailType}");}