Recipe API
api_create_recipe(name, description, tags, categories, datasets, prompt_templates, metrics, grading_scale)
Creates a new recipe with the given parameters.
This function takes various parameters that define a recipe, creates a RecipeArguments object with these parameters, and then calls the Recipe.create method to create a new recipe in the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the recipe. |
required |
description |
str
|
A description of the recipe. |
required |
tags |
list[str]
|
A list of tags associated with the recipe. |
required |
categories |
list[str]
|
A list of categories the recipe belongs to. |
required |
datasets |
list[str]
|
A list of datasets used in the recipe. |
required |
prompt_templates |
list[str]
|
A list of prompt templates for the recipe. |
required |
metrics |
list[str]
|
A list of metrics to evaluate the recipe. |
required |
grading_scale |
dict[str, list[int]]
|
A grading scale dictionary where the key is the grade and the |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The ID of the newly created recipe. |
Source code in moonshot/src/api/api_recipe.py
api_delete_recipe(rec_id)
Deletes a recipe identified by its unique recipe ID.
This function takes a recipe ID, verifies the existence of the recipe, and if found, calls the delete method from the Recipe class to remove the recipe from storage.
If the deletion is successful, it returns True. If the recipe does not exist or an exception occurs during deletion, a RuntimeError is raised with an appropriate error message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rec_id |
str
|
The unique identifier for the recipe to be deleted. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the recipe was successfully deleted. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the deletion process encounters an error. |
Source code in moonshot/src/api/api_recipe.py
api_get_all_recipe()
Retrieves all available recipes.
This function calls the get_available_recipes method to retrieve all available recipes. It then converts each recipe into a dictionary using the to_dict method and returns a list of these dictionaries.
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of dictionaries, each representing a recipe. |
Source code in moonshot/src/api/api_recipe.py
api_get_all_recipe_name()
Retrieves all available recipe names.
This function calls the get_available_recipes method to retrieve all available recipes. It then extracts the names of each recipe and returns a list of these names.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: A list of strings, each representing a recipe name. |
Source code in moonshot/src/api/api_recipe.py
api_read_recipe(rec_id)
Reads a recipe and returns its information.
This function takes a recipe ID as input, reads the corresponding recipe, and returns a dictionary containing the recipe's information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rec_id |
str
|
The ID of the recipe. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the recipe's information. |
Source code in moonshot/src/api/api_recipe.py
api_read_recipes(rec_ids)
Reads multiple recipes and returns their information.
This function takes a list of recipe IDs as input, reads the corresponding recipes, and returns a list of dictionaries containing each recipe's information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rec_ids |
list[str]
|
The IDs of the recipes. |
required |
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing a recipe's information. |
Source code in moonshot/src/api/api_recipe.py
api_update_recipe(rec_id, **kwargs)
Updates a recipe with the given keyword arguments.
This function takes a recipe ID and arbitrary keyword arguments, checks if the recipe exists, and updates the fields of the recipe with the provided values. If the recipe does not exist, a RuntimeError is raised. If the update is successful, it returns True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rec_id |
str
|
The ID of the recipe to update. |
required |
**kwargs |
Arbitrary keyword arguments representing the fields to update. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the recipe was successfully updated. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the recipe with the given ID does not exist. |