Model Calling
- OpenAI
Example for creating an OpenAI model with parameters for chat completion.
Parameters
All existing parameters supported by OpenAI’s chat completion model are included by default for customizable requests. Users can pass these using the parameters dictionary.
The api_key parameter is the user’s OpenAI API key, required for authentication to access the chat completion service.
Example for creating an OpenAI model with parameters for image generation
All existing parameters supported by OpenAI’s image generation model are supported by default.
All existing parameters supported by OpenAI’s image generation model are included by default for customizable requests. Users can pass these using the parameters dictionary.
The api_key parameter is the user’s OpenAI API key, required for authentication to access the image generation service.
- Perplexity
Example of creating a perplexity model with parameters for chat completion.
All existing params supported by the Perplexity chat completion model are supported by default.
Parameters
A dictionary supporting all existing parameters accepted by the Perplexity chat completion model for customizable requests.
The user’s Perplexity API key required for authentication to access the chat completion service.
- Connect your own model to the framework
You can bring in your own model and connect it to our framework by extending our base AIModel class.
Import
Import AIModel class
Params
You may provide initial parameters, including the API key and any model-specific parameters.
Methods
Crucially, create two methods: generate_text and generate_image, as stipulated by the abstract class design of AIModel.
How to bring your own model to Lyzr Automata? 👇
Methods
generate_text
Method
Generates a text response using an AI chat model based on the provided prompt and optional parameters. This method is intended for creating conversational AI responses, leveraging the client’s chat completion capabilities.
An optional identifier for the task. Used to specify or reference a particular task instance.
An optional string that defines the persona or role of the system in the conversation.
An optional string containing the initial prompt or question posed by the user to the AI system.
An optional list of dictionaries, each representing a message in the conversation history. The default value creates a conversation starting with the system persona’s message followed by the user’s prompt.
generate_image
Method
Generates an image based on a given prompt, utilizing the client’s image generation capabilities. The generated image is saved using a ResourceBox
, which likely handles file management and storage.
A required identifier for the task, used to specify a unique instance for image generation and storage.
The prompt based on which the image will be generated. This string should describe the desired outcome for the image.
An instance of ResourceBox, which is used for managing the storage of the generated image, including saving the file from a URL and determining the subfolder based on task_id.