AI APIs
ai_generate
Description: Uses a LLM to generate text and adds it as a new column to a dataset. Ensure that model_name has been registered.
Syntax:
ai_generate(prompt, on, as_col, model_name, model_parameters=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Parameter Type | Description |
|---|---|---|---|
| prompt | Yes | str | Prompt template for text generation. The content of the input column will be appended to this prompt. |
| on | Yes | ir.Column | Dataset column that contains the input data to be processed. |
| as_col | Yes | str | Name of the new column where the generated text will be stored. |
| model_name | Yes | str | Name of the LLM used for text generation. |
| model_parameters | No | str | Additional parameters of the LLM, provided as a JSON string. The default value is None. |
Return type: A dataset containing the new column.
Example:
>>> from aura_frame.multimodal import ai_lake
>>> con = ai_lake.connect(
... aura_endpoint='*',
... access_key='*',
... secret_key='*'
... ...
... )
>>> ds = con.load_dataset("demo_table_text", database='my_schema')
>>> ds
| id | text_content |
| -- | --------------------- |
| int| string |
| -- | --------------------- |
| 1 | You're a good man. |
| 2 | You're a bad man. |
# Use AI and model parameters to generate text.
>>> ds.ai_generate(
... prompt="Is this a positive review? Just reply with 'Yes' or 'No'.",
... on=ds.text_content,
... as_col="judgement",
... model_name="gpt-4",
... model_parameters='{"temperature": 0.7, "max_tokens": 100}'
... )
| id | text_content | judgement |
| -- | --------------------- | --------------- |
| int| string | string |
| -- | --------------------- | --------------- |
| 1 | You're a good man. | Yes |
| 2 | You're a bad man. | No | create_model
Description: Creates an abstract local model to be bound to a remote LLM service.
Syntax:
create_model(model_name, base_url, api_key, remote_model_name, description=None, database=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Parameter Type | Description |
|---|---|---|---|
| model_name | Yes | str | Name of the abstract local model. |
| base_url | Yes | str | Base URL of the remote LLM service. |
| api_key | Yes | str | API key required for connecting to the remote LLM service. |
| remote_model_name | Yes | str | Model name of the remote LLM service. |
| description | No | str | Description of the abstract local model. This parameter is optional. |
| database | No | str | Name of the database to which the model belongs. This parameter is optional. |
Return type: None.
list_models
Description: Queries all models in a specified or the default database.
Syntax:
list_models(database=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Parameter Type | Description |
|---|---|---|---|
| database | No | str | Name of the database where the models to be queried are located. If it is None, the default database is used. |
Return type: list[tuple], a list of tuples, where each tuple contains model names.
drop_model
Description: Deletes the abstract local model with a specified name.
Syntax:
drop_model(model_name)
Input parameters:
| Parameter | Mandatory (Yes/No) | Parameter Type | Description |
|---|---|---|---|
| model_name | Yes | str | Name of the abstract local model. |
Return type: None.
describe_model
Description: Queries the details of a specified model.
Syntax:
describe_model(model_name, database=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Parameter Type | Description |
|---|---|---|---|
| model_name | Yes | str | Name of the model to be queried. |
| database | No | str | Name of the database where the model is located. This parameter is reserved and its default value is None. |
Return type: Details of the model.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot