From c48473cf2b680586937550fc67cc1c9481571518 Mon Sep 17 00:00:00 2001 From: Sriniketh J <81156510+srini047@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:34:48 +0530 Subject: [PATCH 1/3] Add files via upload --- .github/assets/logos/Google Gemini.png | Bin 0 -> 7098 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/assets/logos/Google Gemini.png diff --git a/.github/assets/logos/Google Gemini.png b/.github/assets/logos/Google Gemini.png new file mode 100644 index 0000000000000000000000000000000000000000..d2ff0f72613c976ef54cd36405f0ecfd8ee90108 GIT binary patch literal 7098 zcmZ{JS5(uF?>5NZyC_R!$Y?>PvNsA;h6ruhEkpL+dn0>qMA-j>0NJt_76Kb-5h*5Ra zBN7ra5|hVfx)c-?lvK22WMouy%v93u{|qux5*ijBYV+ZL9(rLtDwktwR(?92T>21z zQpAj!k%Q9e162S(rC-M&<3Qc~geU7ohS2DDA&dC`428s?nOX-uM@ZgoKHM zNBBNe* zWeAAs1Va0O@DU)O9q`2w6m1f2o8;)EoN8qPkFu}%^y41rJ7$dm3EejAmEHS({n9n7m&GQR<4?Mt)1}~0*g!RBzU(1 z9$12cV=mJj#m9NqY2AObhX6Mm0DrN`qim;{2jq_do;`qa4&YJu!>I*;26gagdp}0S zr}qLWJ%9%CISO-akUGVz8f@yG16GIIHJ&|;?H6}!ld^uH?p$t%COqo`EUFLr?`bml z67DCg-4CCTG!Bq}=LzWtq+$=E>bE>H28t(vtUe&ChhQDiklP2a$(RdiJJEAXLd$=d zz6OlZfMGqLk^F%_U|lR7kjMcfG63Nu0AyCnWz~8+>_j4!AQ?D)>)9-KD1j>q;EM+M zVgaF8Krj-x9k5$G0+?X{Xcf`026&jiBcFCGldvV40*EFN1mXz-seoJ_Ae99OyN`l` zi0pp9L0&tzLV(*5MDZjbuOHCK*)*vo8dL##l|;>#fLbv@xd>1w0Pg1!_!9t$R6r_| z$Qcgsh5;hc1V|hp8ompA3CMXj!y15xm4M0%K&gOmKOd0I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, 10 Jan 2024 16:43:06 +0530 Subject: [PATCH 2/3] add: latest google gemini template --- ...gle_Gemini_Write_a_social_media_post.ipynb | 284 ++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb diff --git a/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb b/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb new file mode 100644 index 0000000000..3d2331edfa --- /dev/null +++ b/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb @@ -0,0 +1,284 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "88c104cc-bf08-4242-821b-b3a40908152a", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Google" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Gemini - Write a social media post" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": {}, + "source": [ + "**Tags**: #google #gemini #socialmedia #post #prompt #tone #platform" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": {}, + "source": [ + "**Author:** [Sriniketh Jayasendil](https://www.linkedin.com/in/sriniketh-jayasendil)" + ] + }, + { + "cell_type": "markdown", + "id": "0de144be-594d-463e-9849-696fb2f6d1a8", + "metadata": {}, + "source": [ + "**Last update:** YYYY-MM-DD (Created: YYYY-MM-DD) -> The last update date refers to when the notebook was last edited, while the created date corresponds to when the notebook was initially merged." + ] + }, + { + "cell_type": "markdown", + "id": "31ea7cdb-e10d-43fc-b026-f69249a59736", + "metadata": {}, + "source": [ + "**Description:** This notebook will help us write a social media post and configure based on the topic, the tone and the platform." + ] + }, + { + "cell_type": "markdown", + "id": "d4b89388-5cd5-409a-8169-c53cc8dfab96", + "metadata": {}, + "source": [ + "**References:** list of references and websites utilized in the creation of this notebook\n", + "- [Naas Documentation](https://site.naas.ai/)\n", + "- [Google AI Dev](https://ai.google.dev)\n", + "- [Gemini Python Docs](https://ai.google.dev/tutorials/python_quickstart)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": {}, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import naas\n", + "try:\n", + " import google.generativeai as genai\n", + "except ModuleNotFoundError:\n", + " !pip install google-generativeai --user\n", + " import google.generativeai as genai" + ] + }, + { + "cell_type": "markdown", + "id": "aggressive-trustee", + "metadata": {}, + "source": [ + "### Setup Variables\n", + "\n", + "- `api_key`: Google Gemini API. Get one from [here](https://makersuite.google.com/app/apikey)\n", + "- `topic`: the topic of the blog post\n", + "- `tone`: the tone of the blog post\n", + "- `platform`: social media platform to publish your post\n", + "\n", + "#### About \"tone\"\n", + "\n", + "Here are some different tones you can use for a blog post:\n", + "\n", + "- **Formal**: Use proper language, professional terms, and formal sentence structures. This tone is best used for academic or business-related blog posts.\n", + "- **Informative**: Stick to facts and provide helpful information. Avoid adding your opinion and present the content in a straightforward and objective manner.\n", + "- **Conversational**: Write as if you're talking to a friend. Use casual language, contractions, and personal anecdotes. This tone is best suited for lifestyle or personal blogs.\n", + "- **Inspirational**: Write in a way that motivates and encourages readers. Use positive language, inspiring stories, and uplifting messages.\n", + "- **Humorous**: Add some humor and make readers laugh. Use witty remarks, funny anecdotes, and sarcastic comments to engage readers.\n", + "- **Persuasive**: Try to persuade readers to take action or change their mind about a topic. Use strong arguments, statistics, and emotional appeals to convince readers.\n", + "- **Opinionated**: Share your personal opinion on a topic. Use strong language, personal experiences, and bold statements to express your views.\n", + "- **Educational**: Teach readers something new. Use step-by-step instructions, infographics, and helpful tips to educate readers on a topic.\n", + "- **Critical**: Analyze a topic critically and provide a detailed analysis. Use logic, reasoning, and evidence to support your arguments.\n", + "- **Empathetic**: Write in a way that connects with readers on an emotional level. Use empathy, compassion, and understanding to create a sense of community and support.\n", + "\n", + "#### About \"social media platforms\"\n", + "\n", + "Here's a list of social media platforms where you can write articles:\n", + "\n", + "- **LinkedIn**: LinkedIn is a professional social media platform where you can publish articles on industry-related topics. It's a great place to establish yourself as a thought leader and connect with other professionals in your field.\n", + "- **Facebook Notes**: Facebook Notes is a feature on Facebook that allows users to write long-form posts and publish them to their profile or page. It's a great way to share personal stories or thoughts with your friends and followers.\n", + "- **Twitter Threads**: Twitter Threads are a series of connected tweets that can be used to share longer thoughts or stories. It's a great way to break up longer articles into bite-sized pieces and share them with your Twitter followers.\n", + "- **Instagram Stories**: Instagram Stories are a feature on Instagram that allows users to share short videos or images that disappear after 24 hours. It can be a great way to share personal stories or behind-the-scenes glimpses into your life or business.\n", + "- **Reddit**: Reddit is a social news aggregation and discussion platform where users can post articles, stories, and links to other websites. It's a great platform for niche communities and can be a good place to share your writing with like-minded individuals." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "continuous-melbourne", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "google_api_key = naas.secret.get(\"GOOGLE_API_KEY\") or \"Enter your API key\"\n", + "topic = \"What are the benefits of being consistent?\"\n", + "tone = \"Inspirational\"\n", + "platform = \"Twitter\"\n", + "prompt = f\"Write a {tone.lower()} social media post about '{topic}' for {platform}.\"\n", + "\n", + "# Outputs\n", + "file_path = f\"Social_Media_Post_{topic.replace(' ', '_')}_{tone}_on_{platform}_characters.md\"" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": {}, + "source": [ + "## Model\n", + "### Send requests to OpenAI API" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "crude-louisville", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "try:\n", + " genai.configure(api_key=google_api_key)\n", + " model = genai.GenerativeModel('gemini-pro')\n", + " response = model.generate_content(prompt)\n", + "except:\n", + " print(\"Cannot run code in your region. Check here for valid regions: https://ai.google.dev/available_regions#available_regions\")" + ] + }, + { + "cell_type": "markdown", + "id": "472ed28e-e11f-4820-8aee-73006c25c28c", + "metadata": {}, + "source": [ + "### Get text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3f14b302-c1b6-4f30-8097-2b2baef8e089", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "text = response.text\n", + "print(text)" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + } + }, + "source": [ + "## Output\n", + "### Save text to txt file" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9c4e3b7b-6440-4844-8054-265f1aec65eb", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "text_file = open(file_path, \"w\")\n", + "text_file.write(text)\n", + "text_file.close()\n", + "print('Done...')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a5d441ee-af04-4438-9d6f-316e998ad62a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 6c7631769bd6a0ac60c92a6573662a7e719a7664 Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Thu, 1 Feb 2024 08:20:55 +0100 Subject: [PATCH 3/3] feat: update on google gemini templates --- .../Google_Gemini_Setup_connection.ipynb | 279 ++++++++++++++++++ ...gle_Gemini_Write_a_social_media_post.ipynb | 14 +- template.ipynb | 8 +- 3 files changed, 290 insertions(+), 11 deletions(-) create mode 100644 Google Gemini/Google_Gemini_Setup_connection.ipynb diff --git a/Google Gemini/Google_Gemini_Setup_connection.ipynb b/Google Gemini/Google_Gemini_Setup_connection.ipynb new file mode 100644 index 0000000000..e8e280a3c3 --- /dev/null +++ b/Google Gemini/Google_Gemini_Setup_connection.ipynb @@ -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": [ + "\"OpenAI.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "a5b2c509-2c29-49e8-af91-4f3f1e386da3", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Google Gemini - Setup connection\n", + "

Give Feedback | Bug report" + ] + }, + { + "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 +} diff --git a/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb b/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb index 3d2331edfa..0a980ec91a 100644 --- a/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb +++ b/Google Gemini/Google_Gemini_Write_a_social_media_post.ipynb @@ -8,7 +8,7 @@ "tags": [] }, "source": [ - "\"Google" + "\"OpenAI.png\"" ] }, { @@ -19,7 +19,7 @@ "tags": [] }, "source": [ - "# Gemini - Write a social media post" + "# Google Gemini - Write a social media post" ] }, { @@ -27,7 +27,7 @@ "id": "religious-programmer", "metadata": {}, "source": [ - "**Tags**: #google #gemini #socialmedia #post #prompt #tone #platform" + "**Tags:** #googlegemini #socialmedia #post #prompt #tone #platform" ] }, { @@ -43,7 +43,7 @@ "id": "0de144be-594d-463e-9849-696fb2f6d1a8", "metadata": {}, "source": [ - "**Last update:** YYYY-MM-DD (Created: YYYY-MM-DD) -> The last update date refers to when the notebook was last edited, while the created date corresponds to when the notebook was initially merged." + "**Last update:** 2024-01-31 (Created: 2024-01-15)" ] }, { @@ -59,7 +59,7 @@ "id": "d4b89388-5cd5-409a-8169-c53cc8dfab96", "metadata": {}, "source": [ - "**References:** list of references and websites utilized in the creation of this notebook\n", + "**References:**\n", "- [Naas Documentation](https://site.naas.ai/)\n", "- [Google AI Dev](https://ai.google.dev)\n", "- [Gemini Python Docs](https://ai.google.dev/tutorials/python_quickstart)" @@ -106,7 +106,7 @@ "id": "aggressive-trustee", "metadata": {}, "source": [ - "### Setup Variables\n", + "### Setup variables\n", "\n", "- `api_key`: Google Gemini API. Get one from [here](https://makersuite.google.com/app/apikey)\n", "- `topic`: the topic of the blog post\n", @@ -148,7 +148,7 @@ }, "outputs": [], "source": [ - "google_api_key = naas.secret.get(\"GOOGLE_API_KEY\") or \"Enter your API key\"\n", + "google_api_key = naas.secret.get(\"GOOGLE_GEMINI_API_KEY\") or \"Enter your API key\"\n", "topic = \"What are the benefits of being consistent?\"\n", "tone = \"Inspirational\"\n", "platform = \"Twitter\"\n", diff --git a/template.ipynb b/template.ipynb index 63580c3239..a02710101a 100644 --- a/template.ipynb +++ b/template.ipynb @@ -27,7 +27,7 @@ "id": "religious-programmer", "metadata": {}, "source": [ - "**Tags**: #tool -> hastags of the topics the notebook is about, as text starting with the name of the tool" + "**Tags:** #tool" ] }, { @@ -35,7 +35,7 @@ "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", "metadata": {}, "source": [ - "**Author:** [Firstname Lastname](https://www.linkedin.com/) -> name and social profile link of the author(s)" + "**Author:** [Firstname Lastname](https://www.linkedin.com/)" ] }, { @@ -43,7 +43,7 @@ "id": "0de144be-594d-463e-9849-696fb2f6d1a8", "metadata": {}, "source": [ - "**Last update:** YYYY-MM-DD (Created: YYYY-MM-DD) -> The last update date refers to when the notebook was last edited, while the created date corresponds to when the notebook was initially merged." + "**Last update:** YYYY-MM-DD (Created: YYYY-MM-DD)" ] }, { @@ -59,7 +59,7 @@ "id": "d4b89388-5cd5-409a-8169-c53cc8dfab96", "metadata": {}, "source": [ - "**References:** list of references and websites utilized in the creation of this notebook\n", + "**References:**\n", "- [Naas Documentation](https://site.naas.ai/)" ] },