Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import json
|
3 |
import operator
|
4 |
import streamlit as st
|
|
|
5 |
from typing import TypedDict, Annotated, Sequence
|
6 |
from langchain_openai import ChatOpenAI
|
7 |
from langchain_core.tools import tool
|
@@ -16,6 +17,7 @@ model = ChatOpenAI(temperature=0)
|
|
16 |
|
17 |
@tool
|
18 |
def multiply(first_number: int, second_number: int):
|
|
|
19 |
return first_number * second_number
|
20 |
|
21 |
model_with_tools = model.bind(tools=[convert_to_openai_tool(multiply)])
|
@@ -70,8 +72,6 @@ with tab1:
|
|
70 |
output = app_graph.invoke({"messages": [question]})
|
71 |
st.success(output['messages'][-1])
|
72 |
|
73 |
-
st.info("The app intelligently routes queries through a graph.")
|
74 |
-
|
75 |
with tab2:
|
76 |
st.subheader("General Query")
|
77 |
user_input = st.text_input("Enter your question here")
|
@@ -85,5 +85,4 @@ with tab2:
|
|
85 |
except Exception as e:
|
86 |
st.error("Something went wrong. Try again!")
|
87 |
else:
|
88 |
-
st.warning("Please enter a valid input.")
|
89 |
-
|
|
|
2 |
import json
|
3 |
import operator
|
4 |
import streamlit as st
|
5 |
+
from dotenv import load_dotenv
|
6 |
from typing import TypedDict, Annotated, Sequence
|
7 |
from langchain_openai import ChatOpenAI
|
8 |
from langchain_core.tools import tool
|
|
|
17 |
|
18 |
@tool
|
19 |
def multiply(first_number: int, second_number: int):
|
20 |
+
"""Multiplies two numbers together and returns the result."""
|
21 |
return first_number * second_number
|
22 |
|
23 |
model_with_tools = model.bind(tools=[convert_to_openai_tool(multiply)])
|
|
|
72 |
output = app_graph.invoke({"messages": [question]})
|
73 |
st.success(output['messages'][-1])
|
74 |
|
|
|
|
|
75 |
with tab2:
|
76 |
st.subheader("General Query")
|
77 |
user_input = st.text_input("Enter your question here")
|
|
|
85 |
except Exception as e:
|
86 |
st.error("Something went wrong. Try again!")
|
87 |
else:
|
88 |
+
st.warning("Please enter a valid input.")
|
|