This file contains hidden or 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
| import requests | |
| from dotenv import load_dotenv | |
| import os | |
| import csv | |
| from conversation_ids import conversation_ids | |
| from bs4 import BeautifulSoup | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| load_dotenv() |
This file contains hidden or 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
| import asyncio | |
| from bleak import BleakScanner, BleakClient | |
| import subprocess | |
| from abc import ABC, abstractmethod | |
| # Base class for your lights (enables polymorphism) | |
| # So each light responds to same command but implements differently | |
| class BLELight(ABC): | |
| def __init__(self, address, characteristic_uuid): | |
| self.address = address |
This file contains hidden or 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
| # pip install youtube-transcript-api | |
| from youtube_transcript_api import YouTubeTranscriptApi | |
| def get_video_transcript(video_id="wk89rJpaj6w"): | |
| transcript_with_timestamps = YouTubeTranscriptApi.get_transcript(video_id) | |
| transcript = ' '.join([t['text'] for t in transcript_with_timestamps]) | |
| return transcript | |
| print(get_video_transcript()) |
This file contains hidden or 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
| def get_airtable_data(view_name=None, table_name="Members"): | |
| print("getting members") | |
| access_token = st.secrets["airtable"]["personal_access_token"] | |
| url, headers = f"https://api.airtable.com/v0/appnc2IWGpsHNfTvt/{table_name}", {"Authorization": f"Bearer {access_token}"} | |
| params = {} if view_name is None else {"view": view_name} | |
| data = [] | |
| while True: | |
| res = requests.get(url, headers=headers, params=params).json() | |
| data += res.get('records', []) | |
| if 'offset' not in res: break |
This file contains hidden or 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
| import React, { useEffect, useState } from 'react'; | |
| import mixpanel from 'mixpanel-browser'; | |
| const ThoughtChecker = () => { | |
| const [textEntered, setTextEntered] = useState(false); | |
| const [journalText, setJournalText] = useState(''); | |
| const [defaultJournalEntry, setDefaultJournalEntry] = useState(''); // Set your default journal entry here | |
| const sessionID = ''; // Set your session ID here | |
| useEffect(() => { |
This file contains hidden or 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
| import requests | |
| import json | |
| def generate_talking_avatar(image_filepath, audio_filepath): | |
| api_key = "<YOUR_API_KEY>" | |
| files = [ | |
| ("input_face", open(image_filepath, "rb")), | |
| ("input_audio", open(audio_filepath, "rb")), | |
| ] |
This file contains hidden or 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
| from openai import OpenAI | |
| def choose_voice(gender="female") | |
| gender = gender.lower() | |
| voice = "shimmer" # gender neutral | |
| if gender == "female": | |
| voice = "nova" | |
| elif gender == "male": | |
| voice = "onyx" |
This file contains hidden or 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
| from openai import OpenAI | |
| def respond_to_message(message, character_description): | |
| api_key = st.session_state.api_key | |
| client = OpenAI(api_key = api_key) | |
| response = client.chat.completions.create( | |
| model="gpt-3.5-turbo", | |
| messages=[ | |
| {"role": "system", "content": f"You are a helpful assistant. Respond to the following message in 1-3 sentences. Also, this is a description of the character you are in case you are asked: {character_description}"}, |
This file contains hidden or 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
| from openai import OpenAI | |
| def create_custom_character(character_description): | |
| client = OpenAI(api_key=api_key) | |
| response = client.images.generate( | |
| model="dall-e-3", | |
| prompt=f"Please create the following 3D character in the style of Pixar Animation Studio with a blurred sunlight background: {character_description}. There should be no text in the image.", | |
| size="1024x1024", |
This file contains hidden or 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
| def categorise_cognitive_distortions(quotes): | |
| client = OpenAI() | |
| client.api_key = st.session_state.api_key | |
| conversation = [ | |
| {"role": "system", | |
| "content": "You categorise cognitive distortions and explain why they are an example of that cognitive distortion"}, | |
| {"role": "user", "content": str(quotes)}, | |
| ] | |
| response = client.chat.completions.create( |
NewerOlder