-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2488 from jupyter-naas/2485-gemini-social-media-post
feat: Google Gemini-Social media post
- Loading branch information
Showing
4 changed files
with
567 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "be5dd6e3-f6cd-4c02-a6aa-722079e94fdd", | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2021-02-23T14:22:16.610471Z", | ||
"iopub.status.busy": "2021-02-23T14:22:16.610129Z", | ||
"iopub.status.idle": "2021-02-23T14:22:16.627784Z", | ||
"shell.execute_reply": "2021-02-23T14:22:16.626866Z", | ||
"shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" | ||
}, | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"<img width=\"8%\" alt=\"OpenAI.png\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/OpenAI.png\" style=\"border-radius: 15%\">" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a5b2c509-2c29-49e8-af91-4f3f1e386da3", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Google Gemini - Setup connection\n", | ||
"<a href=\"https://app.naas.ai/user-redirect/naas/downloader?url=https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/OpenAI/OpenAI_Setup_connection.ipynb\" target=\"_parent\"><img src=\"https://naasai-public.s3.eu-west-3.amazonaws.com/Open_in_Naas_Lab.svg\"/></a><br><br><a href=\"https://bit.ly/3JyWIk6\">Give Feedback</a> | <a href=\"https://github.com/jupyter-naas/awesome-notebooks/issues/new?assignees=&labels=bug&template=bug_report.md&title=OpenAI+-+Setup+connection:+Error+short+description\">Bug report</a>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d77fe283-4edd-42d3-a909-8e207d4b842f", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"**Tags:** #googlegemini #naas #secret #connection #setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b90f2d91-c886-4e36-8265-b09d06bb1c7f", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "6bbf7807-dda4-4b8a-b016-fe258a0fa33f", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"**Last update:** 2024-02-01 (Created: 2024-02-01)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "214749fe-7f0b-4755-b7ea-1d200c234cc6", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"**Description:** This notebook help you setup your connection with Google Gemini and add required credentials to Naas secret. You will be able to establish a seamless connection to Google Gemini without the need to repeatedly redefine your credentials in variables by using `naas.secret.get()` in your notebook." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a1329bea-ad80-4981-874c-8776b11f89a8", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"**References:**\n", | ||
"- [Google AI Dev](https://ai.google.dev)\n", | ||
"- [Gemini Python Docs](https://ai.google.dev/tutorials/python_quickstart)\n", | ||
"- [Naas Secret Documentation](https://site.naas.ai/docs/developers/jobs/secret)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cff349c8-2816-4ae4-9229-027c068eeb51", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"## Input" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "80266a9e-fe54-4f3e-aeb2-01483bbc53f9", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"### Import libraries" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cc038b10-2679-42bc-909e-09a298339df4", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import naas" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "30127040-e487-4115-8317-5084823b3a6f", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [ | ||
"variables" | ||
] | ||
}, | ||
"source": [ | ||
"### Setup variables\n", | ||
"**Mandatory**\n", | ||
"- `api_key`: Google Gemini API Key. This value will be stored under the secret 'GOOGLE_GEMINI_API_KEY'.\n", | ||
"\n", | ||
"**Optional**\n", | ||
"- `secrets`: Dict to add secrets to naas" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8d86b8fb-2576-426d-a305-50043c24c23e", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [ | ||
"parameters" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Mandatory\n", | ||
"api_key = None\n", | ||
"\n", | ||
"# Optional\n", | ||
"secrets = {\n", | ||
" \"GOOGLE_GEMINI_API_KEY\": api_key,\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1b0ae044-cac2-479f-b1fc-a3318696adf5", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"## Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3aadae7f-fbe5-4f97-a6a9-6efe9dd1a42f", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"### Add secret" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e235794a-6907-4f0e-ab2b-5aa6668a8d3b", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"for secret in secrets:\n", | ||
" new_value = secrets.get(secret)\n", | ||
" if new_value:\n", | ||
" naas.secret.add(secret, secrets.get(secret))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7c97931b-4ce8-46f9-a70c-45393c5669ee", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"## Output" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "760ec150-d79a-4208-adfe-d0336d443dc8", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"### Display result" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4005faa2-a781-4805-9c08-74951e900d12", | ||
"metadata": { | ||
"papermill": {}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"df = naas.secret.list()\n", | ||
"df = df[df[\"name\"].isin(secrets.keys())]\n", | ||
"df" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.6" | ||
}, | ||
"naas": { | ||
"notebook_id": "3a9b0b5281032399d79196d4dc442bbaa86480c0f1a67a059f517daec95f977a", | ||
"notebook_path": "OpenAI/OpenAI_Setup_connection.ipynb" | ||
}, | ||
"papermill": { | ||
"default_parameters": {}, | ||
"environment_variables": {}, | ||
"parameters": {}, | ||
"version": "2.4.0" | ||
}, | ||
"widgets": { | ||
"application/vnd.jupyter.widget-state+json": { | ||
"state": {}, | ||
"version_major": 2, | ||
"version_minor": 0 | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.