File size: 725 Bytes
29101a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from langchain.llms import OpenAI
from dotenv import load_dotenv
import streamlit as st
import os

load_dotenv() #will load variables from .env-------here we load the openAI api-key

# Function to load OpenAI model 

def get_responses(question):
    llm = OpenAI(openai_api_key=os.getenv('OPENAI_API_KEY'), model = 'text-davinci-003', temperature = 0.6)
    response = llm(question)
    return response
# streamlit app
    
st.set_page_config(page_title='My ChatBot')
st.header('OpenAI gpt-3.5-turbo model')

input = st.text_input('Input: ', key='input')
response = get_responses(input)

submit = st.button('Ask me anything')

# now if query button gets clicked:
if submit:
    st.subheader('Answer:')
    st.write(response)