Spaces:
Running
Running
Commit Β·
c080f15
1
Parent(s): 593ecb7
Switch embedding model to Alibaba-NLP/gte-Qwen2-7B-instruct via AI Grid API
Browse files- __pycache__/config.cpython-313.pyc +0 -0
- __pycache__/rag_pipeline.cpython-313.pyc +0 -0
- config.py +2 -2
- rag_pipeline.py +7 -3
- requirements.txt +1 -0
__pycache__/config.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/config.cpython-313.pyc and b/__pycache__/config.cpython-313.pyc differ
|
|
|
__pycache__/rag_pipeline.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/rag_pipeline.cpython-313.pyc and b/__pycache__/rag_pipeline.cpython-313.pyc differ
|
|
|
config.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
# ββ API Keys ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
AIGRID_API_KEY_GPT = os.getenv("AIGRID_API_KEY_GPT", "sk-XaDrxkmJNvrp04SfkHT2ig")
|
| 5 |
AIGRID_API_KEY_GEMMA = os.getenv("AIGRID_API_KEY_GEMMA", "sk-eQYZ67KgWjIMcPZb6SwwKg")
|
|
|
|
| 6 |
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY", "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")
|
| 7 |
|
| 8 |
# ββ API Bases βββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -11,8 +12,7 @@ OPENROUTER_API_BASE = "https://openrouter.ai/api/v1"
|
|
| 11 |
|
| 12 |
# ββ Model Settings ββββββββββββββββββββββββββββββββββββββββ
|
| 13 |
LLM_MODEL = "gpt-oss-120b"
|
| 14 |
-
EMBEDDING_MODEL = "
|
| 15 |
-
# EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"
|
| 16 |
LLM_TEMPERATURE = 0.1 # Low = less hallucination
|
| 17 |
MAX_TOKENS = 1024
|
| 18 |
|
|
|
|
| 3 |
# ββ API Keys ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
AIGRID_API_KEY_GPT = os.getenv("AIGRID_API_KEY_GPT", "sk-XaDrxkmJNvrp04SfkHT2ig")
|
| 5 |
AIGRID_API_KEY_GEMMA = os.getenv("AIGRID_API_KEY_GEMMA", "sk-eQYZ67KgWjIMcPZb6SwwKg")
|
| 6 |
+
AIGRID_API_KEY_EMBEDDING = os.getenv("AIGRID_API_KEY_EMBEDDING", "sk-CNXeCrle_NG4iCre1XvcAA")
|
| 7 |
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY", "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")
|
| 8 |
|
| 9 |
# ββ API Bases βββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 12 |
|
| 13 |
# ββ Model Settings ββββββββββββββββββββββββββββββββββββββββ
|
| 14 |
LLM_MODEL = "gpt-oss-120b"
|
| 15 |
+
EMBEDDING_MODEL = "Alibaba-NLP/gte-Qwen2-7B-instruct"
|
|
|
|
| 16 |
LLM_TEMPERATURE = 0.1 # Low = less hallucination
|
| 17 |
MAX_TOKENS = 1024
|
| 18 |
|
rag_pipeline.py
CHANGED
|
@@ -4,13 +4,13 @@ from langdetect import detect
|
|
| 4 |
|
| 5 |
from llama_index.core import VectorStoreIndex, Document, Settings
|
| 6 |
from llama_index.core.retrievers import VectorIndexRetriever
|
| 7 |
-
from llama_index.embeddings.
|
| 8 |
from llama_index.llms.openai_like import OpenAILike
|
| 9 |
from llama_index.core.node_parser import SimpleNodeParser
|
| 10 |
|
| 11 |
from document_processor import load_all_documents, load_uploaded_pdf
|
| 12 |
from config import (
|
| 13 |
-
AIGRID_API_KEY_GPT, AIGRID_API_KEY_GEMMA, AIGRID_API_BASE,
|
| 14 |
OPENROUTER_API_KEY, OPENROUTER_API_BASE,
|
| 15 |
LLM_MODEL, EMBEDDING_MODEL,
|
| 16 |
LLM_TEMPERATURE, MAX_TOKENS, TOP_K, SIMILARITY_CUTOFF,
|
|
@@ -62,7 +62,11 @@ def get_llm(model_id: str):
|
|
| 62 |
# Initialise models
|
| 63 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 64 |
def _init_models():
|
| 65 |
-
embed_model =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# We use a default LLM for any global index operations if necessary
|
| 68 |
default_llm = get_llm(LLM_MODEL)
|
|
|
|
| 4 |
|
| 5 |
from llama_index.core import VectorStoreIndex, Document, Settings
|
| 6 |
from llama_index.core.retrievers import VectorIndexRetriever
|
| 7 |
+
from llama_index.embeddings.openai import OpenAIEmbedding
|
| 8 |
from llama_index.llms.openai_like import OpenAILike
|
| 9 |
from llama_index.core.node_parser import SimpleNodeParser
|
| 10 |
|
| 11 |
from document_processor import load_all_documents, load_uploaded_pdf
|
| 12 |
from config import (
|
| 13 |
+
AIGRID_API_KEY_GPT, AIGRID_API_KEY_GEMMA, AIGRID_API_KEY_EMBEDDING, AIGRID_API_BASE,
|
| 14 |
OPENROUTER_API_KEY, OPENROUTER_API_BASE,
|
| 15 |
LLM_MODEL, EMBEDDING_MODEL,
|
| 16 |
LLM_TEMPERATURE, MAX_TOKENS, TOP_K, SIMILARITY_CUTOFF,
|
|
|
|
| 62 |
# Initialise models
|
| 63 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 64 |
def _init_models():
|
| 65 |
+
embed_model = OpenAIEmbedding(
|
| 66 |
+
model_name=EMBEDDING_MODEL,
|
| 67 |
+
api_key=AIGRID_API_KEY_EMBEDDING,
|
| 68 |
+
api_base=AIGRID_API_BASE
|
| 69 |
+
)
|
| 70 |
|
| 71 |
# We use a default LLM for any global index operations if necessary
|
| 72 |
default_llm = get_llm(LLM_MODEL)
|
requirements.txt
CHANGED
|
@@ -6,6 +6,7 @@ python-dotenv
|
|
| 6 |
llama-index-core
|
| 7 |
llama-index-llms-openai-like
|
| 8 |
llama-index-embeddings-huggingface
|
|
|
|
| 9 |
|
| 10 |
# PDF Processing
|
| 11 |
pymupdf
|
|
|
|
| 6 |
llama-index-core
|
| 7 |
llama-index-llms-openai-like
|
| 8 |
llama-index-embeddings-huggingface
|
| 9 |
+
llama-index-embeddings-openai
|
| 10 |
|
| 11 |
# PDF Processing
|
| 12 |
pymupdf
|