# ----------------------------------------- # LIBRARY IMPORTS AND INTRODUCTION # ----------------------------------------- import streamlit as st from langchain.llms import OpenAI # ----------------------------------------- # FUNCTION DEFINITIONS # ----------------------------------------- # This function uses the "text-davinci-003" model to generate a response to a given question. def load_answer(question): llm = OpenAI(model_name="text-davinci-003", temperature=0) answer = llm(question) return answer # ----------------------------------------- # STREAMLIT UI CONFIGURATION # ----------------------------------------- # Set the Streamlit page title and icon. st.set_page_config(page_title="Langchain Prototype", page_icon=":robot:") # Display a header for the application. st.header("LLM App 1") # Function to get text input from the user. def get_text(): input_text = st.text_input("You: ", key="input") return input_text # Get the user input. user_input = get_text() # Fetch the response from the LLM. response = load_answer(user_input) # Display a button on the Streamlit page. submit = st.button('Generate') # Actions for when the 'Generate' button is clicked. if submit: st.subheader("Answer:") st.write(response) # ----------------------------------------- # END OF STREAMLIT APPLICATION # -----------------------------------------