File size: 1,721 Bytes
5698dd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
 "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
}