Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,14 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
from langchain.chat_models import ChatOpenAI
|
| 5 |
-
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
| 6 |
-
|
| 7 |
-
chat = ChatOpenAI(temperature=.7, model='gpt-3.5-turbo')
|
| 8 |
-
|
| 9 |
-
ourChallenge=chat(
|
| 10 |
-
[
|
| 11 |
-
SystemMessage(content="You are an expert in Maths and good at solving challenge. The challenge is to go from starting number to ending number by use of some operators that are available in the game. You should not use add, subtract, multiply and divide operators for solving this challenge. You should use only any of the operators given in the list for solving the challenge. They valid list of operators are sin, cos, tan, asin, acos, atan, log, 10^x, 1/x, x!, xCy, x^y, xPy, x^(1/y), +/-(x). You need to use the output of first step as the input of next step and so on."),
|
| 12 |
-
HumanMessage(content="Starting number is 1. Ending Number is 2. How will you reach from 1 to 2 and give each step for the calculations arrived"),
|
| 13 |
-
AIMessage(content="Step 1: Tan of 1 is 45 degrees. Step 2: Sin of 45 is 1 1/Sqrt(2). Step 3: Inverse of 1/Sqrt(2) is Sqrt(2). Step 4: Square of (Sqrt(2)) is 2"),
|
| 14 |
-
]
|
| 15 |
-
)
|
| 16 |
|
| 17 |
def load_answer(question) :
|
| 18 |
-
|
|
|
|
| 19 |
return answer
|
| 20 |
|
| 21 |
-
|
| 22 |
-
st.set_page_config(page_title="
|
| 23 |
-
st.header("
|
| 24 |
|
| 25 |
#Gets the user input
|
| 26 |
def get_text():
|
|
@@ -30,13 +18,9 @@ def get_text():
|
|
| 30 |
|
| 31 |
user_input=get_text()
|
| 32 |
response = load_answer(user_input)
|
| 33 |
-
|
| 34 |
submit = st.button('Generate')
|
| 35 |
|
| 36 |
#If generate button is clicked
|
| 37 |
if submit:
|
| 38 |
-
|
| 39 |
st.subheader("Answer:")
|
| 40 |
-
|
| 41 |
st.write(response)
|
| 42 |
-
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain.llms import OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def load_answer(question) :
|
| 5 |
+
llm = OpenAI(model_name="text-davinci-003",temperature=0)
|
| 6 |
+
answer = llm(question)
|
| 7 |
return answer
|
| 8 |
|
| 9 |
+
#App UI starts here
|
| 10 |
+
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
| 11 |
+
st.header("LangChain Demo")
|
| 12 |
|
| 13 |
#Gets the user input
|
| 14 |
def get_text():
|
|
|
|
| 18 |
|
| 19 |
user_input=get_text()
|
| 20 |
response = load_answer(user_input)
|
|
|
|
| 21 |
submit = st.button('Generate')
|
| 22 |
|
| 23 |
#If generate button is clicked
|
| 24 |
if submit:
|
|
|
|
| 25 |
st.subheader("Answer:")
|
|
|
|
| 26 |
st.write(response)
|
|
|