Rajagopal commited on
Commit
efa79a1
·
0 Parent(s):

Duplicate from Rajagopal/try556

Browse files
Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +117 -0
  4. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: csrd trying
3
+ emoji: 🏆
4
+ colorFrom: yellow
5
+ colorTo: gray
6
+ sdk: streamlit
7
+ sdk_version: 1.21.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: Rajagopal/try556
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain import OpenAI, PromptTemplate, LLMChain
3
+ from langchain.text_splitter import CharacterTextSplitter
4
+ from langchain.chains.mapreduce import MapReduceChain
5
+ from langchain.prompts import PromptTemplate
6
+ from langchain.chat_models import AzureChatOpenAI
7
+ from langchain.chains.summarize import load_summarize_chain
8
+ from langchain.chains import AnalyzeDocumentChain
9
+ from PyPDF2 import PdfReader
10
+ from langchain.document_loaders import TextLoader
11
+ from langchain.indexes import VectorstoreIndexCreator
12
+ from langchain.document_loaders import PyPDFLoader
13
+ import os
14
+ import openai
15
+
16
+
17
+ import os
18
+
19
+
20
+ os.environ["OPENAI_API_TYPE"] = "azure"
21
+ os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"
22
+
23
+ openai.api_type = "azure"
24
+ openai.api_base = "https://embeddinguseopenai.openai.azure.com/"
25
+ openai.api_version = "2023-03-15-preview"
26
+ openai.api_key = os.environ["OPENAI_API_KEY"]
27
+
28
+
29
+
30
+
31
+
32
+ st.title("Wipro demo with azure cognitive ")
33
+
34
+
35
+
36
+
37
+ yourquestion = st.text_input('Your topic', 'netzero')
38
+ st.write('Your input is ', yourquestion)
39
+
40
+
41
+
42
+ if st.button("Ask Questions "):
43
+ template = """
44
+ You are an AI assistant.
45
+ {concept}
46
+ """
47
+
48
+ response = openai.ChatCompletion.create(
49
+ engine="gpt-35-turbo",
50
+ messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":yourquestion}],
51
+ temperature=0,
52
+ max_tokens=800,
53
+ top_p=1,
54
+ frequency_penalty=0,
55
+ presence_penalty=0,
56
+ stop=None)
57
+
58
+ # Run the chain only specifying the input variable.
59
+ st.write(response)
60
+
61
+
62
+ if st.button("Ask Questions Simplify "):
63
+ template = """
64
+ You are an AI assistant.
65
+ {concept}
66
+ """
67
+
68
+ response = openai.ChatCompletion.create(
69
+ engine="gpt-35-turbo",
70
+ messages = [{"role":"system","content":"You are an AI assistant that helps people find information. Please explain the information like i am a five."},{"role":"user","content":yourquestion}],
71
+ temperature=0,
72
+ max_tokens=800,
73
+ top_p=1,
74
+ frequency_penalty=0,
75
+ presence_penalty=0,
76
+ stop=None)
77
+
78
+ # Run the chain only specifying the input variable.
79
+ st.write(response)
80
+
81
+ if st.button("Ask trying here "):
82
+ template = """
83
+ You are an expert on topics of Sustainability, Climate action and UN Sustainable Development Goals.
84
+ Explain the concept of {concept} like i am a five
85
+ """
86
+
87
+ prompt = PromptTemplate(
88
+ input_variables=["concept"],
89
+ template=template,
90
+ )
91
+
92
+
93
+ from langchain.chains import LLMChain
94
+ chain = LLMChain(llm=llm, prompt=prompt)
95
+
96
+ # Run the chain only specifying the input variable.
97
+ st.write(chain.run(yourquestion))
98
+
99
+
100
+
101
+ if st.button("Ask Hindi "):
102
+ template = """
103
+ You are an expert on topics of Sustainability, Climate action and UN Sustainable Development Goals.
104
+ Explain the concept of {concept} in Hindi
105
+ """
106
+
107
+ prompt = PromptTemplate(
108
+ input_variables=["concept"],
109
+ template=template,
110
+ )
111
+
112
+
113
+ from langchain.chains import LLMChain
114
+ chain = LLMChain(llm=llm, prompt=prompt)
115
+
116
+ # Run the chain only specifying the input variable.
117
+ st.write(chain.run(yourquestion))
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ openai
2
+ langchain
3
+ streamlit
4
+ PyPDF2
5
+ tiktoken
6
+ pypdf
7
+ chromadb