Extends
- SmartChatModelAdapter
Classes
Members
api_key
Get the API key.
choices
Get the number of choices.
default_model_config
Get the default model configuration.
endpoint
Get the endpoint URL.
endpoint_streaming
Get the streaming endpoint URL.
max_output_tokens
Get the maximum output tokens.
model_config
Get the model configuration.
model_key
Get the model key.
models
Get the models.
platform
Get the platform object.
platform_settings
Get the platform settings.
req_adapter
Get the request adapter class.
- Source:
res_adapter
Get the response adapter class.
- Source:
temperature
Get the temperature.
Methods
(async) complete(req) → {Promise.<Object>}
Completes a chat request.
Parameters:
Name | Type | Description |
---|---|---|
req |
Object | The request object. |
- Source:
Returns:
The completed chat response in OpenAI format.
- Type
- Promise.<Object>
(async) count_tokens(req)
Count the number of tokens in a given request.
Parameters:
Name | Type | Description |
---|---|---|
req |
Object | The request object. |
- Source:
Throws:
-
Throws an error if not implemented in the subclass.
- Type
- Error
(async) get_models(refreshopt) → {Promise.<Array.<Object>>}
Get the available models from the platform.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
refresh |
boolean |
<optional> |
false | Whether to refresh the cached models. |
- Source:
Returns:
An array of model objects.
- Type
- Promise.<Array.<Object>>
get_text_chunk_from_stream(event) → {string}
Get the text chunk from the stream event.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | The stream event. |
Returns:
The text chunk.
- Type
- string
is_end_of_stream(event) → {boolean}
Check if the event indicates the end of the stream.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | The event object. |
Returns:
True if the event indicates the end of the stream, false otherwise.
- Type
- boolean
parse_model_data(model_data) → {Array.<Object>}
Parses the raw model data from OpenAI API and transforms it into a more usable format.
Parameters:
Name | Type | Description |
---|---|---|
model_data |
Object | The raw model data received from OpenAI API. |
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
model_name |
string | The name/ID of the model as returned by the API. |
|
key |
string | The key used to identify the model (usually same as model_name). |
|
multimodal |
boolean | Indicates if the model supports multimodal inputs. |
|
max_input_tokens |
number |
<optional> |
The maximum number of input tokens the model can process. |
description |
string |
<optional> |
A description of the model's context and output capabilities. |
- Source:
Returns:
An array of parsed model objects with the following properties:
- Type
- Array.<Object>
stop_stream()
Stop the active stream.