Spaces:
Sleeping
Sleeping
Download src/streamlit_app.py from Yug95/QueryResponse: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/Yug95/QueryResponse/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/Yug95/QueryResponse/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/Yug95/QueryResponse/resolve/main/src/streamlit_app.py
725 Bytes
| from langchain_openai import ChatOpenAI | |
| from langchain_core.prompts import PromptTemplate | |
| from langchain_core.output_parsers import StrOutputParser | |
| import os | |
| import streamlit as st | |
| api_key = os.getenv("OPENAI_API_KEY") | |
| print(api_key) | |
| st.title("Query Response APP") | |
| llm = ChatOpenAI(openai_api_key=api_key) | |
| prompt = PromptTemplate( | |
| template= 'Please write your query : {Query}', | |
| input_variables=['Query'] | |
| ) | |
| parser = StrOutputParser() | |
| chain = prompt | llm | parser | |
| Query = st.text_input("Query: ", key="Query") | |
| submit = st.button("Ask the question") | |
| # Query = 'What is the capital of India' | |
| if submit: | |
| response = chain.invoke({'Query':Query}) | |
| st.subheader('the response is') | |
| st.write(response) |