Mudanças na forma de adicionar chaves e na orientação de uso

This commit is contained in:
Impacte AI 2024-11-29 16:07:38 -03:00
parent e50d108b8a
commit a85b9283be
4 changed files with 64 additions and 98 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.env
docker-composer.yaml
.gitignore

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.env
*.pyc
docker-composer.yaml

151
readme.md

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,9 @@ from fastapi import HTTPException
# Carregar variáveis do .env
load_dotenv()
# Função para obter as variáveis
def get_env_var(var_name, default=None):
return os.getenv(var_name, default)
# Função assíncrona para converter base64 em arquivo temporário
async def convert_base64_to_file(base64_data):
@ -25,7 +28,7 @@ async def summarize_text_if_needed(text):
url_completions = "https://api.groq.com/openai/v1/chat/completions"
headers = {
"Authorization": f"Bearer {os.getenv('GROQ_API_KEY')}",
"Authorization": f"Bearer {get_env_var('GROQ_API_KEY')}",
"Content-Type": "application/json",
}
@ -66,7 +69,7 @@ async def summarize_text_if_needed(text):
# Função assíncrona para transcrever o áudio
async def transcribe_audio(audio_file):
url = "https://api.groq.com/openai/v1/audio/transcriptions"
headers = {"Authorization": f"Bearer {os.getenv('GROQ_API_KEY')}"}
headers = {"Authorization": f"Bearer {get_env_var('GROQ_API_KEY')}"}
async with aiohttp.ClientSession() as session:
async with session.post(