File size: 1,442 Bytes
511ba56
 
9dfc4a2
511ba56
 
 
 
 
 
 
9dfc4a2
511ba56
 
 
5d10ce5
511ba56
 
5d10ce5
511ba56
 
9dfc4a2
 
4ccb6c3
9dfc4a2
4ccb6c3
511ba56
 
 
 
 
 
9dfc4a2
 
511ba56
9dfc4a2
 
 
 
511ba56
9dfc4a2
 
511ba56
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
from pinecone import Pinecone
from openai import OpenAI
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Environment Variables
PINECONE_API_KEY = os.environ.get("PINECONE_API_KEY")
HF_TOKEN = os.environ.get("HF_TOKEN") or os.environ.get("HF_API_KEY")
TELEGRAM_TOKEN = os.environ.get("TELEGRAM_TOKEN")
SUPABASE_URL = os.environ.get("SUPABASE_URL")
SUPABASE_KEY = os.environ.get("SUPABASE_KEY")
TELEGRAM_DOMAIN = os.environ.get("TELEGRAM_DOMAIN", "https://api.telegram.org").rstrip("/")

# Only create TELEGRAM_URL if token exists
TELEGRAM_URL = f"{TELEGRAM_DOMAIN}/bot{TELEGRAM_TOKEN}/sendMessage" if TELEGRAM_TOKEN and TELEGRAM_DOMAIN else None

EMBED_MODEL = os.environ.get("EMBED_MODEL", "multilingual-e5-large")
HF_MODEL = os.environ.get(
    "HF_MODEL",
    "dphn/Dolphin-Mistral-24B-Venice-Edition",
)
PROMPT = os.environ.get("PROMPT")

# Initialize clients only if API keys are available
pc = None
if PINECONE_API_KEY:
    pc = Pinecone(api_key=PINECONE_API_KEY)

hf_client = None
if HF_TOKEN:
    try:
        hf_client = OpenAI(
            base_url="https://router.huggingface.co/v1",
            api_key=HF_TOKEN,
        )
    except Exception as e:
        print(f"Warning: Failed to initialize Hugging Face OpenAI client: {e}")
        hf_client = None

# Initialize index only if Pinecone client is available
index = None
if pc:
    index = pc.Index("customerserviceindex")