OpenAI chat functions on Android
- Introduction to chat functions: Chat functions allow implementing code that can be executed by the OpenAI chat model. This code can provide real-time data and enhance the chat experience.
- How chat functions work: Chat functions are not actual code running in the model or on the server. They are described and provided as part of the chat completion request, specifying parameters and explaining their functionality.
- Implementing a function: In the JetchatAI sample, a function is added to retrieve weather updates. The function is defined in the OpenAIFunctions.kt file, with parameters described using JSON.
- Function call behavior: After a chat completion, the response may include a function call request from the model. In the code, this is handled by checking the "openai" property of the response.
- Steps to use the weather API: The weather function implementation involves determining the 'grid location', getting the weather forecast for that location, and formatting the result as JSON to include in the chat response.
- Feedback and resources: The code for this implementation can be found in the JetchatAI repository. Feedback and further resources are available in the provided pull request.