Skip to content

Instantly share code, notes, and snippets.

/**
* Main function to get comments from the active Google Document, send them to the Azure OpenAI API, and log the responses.
*/
function respondToComments() {
try {
// Get the active document and its ID
var doc = DocumentApp.getActiveDocument();
var documentId = doc.getId();
// Get the body text of the document
@ranfysvalle02
ranfysvalle02 / gs_comments.gs
Created January 23, 2025 04:21
gs_comments.gs
function getComments() {
try {
var doc = DocumentApp.getActiveDocument();
var documentId = doc.getId();
var fields = 'comments(author/displayName,content,createdTime),nextPageToken';
var pageToken = null;
var comments = [];
do {
# Import necessary libraries
from langgraph.graph import StateGraph, END
from typing import Dict, TypedDict, Optional, Literal, List, Union
# Define Graph State
class GraphState(TypedDict):
init_input: Optional[str] = None
fruit: Optional[str] = None
final_result: Optional[str] = None
user_confirmation: Optional[str] = None
from unstructured.partition.auto import partition
import pymongo
from openai import AzureOpenAI
az_client = AzureOpenAI(azure_endpoint="",api_version="",api_key="")
def generate_embeddings(text, model=""): # model = "deployment_name"
return az_client.embeddings.create(input = [text], model=model).data[0].embedding
MDB_URI = ""
DB_NAME = ""
import json
import requests
def get_repo_info(owner, repo):
url = f"https://api.github.com/repos/{owner}/{repo}"
headers = {"Accept": "application/vnd.github+json"}
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
from openai import AzureOpenAI
import os
import subprocess
import json
from shutil import rmtree
# Azure OpenAI configuration
azure_openai_endpoint = os.getenv('OPENAI_AZURE_ENDPOINT', '')
azure_openai_api_key = os.getenv('OPENAI_API_KEY', '')
azure_openai_deployment_id = ''
from openai import AzureOpenAI
import os
import subprocess
import json
from shutil import rmtree
# Azure OpenAI configuration
azure_openai_endpoint = os.getenv('OPENAI_AZURE_ENDPOINT', '')
azure_openai_api_key = os.getenv('OPENAI_API_KEY', '')
azure_openai_deployment_id = ''
from youtube_transcript_api import YouTubeTranscriptApi
from duckduckgo_search import DDGS
from openai import AzureOpenAI
# Replace with your actual values
AZURE_OPENAI_ENDPOINT = "https://DEMO.openai.azure.com"
AZURE_OPENAI_API_KEY = ""
deployment_name = "gpt-4-32k" # The name of your model deployment
client = AzureOpenAI(azure_endpoint=AZURE_OPENAI_ENDPOINT,api_version="2023-07-01-preview",api_key=AZURE_OPENAI_API_KEY)
# Replace with your actual values - if desired
from elevenlabs.client import ElevenLabs
from elevenlabs import play
from langchain_community.vectorstores import MongoDBAtlasVectorSearch
from langchain_openai import AzureOpenAIEmbeddings
from langchain_core.messages import HumanMessage
from langchain_openai import AzureChatOpenAI
import pymongo
# PDF loaded into MongoDB Atlas = https://arxiv.org/pdf/2303.08774.pdf
MDB_URI = ""
cluster = pymongo.MongoClient(MDB_URI)
@ranfysvalle02
ranfysvalle02 / mdb-agg-genai.py
Last active May 19, 2024 07:09
MDB Agg Framework + GenAI (not a vector in sight)
import pymongo
import os
from openai import AzureOpenAI
# Replace with your actual values
AZURE_OPENAI_ENDPOINT = "https://DEMO.openai.azure.com"
AZURE_OPENAI_API_KEY = "DEMO"
deployment_name = "gpt-4-32k" # The name of your model deployment
MDB_URI = ""
# Authenticate and create client