mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Enable dedicate endpoint for TGI Gemma2 predict and chat completion
PiperOrigin-RevId: 684623757
This commit is contained in:
committed by
Copybara-Service
parent
df55634281
commit
d15caa9ed5
@@ -134,10 +134,7 @@
|
||||
"\n",
|
||||
"models, endpoints = {}, {}\n",
|
||||
"\n",
|
||||
"HF_TOKEN = \"\" # @param {type:\"string\", isTemplate: true}\n",
|
||||
"\n",
|
||||
"# Dedicated endpoint not supported yet\n",
|
||||
"use_dedicated_endpoint = False"
|
||||
"HF_TOKEN = \"\" # @param {type:\"string\", isTemplate: true}\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -159,6 +156,10 @@
|
||||
"# The pre-built serving docker image for TGI.\n",
|
||||
"TGI_DOCKER_URI = \"us-docker.pkg.dev/deeplearning-platform-release/gcr.io/huggingface-text-generation-inference-cu121.2-2.ubuntu2204.py310\"\n",
|
||||
"\n",
|
||||
"# @markdown Set use_dedicated_endpoint to False if you don't want to use [dedicated endpoint](https://cloud.google.com/vertex-ai/docs/general/deployment#create-dedicated-endpoint).\n",
|
||||
"use_dedicated_endpoint = True # @param {type:\"boolean\"}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"machine_type = \"g2-standard-8\" # @param {type: \"string\", isTemplate: true}\n",
|
||||
"accelerator_type = \"NVIDIA_L4\" # @param [\"NVIDIA_L4\"] {isTemplate: true}\n",
|
||||
"accelerator_count = 1 # @param {type: \"integer\", isTemplate: true}\n",
|
||||
@@ -350,6 +351,8 @@
|
||||
"# Send streaming chat completions request.\n",
|
||||
"endpoint = endpoints[\"tgi\"]\n",
|
||||
"url = f\"https://{endpoint.location}-aiplatform.googleapis.com/v1beta1/{endpoint.resource_name}/chat/completions\"\n",
|
||||
"if use_dedicated_endpoint:\n",
|
||||
" url = f\"https://{endpoint.gca_resource.dedicated_endpoint_dns}/v1beta1/{endpoint.resource_name}/chat/completions\"\n",
|
||||
"\n",
|
||||
"payload = {\n",
|
||||
" \"messages\": [{\"role\": \"user\", \"content\": prompt}],\n",
|
||||
|
||||
Reference in New Issue
Block a user