Skip to content

Commit

Permalink
Model name is configurable for the cloud function (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
waziers authored Jun 3, 2024
1 parent 4e14cfd commit ee71c80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions explore-assistant-cloud-function/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ To set up and run the function locally, follow these steps:
```

This setup allows developers to test and modify the function in a local environment before deploying it to a cloud function service.

## Model configuration

By default, the cloud function will use a default model. However, you may want to test out different Gemini models are they are released. We have made the model name configurable via an environment variable.

In development, you can run the main script with a new MODEL_NAME variable:

```bash
PROJECT=XXXX LOCATION=us-central-1 VERTEX_CF_AUTH_TOKEN=$(cat ../.vertex_cf_auth_token) MODEL_NAME=XXXXX python main.py
```

In production, on the cloud function, you can manually set a variable in the GCP UI. Updating the variable will re-deploy the cloud function.
4 changes: 3 additions & 1 deletion explore-assistant-cloud-function/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
project = os.environ.get("PROJECT")
location = os.environ.get("REGION")
vertex_cf_auth_token = os.environ.get("VERTEX_CF_AUTH_TOKEN")
model_name = os.environ.get("MODEL_NAME", "gemini-1.0-pro-001")

vertexai.init(project=project, location=location)

def get_response_headers(request):
Expand All @@ -61,7 +63,7 @@ def has_valid_signature(request):

return hmac.compare_digest(signature, expected_signature)

def generate_looker_query(contents, parameters=None, model_name="gemini-1.0-pro-001"):
def generate_looker_query(contents, parameters=None):

# Define default parameters
default_parameters = {
Expand Down

0 comments on commit ee71c80

Please sign in to comment.