module
Memo::ServiceProvider
Overview
Internal module for service configuration CRUD operations
Users should access these operations through Service instance methods:
- memo.create_service(...)
- memo.get_service(name)
- memo.list_services
- memo.update_service(name, ...)
- memo.delete_service(name)
This module is exposed for advanced use cases where direct database access is needed.
:nodoc:
Extended Modules
Defined in:
memo/service_provider.crInstance Method Summary
-
#count(db : DB::Database) : Int64
Get total count of services
-
#create(db : DB::Database, name : String, format : String, model : String, dimensions : Int32, max_tokens : Int32, base_url : String | Nil = nil, is_default : Bool = false) : Info
Create a new service configuration
-
#delete(db : DB::Database, id : Int64, force : Bool = false) : Bool
Delete a service
-
#exists?(db : DB::Database, id : Int64) : Bool
Check if a service exists
-
#get(db : DB::Database, id : Int64) : Info | Nil
Get a service by ID
-
#get_by_name(db : DB::Database, name : String) : Info | Nil
Get a service by name
-
#get_default(db : DB::Database) : Info | Nil
Get the default service
-
#list(db : DB::Database) : Array(Info)
List all services
-
#list_by_format(db : DB::Database, format : String) : Array(Info)
List services by format
-
#set_default(db : DB::Database, name : String) : Bool
Set a service as the default
-
#stats(db : DB::Database, id : Int64) : Stats
Get usage statistics for a service
-
#update(db : DB::Database, id : Int64, base_url : String | Nil = nil, max_tokens : Int32 | Nil = nil) : Info | Nil
Update a service configuration
Instance Method Detail
Create a new service configuration
If a service with the same name already exists, raises an error.
Returns the created service info.
Delete a service
By default, fails if the service has any associated embeddings. Use force: true to delete the service and all associated data.
Returns true if deleted, false if not found. Raises if embeddings exist and force is false.
Get a service by ID
Returns nil if not found.
Get a service by name
Returns nil if not found.
Get the default service
Returns nil if no default is set.
List all services
Returns array of service info, ordered by creation time (newest first).
List services by format
Returns array of service info for the specified API format.
Set a service as the default
Clears any existing default and sets the specified service. Returns true if successful, false if service not found.
Update a service configuration
Can update base_url and max_tokens. Other fields define the service identity. Returns the updated service info, or nil if not found.