The server provides several Socket.io endpoints that clients can use to interact with the server. The default URL for the server is http://localhost:9601
, but it can be changed using the configuration file or launch parameters.
connect
'connect'
disconnect
'disconnect'
list_available_bindings
'list_available_bindings'
binding_infs
to store information about each binding.self.bindings_path
directory.self.bindings_path
:
binding_card.yaml
file, which contains information about the binding card.models.yaml
file, which contains information about the models associated with the binding.binding_infs
list.'bindings_list'
to the client containing the list of available bindings and their information (bindings
) as well as a success
parameter that is False
when not successful.Events generated:
'bindings_list'
: Sent to the client as a response to the 'list_available_bindings'
request. It contains the list of available bindings along with their associated information (binding_infs
).list_available_personalities
'list_available_personalities'
self.personalities_path
).config.yaml
) within the personality folder.
scripts
folder exists within the personality folder to determine if the personality has scripts.logo.gif
or logo.webp
or logo.png
or logo.jpg
or logo.jpeg
or logo.bmp
within the assets
folder to determine if the personality has a logo.avatar
field of the personality info based on the available logo file.Events generated:
'personalities_list'
: Emits an event to the client with the list of available personalities, categorized by language and category. The event data includes the personality information such as name, description, author, version, presence of scripts, and avatar image file path.list_available_models
'list_available_models'
self
which refers to the class instance)'available_models_list'
with a failure response indicating that no binding is selected.models
list.'available_models_list'
with a success response containing the list of available models to the client.Events generated:
'available_models_list'
: This event is emitted as a response to the client requesting a list of available models. It contains the success status and a list of available models with their details, such as title, icon, license, owner, owner link, description, installation status, file path, filesize, and model type.list_available_personalities_categories
'list_available_personalities_categories'
data
: An empty dictionary:'available_personalities_categories_list'
to the client.
'available_personalities_categories'
field of the event data.'error'
field of the event data.Events:
'available_personalities_categories_list'
list_available_personalities_categories
event.'success'
(boolean): Indicates whether the retrieval of available personality categories was successful.'available_personalities_categories'
(list): A list of available personality categories.'success'
(boolean): Indicates whether an error occurred during the retrieval of available personality categories.'error'
(string): The error message describing the encountered error.list_available_personalities_names
'list_available_personalities_names'
language
(string): The language for which the available personality names are requested.category
(string): The category for which the available personality names are requested.language
and category
parameters from the request data.language
and category
parameters.'list_available_personalities_names_list'
list_available_personalities_names
request, providing the list of available personality names.success
(bool): Indicates the success or failure of the request.list_available_personalities_names
(list): The list of available personality names.error
(string, optional): If the request fails, this parameter contains the error message.select_binding
'select_binding'
data['binding_name']
: The name of the binding selected by the client.Actions:
self.config
dictionary and assigns it to self.cp_config
variable."binding_name"
value in self.cp_config
with the selected binding name obtained from data['binding_name']
.self.bindings_path
and self.cp_config
.self.binding
with the created binding instance and updates self.config
with self.cp_config
.Events generated:
'select_binding'
: This event is emitted to the client to provide a response regarding the binding selection. It contains the following data:
'success'
: A boolean value indicating the success or failure of the binding selection.'binding_name'
: The name of the selected binding.'error'
: An error message explaining the reason for the failure.select_model
'select_model'
data['model_name']
(string): The name of the model to select.self.binding
).
'select_model'
event with a failure response, indicating that a binding needs to be selected first.self.config
) and assigns it to self.cp_config
."model_name"
property of self.cp_config
to the selected model name.self.binding
) with self.cp_config
.
self.model
.'select_model'
event with a success response, indicating that the model selection was successful.'select_model'
event with a failure response, indicating that a binding needs to be selected first.Events generated:
'select_model'
(success response):
'success'
(boolean): True
to indicate success.'model_name'
(string): The selected model name.'select_model'
(failure response):
'success'
(boolean): False
to indicate failure.'model_name'
(string): The selected model name.'error'
(string): An error message providing additional details.add_personality
'add_personality'
data
: A dictionary containing the following key-value pairs:
'path'
: The path to the personality file.data
dictionary.AIPersonality
instance with the provided path.self.personalities
list.self.config["personalities"]
list.self.config.save_config()
.'personality_added'
: This event is emitted to the client to indicate the successful addition of the personality. The emitted data is a dictionary with the following key-value pairs:
'success'
: True
to indicate success.'name'
: The name of the added personality.'id'
: The ID of the added personality in the self.personalities
list.'personality_add_failed'
: This event is emitted to the client if an exception occurs during the personality addition. The emitted data is a dictionary with the following key-value pairs:
'success'
: False
to indicate failure.'error'
: A string containing the error message explaining the cause of the failure.activate_personality
'activate_personality'
self.personalities
).self.active_personality
to the selected personality.self.config["active_personality_id"]
.self.config.save_config()
.'activate_personality'
: Emits the event to the client with the following data:
'success'
: Indicates whether the personality activation was successful (True
or False
).'name'
: The name of the activated personality.'id'
: The ID (index) of the activated personality in the self.personalities
list.list_active_personalities
'list_active_personalities'
self.personalities
list.'active_personalities_list'
'success'
: A boolean value indicating the success of the operation.'personalities'
: A list of strings representing the names of the active personalities.Please note that the 'list_active_personalities'
event does not require any parameters when triggering the endpoint. It simply returns the list of active personalities to the client.
activate_personality
'activate_personality'
data['id']
(integer): The ID of the personality to activate.self.personalities
list.self.active_personality
to the personality at the specified ID.active_personality_id
in the self.config
object with the activated personality’s ID.Generated Events:
'activate_personality'
: This event is emitted to the client after successfully activating a personality.
{'success': True, 'name': self.active_personality, 'id': len(self.personalities) - 1}
:
'success'
(boolean): Indicates whether the personality activation was successful.'name'
(string): The name of the activated personality.'id'
(integer): The ID of the activated personality.'personality_add_failed'
: This event is emitted to the client if the personality ID provided is not valid.
{'success': False, 'error': 'Personality ID not valid'}
:
'success'
(boolean): Indicates whether the personality activation failed.'error'
(string): The error message indicating the reason for the failure.generate_text
'generate_text'
data
: A dictionary containing the following fields:
prompt
(string): The text prompt for text generation.personality
(integer): The index of the selected personality for conditioning the text generation. If it is -1 then no personality is used and the text is assumed to be raw.'text_generated'
event.Events generated:
'buzzy'
: when the server is buzzy and can’t process the request, it sends this event and returns. This event have parameter message
containing a string.'text_chunk'
: Generated text chunks are emitted to the client through this event during the text generation process. The event has two parameters chunk
and type
.'text_generated'
: Once the text generation process is complete, the final generated text is emitted to the client through this event. The event has one parameter text
containing the full generated text.'generation_canceled'
: Answer to cancel_generation
endpoint call