Spaces:
Running
Running
added import
Browse files- src/app.py +8 -14
src/app.py
CHANGED
@@ -1,16 +1,15 @@
|
|
1 |
import os
|
2 |
from pathlib import Path
|
3 |
-
from huggingface_hub import
|
4 |
import gradio as gr
|
5 |
-
from llama_index.core import Settings
|
6 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
7 |
from llama_index.llms.llama_cpp import LlamaCPP
|
8 |
from parse_tabular import create_symptom_index
|
9 |
import json
|
10 |
-
import torch
|
11 |
import psutil
|
12 |
-
import subprocess
|
13 |
from typing import Tuple, Dict
|
|
|
14 |
|
15 |
# Model options mapped to their requirements
|
16 |
MODEL_OPTIONS = {
|
@@ -109,11 +108,6 @@ def ensure_model():
|
|
109 |
# Ensure model is downloaded
|
110 |
model_path = ensure_model()
|
111 |
|
112 |
-
# Configure embeddings globally
|
113 |
-
Settings.embed_model = HuggingFaceEmbedding(
|
114 |
-
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
115 |
-
)
|
116 |
-
|
117 |
# Configure local LLM with LlamaCPP
|
118 |
llm = LlamaCPP(
|
119 |
model_path=model_path,
|
@@ -122,13 +116,13 @@ llm = LlamaCPP(
|
|
122 |
context_window=2048
|
123 |
)
|
124 |
|
125 |
-
#
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
)
|
130 |
|
131 |
-
# Create the index at startup
|
132 |
symptom_index = create_symptom_index()
|
133 |
|
134 |
# --- System prompt ---
|
|
|
1 |
import os
|
2 |
from pathlib import Path
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
import gradio as gr
|
5 |
+
from llama_index.core import Settings
|
6 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
7 |
from llama_index.llms.llama_cpp import LlamaCPP
|
8 |
from parse_tabular import create_symptom_index
|
9 |
import json
|
|
|
10 |
import psutil
|
|
|
11 |
from typing import Tuple, Dict
|
12 |
+
import torch
|
13 |
|
14 |
# Model options mapped to their requirements
|
15 |
MODEL_OPTIONS = {
|
|
|
108 |
# Ensure model is downloaded
|
109 |
model_path = ensure_model()
|
110 |
|
|
|
|
|
|
|
|
|
|
|
111 |
# Configure local LLM with LlamaCPP
|
112 |
llm = LlamaCPP(
|
113 |
model_path=model_path,
|
|
|
116 |
context_window=2048
|
117 |
)
|
118 |
|
119 |
+
# Configure global settings
|
120 |
+
Settings.llm = llm
|
121 |
+
Settings.embed_model = HuggingFaceEmbedding(
|
122 |
+
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
123 |
)
|
124 |
|
125 |
+
# Create the index at startup
|
126 |
symptom_index = create_symptom_index()
|
127 |
|
128 |
# --- System prompt ---
|