File size: 1,612 Bytes
a3c7b61
 
 
 
 
 
 
84d1290
81c40fc
84d1290
 
a3c7b61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b508b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from tools.goal_tools import add_goal_tool, list_goal_categories

load_dotenv()


from backend.credentials import setup_google_credentials
setup_google_credentials()

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")

os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_HIDE_INPUTS"] = "false"
os.environ["LANGCHAIN_HIDE_OUTPUTS"] = "false"

# GPT-4o-mini
gpt4o_mini = ChatOpenAI(
    model="gpt-4o-mini",
    api_key=OPENAI_API_KEY,
)
gpt4o_mini_with_tools = gpt4o_mini.bind_tools([add_goal_tool, list_goal_categories])

# GPT-4o
gpt4o = ChatOpenAI(
    model="gpt-4o",
    api_key=OPENAI_API_KEY,
)
gpt4o_with_tools = gpt4o.bind_tools([add_goal_tool, list_goal_categories])

# DeepSeek
deepseek = ChatOpenAI(
    model="deepseek-chat",
    api_key=DEEPSEEK_API_KEY,
    base_url="https://api.deepseek.com/v1",
)
deepseek_with_tools = deepseek.bind_tools([add_goal_tool, list_goal_categories])

import tempfile
import os

def setup_google_credentials():
    creds_json = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
    if creds_json:
        # Create temporary JSON file from environment variable
        tmp_path = tempfile.NamedTemporaryFile(delete=False, suffix=".json").name
        with open(tmp_path, "w") as f:
            f.write(creds_json)
        os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = tmp_path
        print("[CREDENTIALS] Using Google Cloud credentials from environment")
    else:
        print("[CREDENTIALS] Using local service account file")