Spaces:
Runtime error
Runtime error
Commit
·
4256967
1
Parent(s):
eb91c06
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- README.md +3 -9
- app.py +39 -0
- docs/course.docx +3 -0
- docs/pmo_documents_AEuDTO53.md +0 -0
- index.json +3 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ 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 |
+
docs/course.docx filter=lfs diff=lfs merge=lfs -text
|
37 |
+
index.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji: 🚀
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: red
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.36.1
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: PMO_Documents_AI_Chatbot
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 3.35.2
|
6 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
2 |
+
from langchain.chat_models import ChatOpenAI
|
3 |
+
import gradio as gr
|
4 |
+
import sys
|
5 |
+
import os
|
6 |
+
|
7 |
+
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
|
8 |
+
|
9 |
+
def construct_index(directory_path):
|
10 |
+
max_input_size = 4096
|
11 |
+
num_outputs = 512
|
12 |
+
max_chunk_overlap = 20
|
13 |
+
chunk_size_limit = 600
|
14 |
+
|
15 |
+
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
|
16 |
+
|
17 |
+
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
|
18 |
+
|
19 |
+
documents = SimpleDirectoryReader(directory_path).load_data()
|
20 |
+
|
21 |
+
index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
|
22 |
+
|
23 |
+
index.save_to_disk('index.json')
|
24 |
+
|
25 |
+
return index
|
26 |
+
|
27 |
+
def chatbot(input_text):
|
28 |
+
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
29 |
+
response = index.query(input_text, response_mode="compact")
|
30 |
+
return response.response
|
31 |
+
|
32 |
+
iface = gr.Interface(fn=chatbot,
|
33 |
+
inputs=gr.components.Textbox(lines=5, label="Enter your text", show_copy_button=True),
|
34 |
+
outputs=gr.components.Textbox(lines=5, label="Answer", show_copy_button=True),
|
35 |
+
examples=["What are the different types of 'work product' lifespan? Provide detailed answer", "Хто може бути наставником?", "Question3", "Question4", "Question5"],
|
36 |
+
title="PMO Documents AI Chatbot")
|
37 |
+
|
38 |
+
index = construct_index("docs")
|
39 |
+
iface.launch()
|
docs/course.docx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:06634e0fc61efed338f2a6613fc5db276aca750fd0d71d841ca464d89356d11b
|
3 |
+
size 8404625
|
docs/pmo_documents_AEuDTO53.md
ADDED
The diff for this file is too large to render.
See raw diff
|
|
index.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca04670038605b91b0b0dfddcb4c8378d760ca576b022142c163757458b827ad
|
3 |
+
size 123040415
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gpt_index==0.4.24
|
2 |
+
langchain==0.0.118
|
3 |
+
PyPDF2==3.0.1
|
4 |
+
pycryptodome==3.18.0
|
5 |
+
docx2txt==0.8
|