No edit summary |
(Added Edited template with July 12, 2025.) |
||
(7 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Edited|July|12|2025}} | |||
SysOpenAI model pattern is a model for integrating OpenAI functionality into your application. | SysOpenAI model pattern is a model for integrating OpenAI functionality into your application. | ||
This model can be merged from TK Live View. | This model can be merged from [[Documentation:TK Live View|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. | 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 | ==== SysOpenAI has three classes: ==== | ||
'''SysOpenAISingleton''' | |||
SysOpenAISingleton | |||
This class points to the instance on azure where ChatGPT is deployed. | This class points to the instance on azure where ChatGPT is deployed. | ||
SysOpenAIChatSession | '''SysOpenAIChatSession''' | ||
This class is for creating a new AI session and making requests to the AI instance. | This class is for creating a new AI session and making requests to the AI instance. | ||
SysOpenAIMessage | '''SysOpenAIMessage''' | ||
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]] | |||
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 ==== | |||
<syntaxhighlight> | |||
-- 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 | |||
) | |||
) | |||
) | |||
) | |||
</syntaxhighlight> | |||
<html> | |||
<div class="video"> | |||
<div class="video__wrapper"> | |||
<iframe src="https://www.youtube.com/embed/angLacNI2Bs"?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe> | |||
</div> | |||
</div> | |||
</html> |
Latest revision as of 06:35, 20 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
)
)
)
)