Spaces:
Sleeping
Sleeping
| # q & a chatbot | |
| from langchain.llms import OpenAI | |
| from dotenv import load_dotenv | |
| import streamlit as st | |
| import os | |
| load_dotenv() # take environment variables from .env | |
| # lets make a function for calling the llm | |
| def get_openai_response(question): | |
| llm = OpenAI(openai_api_key="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", temperature=0.6) | |
| response = llm(question) | |
| return response | |
| # Streamlit app | |
| st.header("Langchain Application") | |
| input_question = st.text_input("input : ", key="input") | |
| # if ask button is clicked | |
| if st.button("Ask the question"): | |
| response = get_openai_response(input_question) | |
| st.subheader("the response is") | |
| st.write(response) | |