Spaces:
Sleeping
Sleeping
Download chat_openai.py from argodevops/demo: direct link, hf CLI and curl.
- Browser
- Download file 640 Bytes
-
https://huggingface.co/spaces/argodevops/demo/resolve/main/chat_openai.py
- Command line
-
hf download hf://spaces/argodevops/demo/chat_openai.py
-
curl -L -o chat_openai.py https://huggingface.co/spaces/argodevops/demo/resolve/main/chat_openai.py
640 Bytes
| import streamlit as st | |
| from langchain.llms import OpenAI | |
| st.title('🦜🔗 Quickstart OpenAI App') | |
| openai_api_key = st.sidebar.text_input('OpenAI API Key', type='password') | |
| def generate_response(input_text): | |
| llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key) | |
| st.info(llm(input_text)) | |
| with st.form('my_form'): | |
| text = st.text_area('Enter text:', 'Ask me a question?') | |
| submitted = st.form_submit_button('Submit') | |
| if not openai_api_key.startswith('sk-'): | |
| st.warning('Please enter your OpenAI API key!', icon='⚠') | |
| if submitted and openai_api_key.startswith('sk-'): | |
| generate_response(text) |