tharungajula2 commited on
Commit
12a37a6
·
1 Parent(s): 5ea55bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -13
app.py CHANGED
@@ -1,37 +1,51 @@
1
- #Hello! It seems like you want to import the Streamlit library in Python. Streamlit is a powerful open-source framework used for building web applications with interactive data visualizations and machine learning models. To import Streamlit, you'll need to ensure that you have it installed in your Python environment.
2
- #Once you have Streamlit installed, you can import it into your Python script using the import statement,
 
3
 
4
  import streamlit as st
5
-
6
-
7
  from langchain.llms import OpenAI
8
 
9
- #Function to return the response
 
 
 
 
10
  def load_answer(question):
11
- llm = OpenAI(model_name="text-davinci-003",temperature=0)
12
- answer=llm(question)
13
  return answer
14
 
 
 
 
15
 
16
- #App UI starts here
17
  st.set_page_config(page_title="Langchain Prototype", page_icon=":robot:")
 
 
18
  st.header("LLM App 1")
19
 
20
- #Gets the user input
21
  def get_text():
22
  input_text = st.text_input("You: ", key="input")
23
  return input_text
24
 
 
 
25
 
26
- user_input=get_text()
27
  response = load_answer(user_input)
28
 
 
29
  submit = st.button('Generate')
30
 
31
- #If generate button is clicked
32
  if submit:
33
-
34
  st.subheader("Answer:")
35
-
36
  st.write(response)
37
 
 
 
 
 
 
 
1
+ # -----------------------------------------
2
+ # LIBRARY IMPORTS AND INTRODUCTION
3
+ # -----------------------------------------
4
 
5
  import streamlit as st
 
 
6
  from langchain.llms import OpenAI
7
 
8
+ # -----------------------------------------
9
+ # FUNCTION DEFINITIONS
10
+ # -----------------------------------------
11
+
12
+ # This function uses the "text-davinci-003" model to generate a response to a given question.
13
  def load_answer(question):
14
+ llm = OpenAI(model_name="text-davinci-003", temperature=0)
15
+ answer = llm(question)
16
  return answer
17
 
18
+ # -----------------------------------------
19
+ # STREAMLIT UI CONFIGURATION
20
+ # -----------------------------------------
21
 
22
+ # Set the Streamlit page title and icon.
23
  st.set_page_config(page_title="Langchain Prototype", page_icon=":robot:")
24
+
25
+ # Display a header for the application.
26
  st.header("LLM App 1")
27
 
28
+ # Function to get text input from the user.
29
  def get_text():
30
  input_text = st.text_input("You: ", key="input")
31
  return input_text
32
 
33
+ # Get the user input.
34
+ user_input = get_text()
35
 
36
+ # Fetch the response from the LLM.
37
  response = load_answer(user_input)
38
 
39
+ # Display a button on the Streamlit page.
40
  submit = st.button('Generate')
41
 
42
+ # Actions for when the 'Generate' button is clicked.
43
  if submit:
 
44
  st.subheader("Answer:")
 
45
  st.write(response)
46
 
47
+ # -----------------------------------------
48
+ # END OF STREAMLIT APPLICATION
49
+ # -----------------------------------------
50
+
51
+