No edit summary |
|||
Line 18: | Line 18: | ||
This class contains interactions between the AI and User. | This class contains interactions between the AI and User. | ||
[[File:SysOpenAI-Model-Pattern.png|alt=SysOpenAI Pattern|none|thumb|826x826px]] | [[File:SysOpenAI-Model-Pattern.png|alt=SysOpenAI Pattern|none|thumb|826x826px]] | ||
Line 30: | Line 31: | ||
'''#assistance''' - this role is for AI response. The AI uses the context set by the system role and user role to generate a reply. | '''#assistance''' - this role is for AI response. The AI uses the context set by the system role and user role to generate a reply. | ||
==== Using OCL | ==== Using SysOpenAI With OCL ==== | ||
<syntaxhighlight> | <syntaxhighlight> | ||
-- new session to interact with AI | -- new session to interact with AI |
Revision as of 03:25, 16 January 2025
SysOpenAI model pattern is a model for integrating OpenAI functionality into your application.
This model can be merged from TK Live View.
Open AI has a wide variety of use cases from processing data, analyzing data, searching through data and automating other tasks in information systems or apps.
SysOpenAI has three classes,
SysOpenAISingleton
This class points to the instance on azure where ChatGPT is deployed.
SysOpenAIChatSession
This class is for creating a new AI session and making requests to the AI instance.
SysOpenAIMessage
This class contains interactions between the AI and User.
Chat Roles are used to separate the different contexts of the interactions between the person and the AI,
#system - this role is used to give instructions to the AI. It helps to guide and structure the interactions between the user and the AI. This is the context the AI follows to yield responses.
#user - this role is for issuing tasks to the AI. This is the input from person interacting with the AI
#assistance - this role is for AI response. The AI uses the context set by the system role and user role to generate a reply.
Using SysOpenAI With OCL
-- new session to interact with AI
let sess=SysOpenAIChatSession.Create in
(
let message1=SysOpenAIMessage.Create in
(
let message2=SysOpenAIMessage.Create in
(
-- instructions to AI
message1.ChatRole:=#system;
message1.Text:='<text string instruction on how AI should behave>';
sess.SysOpenAIMessages.Add(message1);
-- user input for issuing task
message2.ChatRole:=#user;
message2.Text:='<text string input from user>';
sess.SysOpenAIMessages.Add(message2)
sess.Generate;
let response:=sess.SysOpenAIMessages->last in
(
-- response from AI
reponse.Text
)
)
)
)