hmgill's picture
Update config/settings.py
0bd6bcb verified
"""
"""
import os
import torch
from llama_index.core import Settings
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.llms.huggingface import HuggingFaceLLM
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
from llama_index.core.prompts import PromptTemplate
# ---- Model IDs ---
AGENT_MODEL_ID = "google/gemma-3-12b-it"
EMBEDDING_MODEL_ID = "clip-ViT-B-32"
# --- Environment & Paths ---
CHROMADB = os.getenv("CHROMADB")
CELLPOSE_SAM = os.getenv("CELLPOSE_SAM")
HF_TOKEN = os.getenv("HF_TOKEN")
NEO4J_URI = os.getenv("NEO4J_URI")
NEO4J_USERNAME = os.getenv("NEO4J_USERNAME")
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
NEO4J_DATABASE = os.getenv("NEO4J_DATABASE")
# --- LlamaIndex Global Settings ---
def configure_llama_index():
"""
Configures global LlamaIndex settings for the embedding model and the LLM.
"""
print("βœ“ Configuring LlamaIndex settings...")
# Gemma 3 Prompt Template
query_wrapper_prompt = PromptTemplate(
"<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{query_str}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
)
llm = HuggingFaceInferenceAPI(
model_name=AGENT_MODEL_ID,
token = HF_TOKEN,
provider = "auto",
requests_per_minute=60,
timeout=300
)
Settings.llm = llm
Settings.embed_model = HuggingFaceEmbedding(
model_name=f"sentence-transformers/{EMBEDDING_MODEL_ID}"
)
Settings.chunk_size = 512
Settings.chunk_overlap = 50
print("βœ“ LlamaIndex configured to use local Embedding Model and LLM.")