moved response.text into try to catch errors there
Browse files- library.ipynb +22 -3
library.ipynb
CHANGED
@@ -28,11 +28,30 @@
|
|
28 |
" model = genai.GenerativeModel('gemini-pro')\n",
|
29 |
" try:\n",
|
30 |
" response = model.generate_content(text)\n",
|
|
|
31 |
" except Exception as e:\n",
|
32 |
" return -1,str(e)\n",
|
33 |
-
"
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
]
|
37 |
},
|
38 |
{
|
|
|
28 |
" model = genai.GenerativeModel('gemini-pro')\n",
|
29 |
" try:\n",
|
30 |
" response = model.generate_content(text)\n",
|
31 |
+
" retval=response.text\n",
|
32 |
" except Exception as e:\n",
|
33 |
" return -1,str(e)\n",
|
34 |
+
" return 0,retval"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": null,
|
40 |
+
"metadata": {},
|
41 |
+
"outputs": [],
|
42 |
+
"source": [
|
43 |
+
"# def call_gemini(text,key):\n",
|
44 |
+
"# # response=f'calling gemini with key {key} and text {text}'\n",
|
45 |
+
"# # return response\n",
|
46 |
+
"# genai.configure(api_key=key)\n",
|
47 |
+
"# model = genai.GenerativeModel('gemini-pro')\n",
|
48 |
+
"# try:\n",
|
49 |
+
"# response = model.generate_content(text)\n",
|
50 |
+
"# except Exception as e:\n",
|
51 |
+
"# return -1,str(e)\n",
|
52 |
+
"# if 'text' in response.__dict__ :\n",
|
53 |
+
"# return 0,response.text\n",
|
54 |
+
"# else: return -1,'no generation'"
|
55 |
]
|
56 |
},
|
57 |
{
|