Skip to content

Instantly share code, notes, and snippets.

@matthiasa4
matthiasa4 / vertex_ai_search_tuning_file_checks.py
Last active July 27, 2024 10:51
This script helps do the data checks on your input files when using the Search Tuning feature in Google Cloud Vertex AI Agent Builder (https://cloud.google.com/generative-ai-app-builder/docs/tune-search). Usage: `python check.py <corpus_path> <query_path> <scoring_path>`
import sys
import jsonlines
import pandas as pd
def jsonl_to_df(file_path):
data = []
with jsonlines.open(file_path) as reader:
for line in reader:
# Process each line of the JSONL file
@matthiasa4
matthiasa4 / generate-firebase-token.py
Last active October 10, 2024 08:55
Firestore 500/50/5 rule illustration with `k6`
from google.oauth2 import service_account
from google.auth.transport.requests import Request
# Path to your service account key file
key_path = "[INSERT_PATH_TO_KEY_FILE]"
# Create credentials using the service account key file
credentials = service_account.Credentials.from_service_account_file(
key_path,
scopes=["https://www.googleapis.com/auth/cloud-platform"]