Last active
April 9, 2023 13:05
-
-
Save Cdaprod/bdeb25f97e0fd14881817d9276b2e867 to your computer and use it in GitHub Desktop.
Notebook with AI functionality that tags and sorts…
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Required packages installation\n", | |
"!pip install transformers openai notion-client PyGithub PyPDF2 python-docx\n", | |
"\n", | |
"# Import required libraries\n", | |
"import os\n", | |
"import openai\n", | |
"import docx\n", | |
"import PyPDF2\n", | |
"from transformers import pipeline\n", | |
"from notion_client import Client\n", | |
"from github import Github\n", | |
"\n", | |
"# Set up your API keys and access tokens\n", | |
"openai.api_key = \"your_openai_api_key\"\n", | |
"huggingface_api_token = \"your_huggingface_api_token\"\n", | |
"notion_api_key = \"your_notion_api_key\"\n", | |
"github_api_key = \"your_github_api_key\"\n", | |
"\n", | |
"# Set up Notion and GitHub clients\n", | |
"notion_client = Client(auth=notion_api_key)\n", | |
"github_client = Github(github_api_key)\n", | |
"\n", | |
"# Your tagging, sorting, and other functions from the previous answers go here\n", | |
"\n", | |
"# ...\n", | |
"\n", | |
"# Function to process user input using GPT-3\n", | |
"def process_user_input(input_text):\n", | |
" prompt = f\"Understand and process the following user input: '{input_text}'\"\n", | |
" response = openai.Completion.create(\n", | |
" engine=\"text-davinci-002\",\n", | |
" prompt=prompt,\n", | |
" max_tokens=50,\n", | |
" n=1,\n", | |
" stop=None,\n", | |
" temperature=0.5,\n", | |
" )\n", | |
"\n", | |
" action = response.choices[0].text.strip()\n", | |
" return action\n", | |
"\n", | |
"# Function to handle user input and call the appropriate functions\n", | |
"def handle_user_input(input_text):\n", | |
" action = process_user_input(input_text)\n", | |
"\n", | |
" if action == \"tag_filesystem\":\n", | |
" # Call the function to tag and sort your filesystem\n", | |
" pass\n", | |
" elif action == \"tag_notion\":\n", | |
" # Call the function to tag and sort your Notion pages\n", | |
" pass\n", | |
" elif action == \"tag_github\":\n", | |
" # Call the function to tag and sort your GitHub repositories\n", | |
" pass\n", | |
" else:\n", | |
" print(\"I'm not sure what you want me to do. Please try again.\")\n", | |
"\n", | |
"# Interactive command-line interface\n", | |
"print(\"Welcome! I can help you tag and sort your filesystem, Notion pages, and GitHub repositories.\")\n", | |
"print(\"Type 'exit' to quit the program.\")\n", | |
"\ | |
"while True:\n", | |
" user_input = input(\"Enter your command: \")\n", | |
" \n", | |
" if user_input.lower() == \"exit\":\n", | |
" print(\"Goodbye!\")\n", | |
" break\n", | |
" \n", | |
" handle_user_input(user_input)\n" | |
] | |
} | |
], | |
"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.8.8" | |
}, | |
"orig_nbformat": 4, | |
"orig_nbformat_minor": 4 | |
}, | |
"nbformat": 5, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment