API View
This module contains views to implement the React.
LLMHost and LLMHostCompute list views in the Smarter Dashboard.
- smarter.apps.llmhost.views.listview.api.COMPUTE_SORT_FIELDS = {'cpu': 'cpu', 'createdAt': 'created_at', 'description': 'description', 'gpuCount': 'gpu_count', 'instanceType': 'instance_type', 'name': 'name', 'pricePerHour': 'price_per_hour', 'updatedAt': 'updated_at'}
The columns of the LLMHostCompute list that it may be sorted by, and the fields that sort them.
{ 'cpu': 'cpu', 'createdAt': 'created_at', 'description': 'description', 'gpuCount': 'gpu_count', 'instanceType': 'instance_type', 'name': 'name', 'pricePerHour': 'price_per_hour', 'updatedAt': 'updated_at', }
- class smarter.apps.llmhost.views.listview.api.LLMHostComputeListApiCloneView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewClone an LLMHostCompute for the authenticated user: its spec, but not its node group, which.
Smarter creates when an LLMHost first needs one of the clone’s nodes.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- class smarter.apps.llmhost.views.listview.api.LLMHostComputeListApiDeleteView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewDelete an LLMHostCompute that the authenticated user owns, and its node group.
Refused while LLMHosts use it.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- class smarter.apps.llmhost.views.listview.api.LLMHostComputeListApiRenameView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewRename an LLMHostCompute that the authenticated user owns.
Refused while its node group exists, or LLMHosts use it.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- class smarter.apps.llmhost.views.listview.api.LLMHostComputeListApiView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewReturn the LLMHostComputes available to the authenticated user, for the React list view in the Smarter Workbench web console: their own, and those shared with them, e.g. the built-in LLMHostComputes, which the Smarter admin owns.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- class smarter.apps.llmhost.views.listview.api.LLMHostListApiCloneView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewClone a llmhost for the authenticated user.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- post(request, *args, **kwargs)[source]
Handle POST requests to clone an existing LLMHost.
Validates input parameters, checks for the existence of the LLMHost to be cloned, and creates a new LLMHost with the specified name. Invalidates the cache for the user’s LLMHosts after cloning.
- Parameters:
request (
HttpRequest) – The HTTP request object containing the parameters for cloning.args – Additional positional arguments (not used).
kwargs –
Additional keyword arguments, including:
llmhost_id (str): The ID of the LLMHost to be cloned.
new_name (str): The new name for the cloned LLMHost.
- Returns:
A JsonResponse containing the serialized data of the newly cloned LLMHost if successful, or an error message if the cloning fails.
- Return type:
- class smarter.apps.llmhost.views.listview.api.LLMHostListApiDeleteView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewDelete a llmhost for the authenticated user.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- post(request, *args, **kwargs)[source]
Handle POST requests to delete an existing LLMHost.
Validates input parameters, checks for the existence of the LLMHost to be deleted, and deletes the LLMHost if it exists. Invalidates the cache for the user’s LLMHosts after deletion.
- Parameters:
request (
HttpRequest) – The HTTP request object containing the parameters for deletion.args – Additional positional arguments (not used).
kwargs –
Additional keyword arguments, including:
llmhost_id (str): The ID of the LLMHost to be deleted.
- Returns:
A JsonResponse indicating the success or failure of the deletion.
- Return type:
- class smarter.apps.llmhost.views.listview.api.LLMHostListApiRenameView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewRename a llmhost for the authenticated user.
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- post(request, *args, **kwargs)[source]
Handle POST requests to rename an existing LLMHost.
Validates input parameters, checks for the existence of the LLMHost to be renamed, and renames the LLMHost if it exists. Invalidates the cache for the user’s LLMHosts after renaming.
- Parameters:
request (
HttpRequest) – The HTTP request object containing the parameters for renaming.args – Additional positional arguments (not used).
kwargs –
Additional keyword arguments, including:
llmhost_id (str): The ID of the LLMHost to be renamed.
new_name (str): The new name for the LLMHost.
- Returns:
A JsonResponse indicating the success or failure of the renaming.
- Return type:
- class smarter.apps.llmhost.views.listview.api.LLMHostListApiView(**kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewRender the llmhost list view for the Smarter Workbench web console.
This view displays all llmhosts available to the authenticated user as cards, providing a quick overview and access to llmhost details.
- Parameters:
- Returns:
Rendered HTML page with a card for each llmhost, or a 404 error page if the user is not authenticated.
- Return type:
HttpResponse
- property formatted_class_name: str
Returns a formatted string of the class name for logging purposes.
- smarter.apps.llmhost.views.listview.api.SORT_FIELDS = {'createdAt': 'created_at', 'description': 'description', 'isActive': 'is_active', 'name': 'name', 'updatedAt': 'updated_at'}
The columns of the LLMHost list that it may be sorted by, and the fields that sort them.
{ 'createdAt': 'created_at', 'description': 'description', 'isActive': 'is_active', 'name': 'name', 'updatedAt': 'updated_at', }