try556 / app.py
Rajagopal's picture
Update app.py
314c283
import streamlit as st
from langchain import OpenAI, PromptTemplate, LLMChain
from langchain.text_splitter import CharacterTextSplitter
from langchain.chains.mapreduce import MapReduceChain
from langchain.prompts import PromptTemplate
from langchain.chat_models import AzureChatOpenAI
from langchain.chains.summarize import load_summarize_chain
from langchain.chains import AnalyzeDocumentChain
from PyPDF2 import PdfReader
from langchain.document_loaders import TextLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.document_loaders import PyPDFLoader
import os
import openai
from PIL import Image
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"
openai.api_type = "azure"
openai.api_base = "https://embeddinguseopenai.openai.azure.com/"
openai.api_version = "2023-03-15-preview"
openai.api_key = os.environ["OPENAI_API_KEY"]
image = Image.open('Wipro logo.png')
st.image(image)
st.title("Ask anything on CSRD or Wipro sustainability report")
st.subheader("Type your question here ")
yourquestion = st.text_input('Your topic', 'What is Wipro doing on biodiversity?')
st.write('Your input is ', yourquestion)
if st.button("Ask Questions "):
template = """
You are an AI assistant.
{concept}
"""
response = openai.ChatCompletion.create(
engine="gpt-35-turbo",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":yourquestion}],
temperature=0,
max_tokens=800,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None)
# Run the chain only specifying the input variable.
st.write(response)