feat:
- Criado um serviço de llm (por enquanto está obtendo somente o gemini, necessita adicioanr suporte para entrada do usuário na pergunta) test: - Criado teste para conexão com o banco de dados oracle por meio da engine do sqlAlchemy
This commit is contained in:
21
app/llm_service.py
Normal file
21
app/llm_service.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
from langchain_core.language_models.chat_models import BaseChatModel
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
||||
|
||||
def get_llm() -> BaseChatModel | None:
|
||||
if not GEMINI_API_KEY:
|
||||
print("⚠️ Variável de ambiente GEMINI_API_KEY não definida.")
|
||||
# raise ValueError("OPENAI_API_KEY não está configurada.")
|
||||
return None
|
||||
try:
|
||||
llm = ChatGoogleGenerativeAI(model="gemma-3-27b-it", google_api_key=GEMINI_API_KEY)
|
||||
print("Gemma 3 configurado com sucesso")
|
||||
|
||||
return llm
|
||||
except Exception as e:
|
||||
print(f"Erro ao configurar o llm: {e}")
|
||||
return None
|
||||
Reference in New Issue
Block a user