Sidreds06 commited on
Commit
0b508b2
·
1 Parent(s): 84d1290

import errors fixed

Browse files
backend/cache_utils.py CHANGED
@@ -1,8 +1,7 @@
1
  import time
2
  from typing import Dict, Any, Optional
3
 
4
- from server import setup_google_credentials
5
-
6
  setup_google_credentials()
7
 
8
  # Simple in-memory cache
 
1
  import time
2
  from typing import Dict, Any, Optional
3
 
4
+ from backend.config import setup_google_credentials
 
5
  setup_google_credentials()
6
 
7
  # Simple in-memory cache
backend/config.py CHANGED
@@ -37,3 +37,18 @@ deepseek = ChatOpenAI(
37
  base_url="https://api.deepseek.com/v1",
38
  )
39
  deepseek_with_tools = deepseek.bind_tools([add_goal_tool, list_goal_categories])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  base_url="https://api.deepseek.com/v1",
38
  )
39
  deepseek_with_tools = deepseek.bind_tools([add_goal_tool, list_goal_categories])
40
+
41
+ import tempfile
42
+ import os
43
+
44
+ def setup_google_credentials():
45
+ creds_json = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
46
+ if creds_json:
47
+ # Create temporary JSON file from environment variable
48
+ tmp_path = tempfile.NamedTemporaryFile(delete=False, suffix=".json").name
49
+ with open(tmp_path, "w") as f:
50
+ f.write(creds_json)
51
+ os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = tmp_path
52
+ print("[CREDENTIALS] Using Google Cloud credentials from environment")
53
+ else:
54
+ print("[CREDENTIALS] Using local service account file")
backend/goal_extraction.py CHANGED
@@ -1,8 +1,7 @@
1
  import re
2
  from backend.config import gpt4o
3
 
4
- from server import setup_google_credentials
5
-
6
  setup_google_credentials()
7
 
8
  async def extract_goal_details(user_message: str, conversation_history: list = None) -> dict:
 
1
  import re
2
  from backend.config import gpt4o
3
 
4
+ from backend.config import setup_google_credentials
 
5
  setup_google_credentials()
6
 
7
  async def extract_goal_details(user_message: str, conversation_history: list = None) -> dict:
backend/mood_extraction.py CHANGED
@@ -5,8 +5,7 @@ from backend.config import gpt4o
5
 
6
  db = firestore.Client()
7
 
8
- from server import setup_google_credentials
9
-
10
  setup_google_credentials()
11
 
12
  COMMON_EMOTIONS = [
 
5
 
6
  db = firestore.Client()
7
 
8
+ from backend.config import setup_google_credentials
 
9
  setup_google_credentials()
10
 
11
  COMMON_EMOTIONS = [
backend/rag_utils.py CHANGED
@@ -4,8 +4,7 @@ from backend.mood_extraction import get_recent_mood_entries
4
  import time
5
  from backend.cache_utils import get_cached_user_data, cache_user_data
6
 
7
- from server import setup_google_credentials
8
-
9
  setup_google_credentials()
10
 
11
  # Load from .env file
 
4
  import time
5
  from backend.cache_utils import get_cached_user_data, cache_user_data
6
 
7
+ from backend.config import setup_google_credentials
 
8
  setup_google_credentials()
9
 
10
  # Load from .env file
server.py CHANGED
@@ -18,22 +18,9 @@ from backend.cache_utils import get_cached_user_data, cache_user_data, cleanup_e
18
 
19
 
20
  import json
21
- import tempfile
22
  import os
23
 
24
- def setup_google_credentials():
25
- creds_json = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
26
- if creds_json:
27
- # Create temporary JSON file from environment variable
28
- tmp_path = tempfile.NamedTemporaryFile(delete=False, suffix=".json").name
29
- with open(tmp_path, "w") as f:
30
- f.write(creds_json)
31
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = tmp_path
32
- print("[CREDENTIALS] Using Google Cloud credentials from environment")
33
- else:
34
- print("[CREDENTIALS] Using local service account file")
35
-
36
- # Call this before any Google Cloud operations
37
  setup_google_credentials()
38
 
39
 
 
18
 
19
 
20
  import json
 
21
  import os
22
 
23
+ from backend.config import setup_google_credentials
 
 
 
 
 
 
 
 
 
 
 
 
24
  setup_google_credentials()
25
 
26
 
tools/goal_tools.py CHANGED
@@ -3,8 +3,7 @@ from langchain_core.tools import tool
3
  from datetime import datetime, timedelta
4
  import pytz
5
 
6
- from server import setup_google_credentials
7
-
8
  setup_google_credentials()
9
 
10
  APP_TO_DB_CATEGORY = {
 
3
  from datetime import datetime, timedelta
4
  import pytz
5
 
6
+ from backend.config import setup_google_credentials
 
7
  setup_google_credentials()
8
 
9
  APP_TO_DB_CATEGORY = {