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:
0
app/__init___.py
Normal file
0
app/__init___.py
Normal file
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
|
||||
32
app/main.py
Normal file
32
app/main.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from llm_service import get_llm
|
||||
from langchain_core.messages import HumanMessage
|
||||
|
||||
def main():
|
||||
print("Hello from r3wmsagents!")
|
||||
llm_instance = get_llm()
|
||||
if not llm_instance:
|
||||
print("Não carregou o llm")
|
||||
return
|
||||
pergunta_usuario = "Qual é a capital da França e qual sua principal atração turística?"
|
||||
print(f"\n🧑 Enviando pergunta: {pergunta_usuario}")
|
||||
try:
|
||||
# Para interações simples, você pode passar a string diretamente para .invoke()
|
||||
# ou usar uma lista de mensagens para mais controle (ex: com mensagens do sistema)
|
||||
# response = llm_instance.invoke(pergunta_usuario)
|
||||
|
||||
# Usando HumanMessage para ser mais explícito (bom para LangGraph depois)
|
||||
messages = [HumanMessage(content=pergunta_usuario)]
|
||||
response = llm_instance.invoke(messages)
|
||||
print(response)
|
||||
# 5. Imprimir a resposta
|
||||
# A resposta (response) é geralmente um AIMessage, então acessamos seu .content
|
||||
if hasattr(response, 'content'):
|
||||
print(f"\n🤖 Resposta do LLM: {response.content}")
|
||||
else:
|
||||
print(f"\n🤖 Resposta do LLM (formato desconhecido): {response}")
|
||||
except Exception as e:
|
||||
print(f"\n❌ Ocorreu um erro ao interagir com o LLM: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
app/state.py
Normal file
1
app/state.py
Normal file
@@ -0,0 +1 @@
|
||||
from typing import TypedDict, Annotated, Sequence
|
||||
0
app/tools/__init__.py
Normal file
0
app/tools/__init__.py
Normal file
Reference in New Issue
Block a user