Chat using GenAI
This lesson describes how to use GenAI within Trill Workbench to receive a chat response
Code: /lessons/Gen_Ai
In this example, the function accepts messages in the below format, adds the answer for the last message, and returns the response. Sample input parameter -
This function has another method to “summarizeText”.
Steps(chat method)
Create a new function called GenAi.java.
Implement its “chat” method as shown in the example code.
Set parameters in its function details file. (server.json should be pointing to GenAi.chat.json).
Execute code. Verify response. Return the Result object (if there is a failure then return an error message). Else, extract “messages” from the data.
Sample response for above input is shown below.
Steps(SummarizeText Method)
In the same file implement a method, “summarizeText”. It simply uses Trillo Workbench API, GCPGenApi.summarizeText and returns its response.
Set parameters in its function details file. (server.json should be pointing to GenAi.summarizeText.json).
Execute code and examine the response.
Last updated