Skip to content

Instantly share code, notes, and snippets.

View dewitt4's full-sized avatar
😁
Getting Ready to Accelerate!

DeWitt Gibson dewitt4

😁
Getting Ready to Accelerate!
View GitHub Profile
@dewitt4
dewitt4 / OpenAitoCassandra.py
Last active August 15, 2023 23:28
Python function that demonstrates how to use the openai package to generate responses from the OpenAI Language Model and then store those responses in a Cassandra database
pip install Cassandra-driver openai
from cassandra.cluster import Cluster
import openai
def generate_text_with_llm(prompt):
# OpenAI API configuration
openai.api_key = "your_openai_api_key"
# Generate text using OpenAI's LLM
@dewitt4
dewitt4 / OpenAImySQLStore.py
Created August 15, 2023 22:59
Python function that demonstrates how to use the openai package to generate responses from the OpenAI Language Model and then store those responses in a MySQL database
import mysql.connector
import openai
def generate_text_with_llm(prompt):
# OpenAI API configuration
openai.api_key = "your_openai_api_key"
# Generate text using OpenAI's LLM
response = openai.Completion.create(
engine="davinci", # Choose the appropriate engine
@dewitt4
dewitt4 / mySQLOpenAILLM.py
Created August 15, 2023 22:11
Python function that demonstrates how to read data from a mySQL database and then feed it into the OpenAI Language Model (LLM)
pip install mysql-connector-python openai
import mysql.connector
import openai
def fetch_data_from_mysql():
# MySQL database configuration
db_config = {
"host": "your_host",
"user": "your_username",
@dewitt4
dewitt4 / MySQLtoOpenAILLM.py
Created August 15, 2023 18:00
Python function that connects to a MySQL database, imports data into Pandas DataFrames, and then analyzes the data using OpenAI's API for natural language processing
import pandas as pd
import mysql.connector
import openai
# MySQL database settings
MYSQL_HOST = 'your_mysql_host'
MYSQL_USER = 'your_mysql_user'
MYSQL_PASSWORD = 'your_mysql_password'
MYSQL_DATABASE = 'your_mysql_database'
@dewitt4
dewitt4 / OpenAISearchGoogleDrive.py
Last active August 15, 2023 17:45
Python function that uses the Google Drive API to search for files, ingests the raw data from those files into Pandas dataframes, and then analyzes the data using OpenAI's API for natural language processing
import os
import pickle
import pandas as pd
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import openai
# Google Drive API settings
SCOPES_DRIVE = ['https://www.googleapis.com/auth/drive.readonly']
@dewitt4
dewitt4 / FileSearchGoogleDrive.py
Created August 15, 2023 17:39
Python function that uses the Google Drive API to search for files across a user's Google Drive
import os
import pickle
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these SCOPES, delete the token.pickle file.
SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']
def authenticate_google_drive():
@dewitt4
dewitt4 / ReadGoogleDrive.py
Last active August 15, 2023 17:40
Python function that uses the Google Drive API to read documents from Google Drive
import os
import pickle
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseDownload
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these SCOPES, delete the token.pickle file.
SCOPES = ['https://www.googleapis.com/auth/drive.readonly']
@dewitt4
dewitt4 / OpenAIGoogleDocs.txt
Last active August 15, 2023 17:41
an integration between OpenAI and Google Docs
// Define your OpenAI API key
const OPENAI_API_KEY = 'YOUR_OPENAI_API_KEY';
// This function makes a request to the OpenAI API
function generateOpenAIResponse(prompt) {
const apiUrl = 'https://api.openai.com/v1/engines/davinci-codex/completions';
const headers = {
Authorization: `Bearer ${OPENAI_API_KEY}`,
'Content-Type': 'application/json',
};
@dewitt4
dewitt4 / A Public Gist
Created September 26, 2021 01:27
Trial Gist to Test Functionality
def hello():
print("Hello Gist!")