diff --git a/sijapi/__init__.py b/sijapi/__init__.py index 49ca2ae..d49668e 100644 --- a/sijapi/__init__.py +++ b/sijapi/__init__.py @@ -119,7 +119,6 @@ TTS_OUTPUT_DIR = TTS_DIR / 'outputs' os.makedirs(TTS_OUTPUT_DIR, exist_ok=True) TTS_SEGMENTS_DIR = TTS_DIR / 'segments' os.makedirs(TTS_SEGMENTS_DIR, exist_ok=True) -ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY") # Calendar & email account MS365_TOGGLE = True if os.getenv("MS365_TOGGLE") == "True" else False diff --git a/sijapi/config/secrets.yaml-example b/sijapi/config/secrets.yaml-example index 3a80c6d..bf1c9ac 100644 --- a/sijapi/config/secrets.yaml-example +++ b/sijapi/config/secrets.yaml-example @@ -1,4 +1,4 @@ -GLOBAL_API_KEYS: +GLOBAL: - DEPRECATED OPENAI: 'sk-YOUR_OPENAI_API_KEY' VISUALCROSSING: 'YOUR_VC_API_KEY' diff --git a/sijapi/config/tts.yaml-example b/sijapi/config/tts.yaml-example index bed8591..8e26a15 100644 --- a/sijapi/config/tts.yaml-example +++ b/sijapi/config/tts.yaml-example @@ -21,4 +21,4 @@ elevenlabs: Attenborough: "b42GBisbu9r5m5n6pHF7" Victoria: "7UBkHqZOtFRLq6cSMQQg" - api_key: "{{ SECRET.ELEVENLABS_API_KEY }}" + api_key: "{{ SECRET.ELEVENLABS }}" diff --git a/sijapi/routers/llm.py b/sijapi/routers/llm.py index 7cc544d..921525e 100644 --- a/sijapi/routers/llm.py +++ b/sijapi/routers/llm.py @@ -26,7 +26,7 @@ import tempfile import shutil import html2text import markdown -from sijapi import L, Llm, LLM_SYS_MSG, REQUESTS_DIR, OBSIDIAN_CHROMADB_COLLECTION, OBSIDIAN_VAULT_DIR, DOC_DIR, OPENAI_API_KEY, SUMMARY_INSTRUCT, SUMMARY_CHUNK_SIZE, SUMMARY_TPW, SUMMARY_CHUNK_OVERLAP, SUMMARY_LENGTH_RATIO, SUMMARY_TOKEN_LIMIT, SUMMARY_MIN_LENGTH, SUMMARY_MODEL +from sijapi import L, Llm, LLM_SYS_MSG, REQUESTS_DIR, OBSIDIAN_CHROMADB_COLLECTION, OBSIDIAN_VAULT_DIR, DOC_DIR, SUMMARY_INSTRUCT, SUMMARY_CHUNK_SIZE, SUMMARY_TPW, SUMMARY_CHUNK_OVERLAP, SUMMARY_LENGTH_RATIO, SUMMARY_TOKEN_LIMIT, SUMMARY_MIN_LENGTH, SUMMARY_MODEL from sijapi.utilities import convert_to_unix_time, sanitize_filename, ocr_pdf, clean_text, should_use_ocr, extract_text_from_pdf, extract_text_from_docx, read_text_file, str_to_bool, get_extension from sijapi.routers import tts from sijapi.routers.asr import transcribe_audio @@ -405,7 +405,7 @@ def query_gpt4(llmPrompt: List = [], system_msg: str = "", user_msg: str = "", m {"role": "system", "content": system_msg}, {"role": "user", "content": user_msg} ] - LLM = OpenAI(api_key=OPENAI_API_KEY) + LLM = OpenAI(api_key=Llm.openai.key) response = LLM.chat.completions.create( model="gpt-4", messages=messages, @@ -435,7 +435,7 @@ def llava(image_base64, prompt): return "" if "pass" in response["response"].lower() else response["response"] def gpt4v(image_base64, prompt_sys: str, prompt_usr: str, max_tokens: int = 150): - VISION_LLM = OpenAI(api_key=OPENAI_API_KEY) + VISION_LLM = OpenAI(api_key=Llm.openai.key) response_1 = VISION_LLM.chat.completions.create( model="gpt-4-vision-preview", messages=[ diff --git a/sijapi/routers/tts.py b/sijapi/routers/tts.py index 5340b27..0815f9a 100644 --- a/sijapi/routers/tts.py +++ b/sijapi/routers/tts.py @@ -49,7 +49,7 @@ async def list_wav_files(): async def list_11l_voices(): formatted_list = "" url = "https://api.elevenlabs.io/v1/voices" - headers = {"xi-api-key": Tts.elevenlabs.api_key} + headers = {"xi-api-key": Tts.elevenlabs.key} async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers) @@ -220,9 +220,9 @@ async def determine_voice_id(voice_name: str) -> str: debug(f"Found voice ID in config - {voice_id}") return voice_id - debug(f"Requested voice not among the voices specified in config/tts.yaml. Checking with ElevenLabs API using api_key: {Tts.elevenlabs.api_key}.") + debug(f"Requested voice not among the voices specified in config/tts.yaml. Checking with ElevenLabs API using api_key: {Tts.elevenlabs.key}.") url = "https://api.elevenlabs.io/v1/voices" - headers = {"xi-api-key": Tts.elevenlabs.api_key} + headers = {"xi-api-key": Tts.elevenlabs.key} async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers) @@ -263,7 +263,7 @@ async def elevenlabs_tts(model: str, input_text: str, voice: str, title: str = N "model_id": model } # Make sure this is the correct way to access the API key - headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.api_key} + headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.key} try: async with httpx.AsyncClient(timeout=httpx.Timeout(300.0)) as client: response = await client.post(url, json=payload, headers=headers) @@ -447,7 +447,7 @@ async def get_audio_stream(model: str, input_text: str, voice: str): "text": input_text, "model_id": "eleven_turbo_v2" } - headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.api_key} + headers = {"Content-Type": "application/json", "xi-api-key": Tts.elevenlabs.key} response = requests.post(url, json=payload, headers=headers) if response.status_code == 200: