gmshroff commited on
Commit
9ee674e
1 Parent(s): 054c3f5

added encode_gemini(text,key)

Browse files
Files changed (1) hide show
  1. library.ipynb +16 -0
library.ipynb CHANGED
@@ -55,6 +55,22 @@
55
  " return -1,str(e)\n",
56
  " return 0,prediction"
57
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
  ],
60
  "metadata": {
 
55
  " return -1,str(e)\n",
56
  " return 0,prediction"
57
  ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "execution_count": null,
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": [
65
+ "def encode_gemini(text,key):\n",
66
+ " genai.configure(api_key=key)\n",
67
+ " result = genai.embed_content(\n",
68
+ " model=\"models/embedding-001\",\n",
69
+ " content=text,\n",
70
+ " task_type=\"retrieval_document\",\n",
71
+ " title=\"Embedding of single string\")\n",
72
+ " return result['embedding']"
73
+ ]
74
  }
75
  ],
76
  "metadata": {