AIProvider Class API Reference¶
The AIProvider
class is an abstract base class that defines the interface for all AI provider implementations in ClientAI. It ensures consistency across different providers.
Class Definition¶
Bases: ABC
Abstract base class for AI providers.
Source code in clientai/ai_provider.py
chat(messages, model, return_full_response=False, stream=False, **kwargs)
abstractmethod
¶
Engage in a chat conversation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages |
List[Message]
|
A list of message dictionaries, each containing 'role' and 'content'. |
required |
model |
str
|
The name or identifier of the AI model to use. |
required |
return_full_response |
bool
|
If True, return the full response object instead of just the chat content. |
False
|
stream |
bool
|
If True, return an iterator for streaming responses. |
False
|
**kwargs |
Any
|
Additional keyword arguments specific to the provider's API. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
GenericResponse |
GenericResponse
|
The chat response, either as a string, a dictionary, or an iterator for streaming responses. |
Source code in clientai/ai_provider.py
generate_text(prompt, model, return_full_response=False, stream=False, **kwargs)
abstractmethod
¶
Generate text based on a given prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt |
str
|
The input prompt for text generation. |
required |
model |
str
|
The name or identifier of the AI model to use. |
required |
return_full_response |
bool
|
If True, return the full response object instead of just the generated text. |
False
|
stream |
bool
|
If True, return an iterator for streaming responses. |
False
|
**kwargs |
Any
|
Additional keyword arguments specific to the provider's API. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
GenericResponse |
GenericResponse
|
The generated text response, full response object, or an iterator for streaming responses. |