Spaces:
Runtime error
Runtime error
Duplicate from Saurabh46/MyChatGPT-DEMO
Browse filesCo-authored-by: Dubey <[email protected]>
- .gitattributes +38 -0
- README.md +13 -0
- app.py +40 -0
- requirements.txt +3 -0
- trainingData/.DS_Store +0 -0
- trainingData/Endangered Species Act.pdf +0 -0
- trainingData/Environment Protection Act.pdf +3 -0
- trainingData/Highway Traffic Act.pdf +3 -0
- trainingData/Legislation Act.pdf +0 -0
- trainingData/Nutrient Management Act.pdf +0 -0
- trainingData/Pesticides Act.pdf +0 -0
- trainingData/Safe Drinking Water Act.pdf +0 -0
- trainingData/Water Resource Act.pdf +3 -0
.gitattributes
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz 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 |
+
Highway[[:space:]]Traffic[[:space:]]Act.pdf filter=lfs diff=lfs merge=lfs -text
|
37 |
+
trainingData/Environment[[:space:]]Protection[[: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
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: MyChatGPT DEMO
|
3 |
+
emoji: ⚡
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.39.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: Saurabh46/MyChatGPT-DEMO
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
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()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gpt-index
|
2 |
+
pypdf
|
3 |
+
nltk
|
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
|