AndyWodecki commited on
Commit
b9f8e90
·
1 Parent(s): 22ed226

simple langchain app

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1,4 +1,22 @@
1
  import streamlit as st
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from langchain.llms import OpenAI
3
 
4
+ st.title("🦜🔗 Langchain Quickstart App")
5
+
6
+ with st.sidebar:
7
+ openai_api_key = st.text_input("OpenAI API Key", type="password")
8
+ "[Get an OpenAI API key](https://platform.openai.com/account/api-keys)"
9
+
10
+
11
+ def generate_response(input_text):
12
+ llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key)
13
+ st.info(llm(input_text))
14
+
15
+
16
+ with st.form("my_form"):
17
+ text = st.text_area("Enter text:", "What are 3 key advice for learning how to code?")
18
+ submitted = st.form_submit_button("Submit")
19
+ if not openai_api_key:
20
+ st.info("Please add your OpenAI API key to continue.")
21
+ elif submitted:
22
+ generate_response(text)