Rajagopal commited on
Commit
d6f7726
·
1 Parent(s): 1b38f54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -25,6 +25,7 @@ st.header("Welcome!. Today, What company's sustainability story is inspiring you
25
 
26
  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")
27
 
 
28
  yourquestion = st.text_input('Ask your question on best practices', 'What is Wipro plans for Biodiversity in 2024?')
29
  st.write('Your input is ', yourquestion)
30
 
@@ -40,33 +41,35 @@ llmgpt3 = AzureOpenAI( deployment_name="testdavanci", model_name="text-davi
40
  #llmchatgpt = AzureOpenAI( deployment_name="esujnand", model_name="gpt-35-turbo" )
41
 
42
 
43
- if myurl:
44
- index = None
45
- loader1 = PyPDFLoader(myurl)
46
- langchainembeddings = OpenAIEmbeddings(deployment="textembedding", chunk_size=1)
47
-
48
- index = VectorstoreIndexCreator(
49
- # split the documents into chunks
50
- text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0),
51
- # select which embeddings we want to use
52
- embedding=langchainembeddings,
53
- # use Chroma as the vectorestore to index and search embeddings
54
- vectorstore_cls=Chroma
55
- ).from_loaders([loader1])
56
-
57
- st.write("loaded")
58
 
 
59
 
 
 
60
 
61
- if yourquestion:
62
- answer = index.query(llm=llmgpt3, question=yourquestion, chain_type="map_reduce")
63
- st.write(answer)
 
 
 
 
64
 
 
 
 
 
 
 
 
 
 
 
65
 
66
-
67
 
68
-
69
-
70
 
 
 
 
71
 
72
-
 
25
 
26
  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")
27
 
28
+
29
  yourquestion = st.text_input('Ask your question on best practices', 'What is Wipro plans for Biodiversity in 2024?')
30
  st.write('Your input is ', yourquestion)
31
 
 
41
  #llmchatgpt = AzureOpenAI( deployment_name="esujnand", model_name="gpt-35-turbo" )
42
 
43
 
44
+ with st.form("my_form"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ 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")
47
 
48
+ yourquestion = st.text_input('Ask your question on best practices', 'What is Wipro plans for Biodiversity in 2024?')
49
+ st.write('Your input is ', yourquestion)
50
 
51
+ # Every form must have a submit button.
52
+ submitted = st.form_submit_button("Ask question")
53
+ if submitted:
54
+ if myurl:
55
+ index = None
56
+ loader1 = PyPDFLoader(myurl)
57
+ langchainembeddings = OpenAIEmbeddings(deployment="textembedding", chunk_size=1)
58
 
59
+ index = VectorstoreIndexCreator(
60
+ # split the documents into chunks
61
+ text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0),
62
+ # select which embeddings we want to use
63
+ embedding=langchainembeddings,
64
+ # use Chroma as the vectorestore to index and search embeddings
65
+ vectorstore_cls=Chroma
66
+ ).from_loaders([loader1])
67
+
68
+ st.write("loaded")
69
 
 
70
 
 
 
71
 
72
+ if yourquestion:
73
+ answer = index.query(llm=llmgpt3, question=yourquestion, chain_type="map_reduce")
74
+ st.write(answer)
75