Couple small code changes for LangServe walkthrough

This commit is contained in:
Cole Medin
2024-08-30 12:41:06 -05:00
parent af684be17e
commit b3438810d7
4 changed files with 11 additions and 9 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -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():