CocoonAI commited on
Commit
6c49cfd
Β·
1 Parent(s): f534006

Update obsidian

Browse files
Files changed (3) hide show
  1. app.py +2 -1
  2. profile_writer.py +10 -10
  3. utils.py +3 -1
app.py CHANGED
@@ -2,12 +2,13 @@ from profile_writer import write_profile_to_obsidian
2
  import os
3
  import json
4
  import tempfile
 
5
  from fastapi import FastAPI, UploadFile, File
6
  from fastapi.responses import JSONResponse
7
  from pydantic import BaseModel
8
  from sentence_transformers import SentenceTransformer
9
  from supabase import create_client
10
- import openai
11
  from embedding_utils import load_documents, embed_documents, create_vector_db, query_db
12
 
13
  # === Hugging Face Cache Setup ===
 
2
  import os
3
  import json
4
  import tempfile
5
+ import openai
6
  from fastapi import FastAPI, UploadFile, File
7
  from fastapi.responses import JSONResponse
8
  from pydantic import BaseModel
9
  from sentence_transformers import SentenceTransformer
10
  from supabase import create_client
11
+ from utils import get_user_vault_path
12
  from embedding_utils import load_documents, embed_documents, create_vector_db, query_db
13
 
14
  # === Hugging Face Cache Setup ===
profile_writer.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- from app import get_user_vault_path # πŸ”₯ Utilise le chemin correct (dans /data)
3
 
4
  def write_file(user_path, relative_path, content):
5
  full_path = os.path.join(user_path, relative_path)
@@ -8,7 +7,8 @@ def write_file(user_path, relative_path, content):
8
  f.write(content.strip() + "\n")
9
 
10
  def write_profile_to_obsidian(user_id: str, data: dict):
11
- base_path = get_user_vault_path(user_id) # βœ… Utilise le bon chemin Hugging Face
 
12
 
13
  # === Profile Folder ===
14
  write_file(base_path, "Profile/user_profile.md", f"""
@@ -16,14 +16,14 @@ def write_profile_to_obsidian(user_id: str, data: dict):
16
  - Experience Level: {data.get("experienceLevel", "")}
17
  - Main Goal: {data.get("contentGoal", "")}
18
  - Location: {data.get("country", "")}, {data.get("city", "")}
19
- """)
20
 
21
  write_file(base_path, "Profile/business_profile.md", f"""
22
  # 🏒 Business Profile
23
  - Type: {data.get("businessType", "")}
24
  - Description: {data.get("businessDescription", "")}
25
  - Niche: {data.get("niche", "")}
26
- """)
27
 
28
  write_file(base_path, "Profile/creator_personality.md", "# ✨ Creator Personality\nTo be discovered...")
29
 
@@ -32,7 +32,7 @@ def write_profile_to_obsidian(user_id: str, data: dict):
32
  # 🎯 Content Goals
33
  - Goal: {data.get("contentGoal", "")}
34
  - Niche: {data.get("niche", "")}
35
- """)
36
 
37
  write_file(base_path, "Content_Strategy/platforms_and_audience.md", f"""
38
  # πŸ“£ Platforms & Audience
@@ -40,13 +40,13 @@ def write_profile_to_obsidian(user_id: str, data: dict):
40
  - Target Generation: {data.get("targetGeneration", "")}
41
  - Time Available: {data.get("timeAvailable", "")}
42
  - Monetization Intent: {data.get("monetizationIntent", "")}
43
- """)
44
 
45
  write_file(base_path, "Content_Strategy/content_types_and_niche.md", f"""
46
  # πŸ“¦ Content Types & Niche
47
  - Types: {", ".join(data.get("contentTypes", []))}
48
  - Challenges: {data.get("mainChallenges", "")}
49
- """)
50
 
51
  write_file(base_path, "Content_Strategy/social_accounts.md", "# πŸ”— Social Accounts\nAdd your accounts here.")
52
 
@@ -54,12 +54,12 @@ def write_profile_to_obsidian(user_id: str, data: dict):
54
  write_file(base_path, "Resources_and_Skills/current_challenges.md", f"""
