Spaces:
Sleeping
Sleeping
myrandagoestospace
commited on
Commit
Β·
8e5ac00
1
Parent(s):
5f700b0
create my new app
Browse files- app.py +23 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from langchain_openai.chat_models import ChatOpenAI
|
3 |
+
|
4 |
+
st.title("π¦π Quickstart App")
|
5 |
+
|
6 |
+
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
|
7 |
+
|
8 |
+
|
9 |
+
def generate_response(input_text):
|
10 |
+
model = ChatOpenAI(temperature=0.7, api_key=openai_api_key)
|
11 |
+
st.info(model.invoke(input_text))
|
12 |
+
|
13 |
+
|
14 |
+
with st.form("my_form"):
|
15 |
+
text = st.text_area(
|
16 |
+
"Enter text:",
|
17 |
+
"What are the three key pieces of advice for learning how to code?",
|
18 |
+
)
|
19 |
+
submitted = st.form_submit_button("Submit")
|
20 |
+
if not openai_api_key.startswith("sk-"):
|
21 |
+
st.warning("Please enter your OpenAI API key!", icon="β ")
|
22 |
+
if submitted and openai_api_key.startswith("sk-"):
|
23 |
+
generate_response(text)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
langchain_openai
|