Back to bricks list
Introduction
Technical Documentation
Other Classes
OpenAiChat
Version

OpenAiChat

Class to manage communication with OpenAI chat api

:return: description :rtype: type

Functions

__INIT__

Initialize self. See help(type(self)) for accurate signature.

Parameters:
NameTypeDefault valueDescription
contextstr
messagesList
ADD_ASSISTANT_MESSAGE
Parameters:
NameTypeDefault valueDescription
contentstr
ADD_USER_MESSAGE
Parameters:
NameTypeDefault valueDescription
contentstr
CALL_GPT
Return type:
str
EXPORT_GPT_MESSAGES
Return type:
List
GET_LAST_ASSISTANT_MESSAGE
Parameters:
NameTypeDefault valueDescription
extract_codebool
Return type:
Optional
GET_LAST_MESSAGE
Return type:
Optional
HAS_CONTEXT
Return type:
bool
LAST_MESSAGE_IS_USER
Return type:
bool
SET_CONTEXT
Parameters:
NameTypeDefault valueDescription
contextstr
TO_JSON
Return type:
OpenAiChatDict
EXTRACT_CODE_FROM_GPT_RESPONSE - @classmethod

Extract only the code from the GPT response.

Parameters:
NameTypeDefault valueDescription
gpt_responsestr _description_
Return type:
str
FROM_JSON - @classmethod
Parameters:
NameTypeDefault valueDescription
jsonOpenAiChatDict
contextstr
Return type:
OpenAiChat