55
  # ❗ Current Challenges
56
  {data.get("mainChallenges", "")}
57
- """)
58
 
59
  write_file(base_path, "Resources_and_Skills/available_resources.md", f"""
60
  # πŸ› οΈ Available Resources
61
  {data.get("resources", "")}
62
- """)
63
 
64
  write_file(base_path, "Resources_and_Skills/learning_preferences.md", "# πŸ“š Learning Preferences\nTo define.")
65
 
@@ -90,4 +90,4 @@ This file summarizes the user context.
90
 
91
  ## Notes
92
  Automatically generated. Use for AI context.
93
- """)
 
1
  import os
 
2
 
3
  def write_file(user_path, relative_path, content):
4
  full_path = os.path.join(user_path, relative_path)
 
7
  f.write(content.strip() + "\n")
8
 
9
  def write_profile_to_obsidian(user_id: str, data: dict):
10
+ base_path = f"vaults/user_{user_id}"
11
+ os.makedirs(base_path, exist_ok=True)
12
 
13
  # === Profile Folder ===
14
  write_file(base_path, "Profile/user_profile.md", f"""
 
16
  - Experience Level: {data.get("experienceLevel", "")}
17
  - Main Goal: {data.get("contentGoal", "")}
18
  - Location: {data.get("country", "")}, {data.get("city", "")}
19
+ """)
20
 
21
  write_file(base_path, "Profile/business_profile.md", f"""
22
  # 🏒 Business Profile
23
  - Type: {data.get("businessType", "")}
24
  - Description: {data.get("businessDescription", "")}
25
  - Niche: {data.get("niche", "")}
26
+ """)
27
 
28
  write_file(base_path, "Profile/creator_personality.md", "# ✨ Creator Personality\nTo be discovered...")
29
 
 
32
  # 🎯 Content Goals
33
  - Goal: {data.get("contentGoal", "")}
34
  - Niche: {data.get("niche", "")}
35
+ """)
36
 
37
  write_file(base_path, "Content_Strategy/platforms_and_audience.md", f"""
38
  # πŸ“£ Platforms & Audience
 
40
  - Target Generation: {data.get("targetGeneration", "")}
41
  - Time Available: {data.get("timeAvailable", "")}
42
  - Monetization Intent: {data.get("monetizationIntent", "")}
43
+ """)
44
 
45
  write_file(base_path, "Content_Strategy/content_types_and_niche.md", f"""
46
  # πŸ“¦ Content Types & Niche
47
  - Types: {", ".join(data.get("contentTypes", []))}
48
  - Challenges: {data.get("mainChallenges", "")}
49
+ """)
50
 
51
  write_file(base_path, "Content_Strategy/social_accounts.md", "# πŸ”— Social Accounts\nAdd your accounts here.")
52
 
 
54
  write_file(base_path, "Resources_and_Skills/current_challenges.md", f"""
55
  # ❗ Current Challenges
56
  {data.get("mainChallenges", "")}
57
+ """)
58
 
59
  write_file(base_path, "Resources_and_Skills/available_resources.md", f"""
60
  # πŸ› οΈ Available Resources
61
  {data.get("resources", "")}
62
+ """)
63
 
64
  write_file(base_path, "Resources_and_Skills/learning_preferences.md", "# πŸ“š Learning Preferences\nTo define.")
65
 
 
90
 
91
  ## Notes
92
  Automatically generated. Use for AI context.
93
+ """)
utils.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import os
3
 
4
  def load_vault(vault_path="vault"):
@@ -14,3 +13,6 @@ def load_vault(vault_path="vault"):
14
  "text": text
15
  })
16
  return documents
 
 
 
 
 
1
  import os
2
 
3
  def load_vault(vault_path="vault"):
 
13
  "text": text
14
  })
15
  return documents
16
+
17
+ def get_user_vault_path(user_id: str) -> str:
18
+ return f"vaults/user_{user_id}"