Spaces:
Runtime error
Runtime error
Upload 7 files
Browse files
main.py
CHANGED
|
@@ -11,6 +11,8 @@ This script performs the following tasks:
|
|
| 11 |
|
| 12 |
# --- Importing required libraries ---
|
| 13 |
from zigistry import constants
|
|
|
|
|
|
|
| 14 |
from zigistry import pre_requisite
|
| 15 |
import gradio as gr
|
| 16 |
from llama_index.core import (
|
|
@@ -36,13 +38,12 @@ if not pre_requisite.CorrectlyCompletedPreRequisites():
|
|
| 36 |
|
| 37 |
|
| 38 |
# --- Configure LLM and embedding model ---
|
| 39 |
-
Settings.llm =
|
| 40 |
model_name=constants.LLM,
|
| 41 |
-
|
| 42 |
context_window=3000,
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
generate_kwargs={"temperature": constants.TEMPERATURE},
|
| 46 |
)
|
| 47 |
|
| 48 |
Settings.embed_model = HuggingFaceEmbedding(model_name=constants.EMBEDDER)
|
|
|
|
| 11 |
|
| 12 |
# --- Importing required libraries ---
|
| 13 |
from zigistry import constants
|
| 14 |
+
from llama_index.llms.openrouter import OpenRouter
|
| 15 |
+
from llama_index.core.llms import ChatMessage
|
| 16 |
from zigistry import pre_requisite
|
| 17 |
import gradio as gr
|
| 18 |
from llama_index.core import (
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
# --- Configure LLM and embedding model ---
|
| 41 |
+
Settings.llm = OpenRouter(
|
| 42 |
model_name=constants.LLM,
|
| 43 |
+
api_key=constants.OR_TOKEN,
|
| 44 |
context_window=3000,
|
| 45 |
+
max_tokens=512,
|
| 46 |
+
temperature=constants.TEMPERATURE,
|
|
|
|
| 47 |
)
|
| 48 |
|
| 49 |
Settings.embed_model = HuggingFaceEmbedding(model_name=constants.EMBEDDER)
|
zigistry/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (147 Bytes). View file
|
|
|
zigistry/__pycache__/constants.cpython-313.pyc
ADDED
|
Binary file (1.69 kB). View file
|
|
|
zigistry/__pycache__/pre_requisite.cpython-313.pyc
ADDED
|
Binary file (1.27 kB). View file
|
|
|
zigistry/constants.py
CHANGED
|
@@ -5,9 +5,9 @@ print("Loaded environment variables.")
|
|
| 5 |
load_dotenv()
|
| 6 |
|
| 7 |
PERSIST_DIR = "PERSIST_DIR"
|
| 8 |
-
LLM = "
|
| 9 |
EMBEDDER = "BAAI/bge-small-en-v1.5"
|
| 10 |
-
|
| 11 |
TEMPERATURE = 0.1
|
| 12 |
FILES = ["Zigistry.pdf"]
|
| 13 |
|
|
|
|
| 5 |
load_dotenv()
|
| 6 |
|
| 7 |
PERSIST_DIR = "PERSIST_DIR"
|
| 8 |
+
LLM = "meta-llama/llama-guard-3-8b"
|
| 9 |
EMBEDDER = "BAAI/bge-small-en-v1.5"
|
| 10 |
+
OR_TOKEN = os.getenv("OR_TOKEN")
|
| 11 |
TEMPERATURE = 0.1
|
| 12 |
FILES = ["Zigistry.pdf"]
|
| 13 |
|
zigistry/pre_requisite.py
CHANGED
|
@@ -11,7 +11,7 @@ def CorrectlyCompletedPreRequisites() -> bool:
|
|
| 11 |
if not os.path.exists(constants.PERSIST_DIR):
|
| 12 |
error(f"Directory {constants.PERSIST_DIR} does not exist")
|
| 13 |
return False
|
| 14 |
-
if constants.
|
| 15 |
error("Hugging Face token not set")
|
| 16 |
return False
|
| 17 |
return True
|
|
|
|
| 11 |
if not os.path.exists(constants.PERSIST_DIR):
|
| 12 |
error(f"Directory {constants.PERSIST_DIR} does not exist")
|
| 13 |
return False
|
| 14 |
+
if constants.OR_TOKEN == None:
|
| 15 |
error("Hugging Face token not set")
|
| 16 |
return False
|
| 17 |
return True
|