Spaces:
Runtime error
Runtime error
Commit ·
de6d3f6
1
Parent(s): f010056
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +2 -8
- app.py +39 -0
- docs/RFID1.docx +3 -0
- index.json +0 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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/RFID1.docx filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
colorFrom: gray
|
| 5 |
-
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.45.2
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: OperativeIQ_Demo
|
| 3 |
+
app_file: app.py
|
|
|
|
|
|
|
| 4 |
sdk: gradio
|
| 5 |
sdk_version: 3.45.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 = 30
|
| 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)
|
| 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="OperativeIQ RFID Training AI Chatbot")
|
| 37 |
+
|
| 38 |
+
index = construct_index("docs")
|
| 39 |
+
iface.launch()
|
docs/RFID1.docx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a47cfde7c15155fbb5ce282da39b34f840882b566d9305b7053bfbb904d55f9
|
| 3 |
+
size 2021432
|
index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
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
|