{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "To add a fine-tuned model, you'll have to grant additional permissions (due to fine-tuned models using personal data).\n", "The Google Gemini API currently does not support this feature (https://github.com/google-gemini/cookbook/blob/main/quickstarts/Authentication_with_OAuth.ipynb), therefore ping the REST endpoint to grant access. Just make it EVERYONE cause FURY data isn't something sensitive.\n", "\n", "To setup gcloud refer: https://ai.google.dev/gemini-api/docs/oauth\n", "\n", "RESOURCES\n", "https://ai.google.dev/gemini-api/docs/model-tuning\n", "https://ai.google.dev/api/tuning/permissions\n", "\n", "\"\"\"\n", "\n", "import requests\n", "\n", "model_name = 'tunedModels/model_name' # @param {type:\"string\"}\n", "emailAddress = '' # @param {type:\"string\"}\n", "\n", "\n", "access_token = !gcloud auth application-default print-access-token\n", "\n", "headers = {\n", " 'Content-Type': 'application/json',\n", " 'Authorization': f'Bearer {access_token[0]}',\n", "}\n", "\n", "body = {\n", " 'granteeType': 'EVERYONE',\n", " 'role': 'READER'\n", "}\n", "\n", "# Construct correct URL with model name\n", "url = f'https://generativelanguage.googleapis.com/v1beta/{model_name}/permissions'\n", "\n", "response = requests.post(url, json=body, headers=headers)\n", "\n", "print(response.json())\n" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 2 }