Hackoor commited on
Commit
1c5daa7
1 Parent(s): 00697cb

Upload 10 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ trainingData/Environment[[:space:]]Protection[[:space:]]Act.pdf filter=lfs diff=lfs merge=lfs -text
37
+ trainingData/Highway[[:space:]]Traffic[[:space:]]Act.pdf filter=lfs diff=lfs merge=lfs -text
38
+ trainingData/Water[[:space:]]Resource[[:space:]]Act.pdf filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader, LLMPredictor, ServiceContext, StorageContext, load_index_from_storage
2
+ from langchain import OpenAI
3
+ import gradio
4
+ import os
5
+
6
+ os.environ["OPENAI_API_KEY"] = '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'
7
+
8
+ def construct_index(directory_path):
9
+ num_outputs = 512
10
+
11
+ _llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
12
+
13
+ service_context = ServiceContext.from_defaults(llm_predictor=_llm_predictor)
14
+
15
+ docs = SimpleDirectoryReader(directory_path).load_data()
16
+
17
+ index = GPTVectorStoreIndex.from_documents(docs, service_context=service_context)
18
+
19
+ index.storage_context.persist(persist_dir="indexes")
20
+
21
+ return index
22
+
23
+ def chatbot(input_text):
24
+
25
+ storage_context = StorageContext.from_defaults(persist_dir="indexes")
26
+
27
+ query_engne = load_index_from_storage(storage_context).as_query_engine()
28
+
29
+ response = query_engne.query(input_text)
30
+
31
+ return response.response
32
+
33
+ iface = gradio.Interface(fn=chatbot,
34
+ inputs=gradio.inputs.Textbox(lines=4, label="Enter your question here"),
35
+ outputs=gradio.outputs.Textbox(label="Generated Text"),
36
+ title="My Custom trained AI Chatbot")
37
+
38
+ index = construct_index("trainingData")
39
+
40
+ iface.launch()
trainingData/.DS_Store ADDED
Binary file (6.15 kB). View file
 
trainingData/Endangered Species Act.pdf ADDED
Binary file (474 kB). View file
 
trainingData/Environment Protection Act.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a035f8bc013734aeff419ea2579d6fb2b4916e49359a2715241948448096d0aa
3
+ size 1557709
trainingData/Highway Traffic Act.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:133d4cf0c34f5f51c7a61bd4c0838bcccf10e5b514772e5083876e95089f2e0d
3
+ size 2533591
trainingData/Legislation Act.pdf ADDED
Binary file (345 kB). View file
 
trainingData/Nutrient Management Act.pdf ADDED
Binary file (397 kB). View file
 
trainingData/Pesticides Act.pdf ADDED
Binary file (508 kB). View file
 
trainingData/Safe Drinking Water Act.pdf ADDED
Binary file (798 kB). View file
 
trainingData/Water Resource Act.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20be8b2476df8ca3e2eb97568d1c2bba9c9dd2275d126234e10f6f83827761a2
3
+ size 1088838