Spaces:
Sleeping
Sleeping
Update app.py
Browse files7 unmodified lines891011111213141 unmodified line16171819192021225 unmodified lines28293031323332343536377 unmodified lines
## Load Anthropic model and get response
def get_openai_response(question):def get_openai_response(question, api_key): system_template = "You are a helpful coder assistant. When the user asks a question, your task is to write simple Python codes." user_template = "{question}" chat_prompt = ChatPromptTemplate.from_messages([1 unmodified line ("human", user_template) ]) chat_llm = ChatOpenAI(temperature=0.5) chat_llm = ChatOpenAI(temperature=0.5, openai_api_key=api_key) chain = chat_prompt | chat_llm 5 unmodified linesst.set_page_config(page_title="Simple Langchain App")st.header("Coder Q&A Demo")
OPENAI_API_KEY = st.text_input("OpenAI API Key: ", type="password")
input = st.text_input("Input: ", key=input)response = get_openai_response(input)response = get_openai_response(input, api_key=OPENAI_API_KEY)
submit = st.button("Ask your question...")if submit:app.py+5-3