mirror of
https://github.com/aimingmed/aimingmed-ai.git
synced 2026-01-27 09:23:18 +08:00
23 lines
706 B
Python
23 lines
706 B
Python
import streamlit as st
|
|
from langchain.llms import OpenAI
|
|
|
|
st.title("🦜🔗 Langchain Quickstart App")
|
|
|
|
with st.sidebar:
|
|
openai_api_key = st.text_input("OpenAI API Key", type="password")
|
|
"[Get an OpenAI API key](https://platform.openai.com/account/api-keys)"
|
|
|
|
|
|
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:", "What are 3 key advice for learning how to code?")
|
|
submitted = st.form_submit_button("Submit")
|
|
if not openai_api_key:
|
|
st.info("Please add your OpenAI API key to continue.")
|
|
elif submitted:
|
|
generate_response(text)
|