Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import pickle
|
| 4 |
import os
|
| 5 |
-
from llama_index.core import StorageContext, load_index_from_storage,
|
| 6 |
from llama_index.llms.huggingface import HuggingFaceInferenceAPI
|
| 7 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 8 |
from dotenv import load_dotenv
|
|
@@ -19,7 +19,7 @@ with open('feature_columns.pkl', 'rb') as col_file:
|
|
| 19 |
feature_columns = pickle.load(col_file)
|
| 20 |
|
| 21 |
# Configure the Llama index settings for the PDF Reader
|
| 22 |
-
|
| 23 |
model_name="google/gemma-1.1-7b-it",
|
| 24 |
tokenizer_name="google/gemma-1.1-7b-it",
|
| 25 |
context_window=3000,
|
|
@@ -27,7 +27,7 @@ HuggingFaceInferenceAPI = HuggingFaceInferenceAPI(
|
|
| 27 |
max_new_tokens=512,
|
| 28 |
generate_kwargs={"temperature": 0.1}
|
| 29 |
)
|
| 30 |
-
|
| 31 |
|
| 32 |
# Define the directory for persistent storage and data
|
| 33 |
PERSIST_DIR = "./db"
|
|
@@ -165,11 +165,10 @@ with gr.Blocks() as demo:
|
|
| 165 |
# Define button actions
|
| 166 |
predict_button.click(fn=predict_status,
|
| 167 |
inputs=[air_temp, proc_temp, speed, torque, tool_wear],
|
| 168 |
-
outputs=[output_status
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
inputs=gr.Variable("reasons"),
|
| 173 |
outputs=response_box)
|
| 174 |
|
| 175 |
# Display the PDF content
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import pickle
|
| 4 |
import os
|
| 5 |
+
from llama_index.core import StorageContext, load_index_from_storage, ChatPromptTemplate
|
| 6 |
from llama_index.llms.huggingface import HuggingFaceInferenceAPI
|
| 7 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 8 |
from dotenv import load_dotenv
|
|
|
|
| 19 |
feature_columns = pickle.load(col_file)
|
| 20 |
|
| 21 |
# Configure the Llama index settings for the PDF Reader
|
| 22 |
+
hf_api = HuggingFaceInferenceAPI(
|
| 23 |
model_name="google/gemma-1.1-7b-it",
|
| 24 |
tokenizer_name="google/gemma-1.1-7b-it",
|
| 25 |
context_window=3000,
|
|
|
|
| 27 |
max_new_tokens=512,
|
| 28 |
generate_kwargs={"temperature": 0.1}
|
| 29 |
)
|
| 30 |
+
hf_embedding = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
| 31 |
|
| 32 |
# Define the directory for persistent storage and data
|
| 33 |
PERSIST_DIR = "./db"
|
|
|
|
| 165 |
# Define button actions
|
| 166 |
predict_button.click(fn=predict_status,
|
| 167 |
inputs=[air_temp, proc_temp, speed, torque, tool_wear],
|
| 168 |
+
outputs=[output_status])
|
| 169 |
|
| 170 |
+
submit_btn.click(fn=handle_query,
|
| 171 |
+
inputs=chat_box,
|
|
|
|
| 172 |
outputs=response_box)
|
| 173 |
|
| 174 |
# Display the PDF content
|