Spaces:
Sleeping
Sleeping
Wenye He
commited on
Commit
·
ceb3cc0
1
Parent(s):
8153a1a
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -13,10 +13,21 @@ import uuid
|
|
| 13 |
|
| 14 |
from huggingface_hub import HfApi, snapshot_download
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Configuration
|
| 18 |
-
VECTOR_STORE_DIR = "./vector_stores"
|
| 19 |
-
EMBED_MODEL_PATH = "./datas/bge_onnx"
|
| 20 |
CONFIG_PATH = "config.json"
|
| 21 |
|
| 22 |
DEFAULT_LLM = "Jatin19K/unsloth-q5_k_m-mistral-nemo-instruct-2407"
|
|
@@ -45,7 +56,7 @@ local_dir = snapshot_download(
|
|
| 45 |
)
|
| 46 |
|
| 47 |
EMBED_MODEL_PATH = os.path.join(local_dir, "bge_onnx")
|
| 48 |
-
|
| 49 |
|
| 50 |
class ModelManager:
|
| 51 |
def __init__(self):
|
|
@@ -239,11 +250,11 @@ def chat_response(message, history, llm_choice, vector_store_choice, session_sta
|
|
| 239 |
|
| 240 |
# bot_message = f"{response.response}\n\nSources:\n" + "\n".join(sources)
|
| 241 |
bot_message = f"{response.response}\n"
|
| 242 |
-
return history + [(message, bot_message)], session_state
|
| 243 |
# return history + [(message)], session_state
|
| 244 |
|
| 245 |
except Exception as e:
|
| 246 |
-
return history + [(message, f"Error: {str(e)}")], session_state
|
| 247 |
|
| 248 |
# Gradio interface with embedding status
|
| 249 |
with gr.Blocks(title="De-KCIB(Deep Knowledge Center for Injury Biomechanics)") as demo:
|
|
@@ -258,7 +269,8 @@ with gr.Blocks(title="De-KCIB(Deep Knowledge Center for Injury Biomechanics)") a
|
|
| 258 |
# alt="Company Logo"
|
| 259 |
# style="height: 100px; object-fit: contain;">
|
| 260 |
# """)
|
| 261 |
-
gr.
|
|
|
|
| 262 |
# gr.Markdown("<img src='file/logo.png' alt='Company Logo' />")
|
| 263 |
with gr.Row():
|
| 264 |
gr.Markdown("# De-KCIB(Deep Knowledge Center for Injury Biomechanics)")
|
|
@@ -299,7 +311,7 @@ with gr.Blocks(title="De-KCIB(Deep Knowledge Center for Injury Biomechanics)") a
|
|
| 299 |
msg.submit(
|
| 300 |
chat_response,
|
| 301 |
[msg, chatbot, llm_dropdown, vector_dropdown, session_state],
|
| 302 |
-
[chatbot, session_state] # <-- Update outputs
|
| 303 |
)
|
| 304 |
|
| 305 |
clear_btn.click(
|
|
@@ -311,5 +323,5 @@ with gr.Blocks(title="De-KCIB(Deep Knowledge Center for Injury Biomechanics)") a
|
|
| 311 |
|
| 312 |
# Deployment settings
|
| 313 |
if __name__ == "__main__":
|
| 314 |
-
demo.launch()
|
| 315 |
# demo.launch(share=True)
|
|
|
|
| 13 |
|
| 14 |
from huggingface_hub import HfApi, snapshot_download
|
| 15 |
|
| 16 |
+
from gradio.themes.utils import colors, fonts, sizes
|
| 17 |
+
from gradio.themes import Base
|
| 18 |
+
|
| 19 |
+
# Create a custom theme with larger text
|
| 20 |
+
large_text_theme = Base(
|
| 21 |
+
# Increase all font sizes by ~25%
|
| 22 |
+
font=[fonts.GoogleFont("Roboto"), "ui-sans-serif", "sans-serif"],
|
| 23 |
+
font_mono=[fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace"],
|
| 24 |
+
text_size=sizes.text_lg, # Base text size (default is text_md)
|
| 25 |
+
radius_size=sizes.radius_md,
|
| 26 |
+
)
|
| 27 |
|
| 28 |
# Configuration
|
| 29 |
+
# VECTOR_STORE_DIR = "./vector_stores"
|
| 30 |
+
# EMBED_MODEL_PATH = "./datas/bge_onnx"
|
| 31 |
CONFIG_PATH = "config.json"
|
| 32 |
|
| 33 |
DEFAULT_LLM = "Jatin19K/unsloth-q5_k_m-mistral-nemo-instruct-2407"
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
EMBED_MODEL_PATH = os.path.join(local_dir, "bge_onnx")
|
| 59 |
+
VECTOR_STORE_DIR = os.path.join(local_dir, "vector_stores")
|
| 60 |
|
| 61 |
class ModelManager:
|
| 62 |
def __init__(self):
|
|
|
|
| 250 |
|
| 251 |
# bot_message = f"{response.response}\n\nSources:\n" + "\n".join(sources)
|
| 252 |
bot_message = f"{response.response}\n"
|
| 253 |
+
return history + [(message, bot_message)], session_state, ""
|
| 254 |
# return history + [(message)], session_state
|
| 255 |
|
| 256 |
except Exception as e:
|
| 257 |
+
return history + [(message, f"Error: {str(e)}")], session_state, ""
|
| 258 |
|
| 259 |
# Gradio interface with embedding status
|
| 260 |
with gr.Blocks(title="De-KCIB(Deep Knowledge Center for Injury Biomechanics)") as demo:
|
|
|
|
| 269 |
# alt="Company Logo"
|
| 270 |
# style="height: 100px; object-fit: contain;">
|
| 271 |
# """)
|
| 272 |
+
gr.Markdown("<img src='/gradio_api/file/logo.png' alt='Innovision Logo' height='150' width='390'>")
|
| 273 |
+
# gr.HTML("<img src='https://www.ussbchamber.org/wp-content/uploads/2021/04/innovisionlogo.png' />")
|
| 274 |
# gr.Markdown("<img src='file/logo.png' alt='Company Logo' />")
|
| 275 |
with gr.Row():
|
| 276 |
gr.Markdown("# De-KCIB(Deep Knowledge Center for Injury Biomechanics)")
|
|
|
|
| 311 |
msg.submit(
|
| 312 |
chat_response,
|
| 313 |
[msg, chatbot, llm_dropdown, vector_dropdown, session_state],
|
| 314 |
+
[chatbot, session_state, msg] # <-- Update outputs
|
| 315 |
)
|
| 316 |
|
| 317 |
clear_btn.click(
|
|
|
|
| 323 |
|
| 324 |
# Deployment settings
|
| 325 |
if __name__ == "__main__":
|
| 326 |
+
demo.launch(allowed_paths=["logo.png"])
|
| 327 |
# demo.launch(share=True)
|
logo.png
ADDED
|