Applications
Create a Completion Application
Recipes
- Evaluations
- Applications
- Datasets
- Inference
Applications
Create a Completion Application
Use this recipe to create a simple completion application
from scale_gp import SGPClient
from scale_gp.lib.application_builder import ApplicationBuilder
from scale_gp.types.model_template_create_params import (
VendorConfiguration,
VendorConfigurationBundleConfig,
VendorConfigurationEndpointConfig,
)
client = SGPClient(api_key=api_key)
bundle_config = VendorConfigurationBundleConfig(image="gemini-pro", registry="aws-registry", tag="latest")
endpoint_config = VendorConfigurationEndpointConfig(
max_workers=3,
)
vendor_configuration = VendorConfiguration(
bundle_config=bundle_config,
endpoint_config=endpoint_config,
)
model_template = client.model_templates.create(
account_id=account_id,
endpoint_type="SYNC",
model_type="COMPLETION",
name="Gemini-Pro Template",
vendor_configuration=vendor_configuration,
)
model_instance = client.models.create(
account_id=account_id,
model_type="COMPLETION",
name="gemini-pro",
model_vendor="GOOGLE",
model_template_id=model_template.id,
)
model_deployment = client.models.deployments.create(
model_instance_id=model_instance.id, name="Gemini-Pro Deployment", account_id=account_id
)
builder = ApplicationBuilder(client)
application_response = builder.create_completion_application(account_id=account_id, application_name=<UNIQUE_NAME>, completion_model_id=model_deployment.id)
print(application_response)
process_response = builder.process(query="what is the capital of Canada?")
print(process_response)
ApplicationTemplate(
application_type='COMPLETION',
variant_id='3c9a154f-9895-4944-8f4d-4372064d3519'
)
Follow the instructions in the Quickstart Guide to setup the SGP Client
from scale_gp import SGPClient
client = SGPClient(api_key=api_key)
Follow the steps inside the recipe “Deploy and Execute a Model” to create a completion model deployment that we will use in our application
model_deployment = client.models.deployments.create(
model_instance_id=model_instance.id, name="Gemini-Pro Deployment", account_id=account_id
)
We will now use our gemini-pro completion model to create a simple completion application with the ApplicationBuilder helper. Once the application variant is created, it can be used for evaluations, generating report cards, and other benchmarking tasks available in the SGP SDK. The application can also be processed with an input to return a completion result.
builder = ApplicationBuilder(client)
builder.create_completion_application(account_id=account_id, application_name="test-app-builder",completion_model_id=model_deployment.id)
builder.process(query="what is the capital of Canada?")
from scale_gp import SGPClient
from scale_gp.lib.application_builder import ApplicationBuilder
from scale_gp.types.model_template_create_params import (
VendorConfiguration,
VendorConfigurationBundleConfig,
VendorConfigurationEndpointConfig,
)
client = SGPClient(api_key=api_key)
bundle_config = VendorConfigurationBundleConfig(image="gemini-pro", registry="aws-registry", tag="latest")
endpoint_config = VendorConfigurationEndpointConfig(
max_workers=3,
)
vendor_configuration = VendorConfiguration(
bundle_config=bundle_config,
endpoint_config=endpoint_config,
)
model_template = client.model_templates.create(
account_id=account_id,
endpoint_type="SYNC",
model_type="COMPLETION",
name="Gemini-Pro Template",
vendor_configuration=vendor_configuration,
)
model_instance = client.models.create(
account_id=account_id,
model_type="COMPLETION",
name="gemini-pro",
model_vendor="GOOGLE",
model_template_id=model_template.id,
)
model_deployment = client.models.deployments.create(
model_instance_id=model_instance.id, name="Gemini-Pro Deployment", account_id=account_id
)
builder = ApplicationBuilder(client)
application_response = builder.create_completion_application(account_id=account_id, application_name=<UNIQUE_NAME>, completion_model_id=model_deployment.id)
print(application_response)
process_response = builder.process(query="what is the capital of Canada?")
print(process_response)
ApplicationTemplate(
application_type='COMPLETION',
variant_id='3c9a154f-9895-4944-8f4d-4372064d3519'
)
from scale_gp import SGPClient
from scale_gp.lib.application_builder import ApplicationBuilder
from scale_gp.types.model_template_create_params import (
VendorConfiguration,
VendorConfigurationBundleConfig,
VendorConfigurationEndpointConfig,
)
client = SGPClient(api_key=api_key)
bundle_config = VendorConfigurationBundleConfig(image="gemini-pro", registry="aws-registry", tag="latest")
endpoint_config = VendorConfigurationEndpointConfig(
max_workers=3,
)
vendor_configuration = VendorConfiguration(
bundle_config=bundle_config,
endpoint_config=endpoint_config,
)
model_template = client.model_templates.create(
account_id=account_id,
endpoint_type="SYNC",
model_type="COMPLETION",
name="Gemini-Pro Template",
vendor_configuration=vendor_configuration,
)
model_instance = client.models.create(
account_id=account_id,
model_type="COMPLETION",
name="gemini-pro",
model_vendor="GOOGLE",
model_template_id=model_template.id,
)
model_deployment = client.models.deployments.create(
model_instance_id=model_instance.id, name="Gemini-Pro Deployment", account_id=account_id
)
builder = ApplicationBuilder(client)
application_response = builder.create_completion_application(account_id=account_id, application_name=<UNIQUE_NAME>, completion_model_id=model_deployment.id)
print(application_response)
process_response = builder.process(query="what is the capital of Canada?")
print(process_response)
ApplicationTemplate(
application_type='COMPLETION',
variant_id='3c9a154f-9895-4944-8f4d-4372064d3519'
)