blab_chatbot_openai.conversation_openai#

A module that interacts with the APIs of OpenAI and BLAB Controller.

Module Contents#

Classes#

OpenAIWebSocketBotClientConversation

Performs the communication between OpenAI and BLAB Controller.

class OpenAIWebSocketBotClientConversation(*args, **kwargs)#

Bases: blab_chatbot_bot_client.conversation_websocket.WebSocketBotClientConversation[blab_chatbot_openai.openai_settings_format.BlabOpenAIClientSettings]

Performs the communication between OpenAI and BLAB Controller.

Create an instance. The history deque is initialized as empty.

Parameters:
  • args (Any) –

  • kwargs (Any) –

on_connect()#

Handle the successful connection with the controller.

This method does nothing. The behaviour is defined by subclasses.

Return type:

None

on_receive_message(message)#

Handle the arrival of a new message.

This method does nothing. The behaviour is defined by subclasses.

Note that this method is also called when the bot’s own messages are delivered.

Parameters:

message (blab_chatbot_bot_client.data_structures.Message) – the incoming message

Return type:

None

generate_answer(message)#

Generate zero or more answers to a given message.

This method returns an empty list. Subclasses should implement the desired behaviour.

Parameters:

message (blab_chatbot_bot_client.data_structures.Message) – the message which should be answered

Returns:

a list with the answers

Return type:

list[blab_chatbot_bot_client.data_structures.OutgoingMessage]