Spaces:
Sleeping
Sleeping
Create app.py
Browse files12345678910111213141516171819202122232425262728293031323334353637### Q&A Chatbot ###
import osimport streamlit as stfrom langchain_openai import ChatOpenAIfrom langchain.prompts.chat import ChatPromptTemplate
## Load Anthropic model and get response
def get_openai_response(question): 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([ ("system", system_template), ("human", user_template) ]) chat_llm = ChatOpenAI(temperature=0.5) chain = chat_prompt | chat_llm return chain.invoke(question).content ## Initialize Streamlit app
st.set_page_config(page_title="Simple Langchain App")st.header("Coder Q&A Demo")
input = st.text_input("Input: ", key=input)response = get_openai_response(input)
submit = st.button("Ask your question...")if submit: st.subheader("The response is:") st.write(response)app.pyAdded+37