mirror of
https://github.com/coleam00/ai-agents-masterclass.git
synced 2026-01-19 21:40:32 +00:00
Couple small code changes for LangServe walkthrough
This commit is contained in:
@@ -9,14 +9,12 @@ import os
|
||||
from langchain_core.messages import SystemMessage, AIMessage, HumanMessage, ToolMessage
|
||||
from langserve import RemoteRunnable
|
||||
|
||||
from runnable import get_runnable
|
||||
|
||||
load_dotenv()
|
||||
agent_endpoint_url = os.getenv('AGENT_ENDPOINT_URL', 'http://localhost:8000')
|
||||
|
||||
@st.cache_resource
|
||||
def create_chatbot_instance():
|
||||
return RemoteRunnable(f"{agent_endpoint_url}/invoke/")
|
||||
return RemoteRunnable(agent_endpoint_url)
|
||||
|
||||
chatbot = create_chatbot_instance()
|
||||
|
||||
|
||||
@@ -33,12 +33,11 @@ def main():
|
||||
# Create the Fast API route to invoke the runnable
|
||||
add_routes(
|
||||
app,
|
||||
runnable,
|
||||
path="/invoke",
|
||||
runnable
|
||||
)
|
||||
|
||||
# Start the API
|
||||
uvicorn.run(app, host="localhost", port=8000)
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -4,6 +4,7 @@ langchain==0.2.12
|
||||
langserve==0.2.2
|
||||
uvicorn==0.30.6
|
||||
fastapi==0.112.2
|
||||
gunicorn==23.0.0
|
||||
sse_starlette==2.1.3
|
||||
langchain-anthropic==0.1.22
|
||||
langchain-groq==0.1.5
|
||||
|
||||
@@ -14,8 +14,8 @@ from langchain_anthropic import ChatAnthropic
|
||||
from langchain_core.messages import ToolMessage, AIMessage
|
||||
|
||||
from tools.asana_tools import available_asana_functions
|
||||
from tools.google_drive_tools import available_drive_functions
|
||||
from tools.vector_db_tools import available_vector_db_functions
|
||||
# from tools.google_drive_tools import available_drive_functions
|
||||
# from tools.vector_db_tools import available_vector_db_functions
|
||||
|
||||
load_dotenv()
|
||||
model = os.getenv('LLM_MODEL', 'gpt-4o')
|
||||
@@ -26,7 +26,11 @@ model_mapping = {
|
||||
"groq": ChatGroq
|
||||
}
|
||||
|
||||
available_functions = available_asana_functions | available_drive_functions | available_vector_db_functions
|
||||
# Google Drive and Vector DB tools are not included by default because you'll need a bigger cloud instance (DigitalOcean droplet)
|
||||
# To load the Vector DB and add Google Drive documents to the knowledgebase. You could also use something else like
|
||||
# Pinecone instead of running Chroma locally! Uncomment lines 17 and 18 + replace line 33 with 32 if you want to use these tools.
|
||||
# available_functions = available_asana_functions | available_drive_functions | available_vector_db_functions
|
||||
available_functions = available_asana_functions
|
||||
tools = [tool for _, tool in available_functions.items()]
|
||||
|
||||
for key, chatbot_class in model_mapping.items():
|
||||
|
||||
Reference in New Issue
Block a user