FastApiAssistant #2
| @@ -6,12 +6,12 @@ from google.oauth2.credentials import Credentials | |||||||
| from google_auth_oauthlib.flow import InstalledAppFlow | from google_auth_oauthlib.flow import InstalledAppFlow | ||||||
| from google.auth.transport.requests import Request | from google.auth.transport.requests import Request | ||||||
| from googleapiclient.discovery import build | from googleapiclient.discovery import build | ||||||
| from ..rag.split_docs import load_split_docs | from app.rag.split_docs import load_split_docs | ||||||
| from ..rag.llm import load_llm_openai | from app.rag.llm import load_llm_openai | ||||||
| from ..rag.embeddings import load_embeddins | from app.rag.embeddings import load_embeddins | ||||||
| from ..rag.retriever import create_retriever | from app.rag.retriever import create_retriever | ||||||
| from ..rag.vectorstore import create_verctorstore | from app.rag.vectorstore import create_verctorstore | ||||||
| from ..rag.rag_chain import create_rag_chain | from app.rag.rag_chain import create_rag_chain | ||||||
| import pytz | import pytz | ||||||
| import telebot | import telebot | ||||||
| import os | import os | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ from langchain_community.tools.gmail.utils import ( | |||||||
|     get_gmail_credentials) |     get_gmail_credentials) | ||||||
| from langchain_community.agent_toolkits import GmailToolkit | from langchain_community.agent_toolkits import GmailToolkit | ||||||
|  |  | ||||||
| from .langchain_tools.agent_tools import ( | from app.langchain_tools.agent_tools import ( | ||||||
|     redact_email, |     redact_email, | ||||||
|     list_calendar_events, |     list_calendar_events, | ||||||
|     create_calendar_event, |     create_calendar_event, | ||||||
| @@ -155,6 +155,20 @@ async def process_text(request: Request): | |||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     import uvicorn |     config = {"configurable": {"thread_id": "thread-1", "recursion_limit": 50}} | ||||||
|  |  | ||||||
|     uvicorn.run(app, host="0.0.0.0", port=8000) |     while True: | ||||||
|  |         user_input = input("User: ") | ||||||
|  |         if user_input.lower() in ["quit", "exit", "q"]: | ||||||
|  |             print("Goodbye!") | ||||||
|  |             break | ||||||
|  |  | ||||||
|  |         events = graph.stream({ | ||||||
|  |             "messages": [("user", user_input)], | ||||||
|  |             "is_last_step": False}, | ||||||
|  |                               config, stream_mode="updates") | ||||||
|  |  | ||||||
|  |         for event in events: | ||||||
|  |             if "agent" in event: | ||||||
|  |                 print( | ||||||
|  |                     f"\nAsistente: {event['agent']['messages'][-1].content}\n") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user