-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_mongodb.py
More file actions
46 lines (37 loc) · 1.44 KB
/
Copy pathinit_mongodb.py
File metadata and controls
46 lines (37 loc) · 1.44 KB
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
"""
MongoDB Collection Initializer
Bu script agentic_rag collection'ını oluşturur
"""
from pymongo import MongoClient
import os
from dotenv import load_dotenv
load_dotenv()
# Connection string'ini .env dosyasından al veya buraya direkt yaz
MONGODB_URI = os.getenv("MONGODB_URI", "BURAYA_CONNECTION_STRING_YAZ")
def init_collection():
try:
client = MongoClient(MONGODB_URI)
db = client["diet_db"]
# Yeni collection oluştur
collection = db["agentic_rag"]
# Dummy document ekle (collection'ın oluşması için)
result = collection.insert_one({
"_init": True,
"description": "Agentic RAG embeddings collection"
})
print("✅ Collection 'agentic_rag' başarıyla oluşturuldu!")
print(f" Database: diet_db")
print(f" Collection: agentic_rag")
print(f" Document ID: {result.inserted_id}")
print("\n📌 Şimdi MongoDB Atlas'a git ve Vector Search Index oluştur:")
print(" 1. Search & Vector Search sayfasına git")
print(" 2. + CREATE SEARCH INDEX tıkla")
print(" 3. JSON Editor seç")
print(" 4. Database: diet_db, Collection: agentic_rag seç")
print(" 5. Index name: vector_index")
# Bağlantıyı kapat
client.close()
except Exception as e:
print(f"❌ Hata: {e}")
if __name__ == "__main__":
init_collection()