File size: 2,371 Bytes
13b193b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a05ca56
13b193b
 
a05ca56
13b193b
 
0ea7645
13b193b
0620e33
 
 
 
 
 
00f5ccf
0620e33
 
 
 
0ea7645
 
0620e33
1b38f54
0620e33
 
a05ca56
f414072
 
12fdec6
 
 
 
 
 
 
 
 
 
1b38f54
12fdec6
 
0620e33
0ea7645
a05ca56
 
13b193b
1b38f54
13b193b
a05ca56
13b193b
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
from langchain.chains import RetrievalQA
from langchain.llms import AzureOpenAI
from langchain.document_loaders import TextLoader
from langchain.document_loaders import PyPDFLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.text_splitter import CharacterTextSplitter
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.chains.question_answering import load_qa_chain
from langchain.llms import AzureOpenAI
from langchain.chains.question_answering import load_qa_chain
import streamlit as st
from PIL import Image
import time

image = Image.open('Wipro logo.png')
st.image(image)

st.title("Wipro impact | The inquisitive sustainability leader:  Learn some of the best practices in sustainability from success stories of leading companies.. ")


st.header("Welcome!. Today, What company's sustainability story is inspiring you ?.. ")


myurl = st.text_input("Give the URL to find a sustainability or annual report", "https://www.wipro.com/content/dam/nexus/en/sustainability/sustainability_reports/wipro-sustainability-report-fy-2021-22.pdf")

yourquestion = st.text_input('Ask your question on best practices', 'What is Wipro plans for Biodiversity in 2024?')
st.write('Your input is ', yourquestion)

aimethod = st.radio(
    "Choose a AI brain",
    ('GPT3', 'GPT3.5' ), index=1)


os.environ['OPENAI_API_TYPE'] = 'azure'
os.environ['OPENAI_API_VERSION'] = '2023-03-15-preview'

llmgpt3 = AzureOpenAI(      deployment_name="testdavanci", model_name="text-davinci-003" )
#llmchatgpt = AzureOpenAI(     deployment_name="esujnand", model_name="gpt-35-turbo" )


if myurl:
    index = None
    loader1 = PyPDFLoader(myurl)
    langchainembeddings = OpenAIEmbeddings(deployment="textembedding", chunk_size=1)

    index = VectorstoreIndexCreator(
            # split the documents into chunks
            text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0),
            # select which embeddings we want to use
            embedding=langchainembeddings,
            # use Chroma as the vectorestore to index and search embeddings
            vectorstore_cls=Chroma
        ).from_loaders([loader1])
        
    st.write("loaded")



if yourquestion:
  answer = index.query(llm=llmgpt3, question=yourquestion, chain_type="map_reduce")
  st.write(answer)