File size: 756 Bytes
06cdf22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Chatbot
from langchain_community.llms import OpenAI

from dotenv import load_dotenv
load_dotenv() #take environment variable from .env

import streamlit as st
import os

## function to load OpenAI model and get reponses

def response(question):
    llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name="gpt-3.5-turbo-instruct",temperature=0.6)
    res= llm(question)
    return res
# streamlit

st.set_page_config(page_title="Question Answering App")
st.header("Langchain Question Answering App")

input = st.text_input("Input: ",key="input")
res=response(input)

submit = st.button("Ask the Question")

# when button is clicked, we should get response

if submit:
    st.subheader("RESPONSE:")
    st.write(res)