-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathapply_rag_data.py
More file actions
36 lines (33 loc) · 1.15 KB
/
apply_rag_data.py
File metadata and controls
36 lines (33 loc) · 1.15 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
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
now = datetime.now()
embeddings = []
for i in range(10):
embeddings.append(
{
"document_id": f"doc_{i}",
"embedding": np.random.rand(768).astype(np.float32),
"event_timestamp": now - timedelta(days=i),
"created_timestamp": now - timedelta(days=i, hours=1),
}
)
df_embeddings = pd.DataFrame(embeddings)
df_embeddings.to_parquet("data/document_embeddings.parquet", index=False)
metadata = []
for i in range(10):
metadata.append(
{
"document_id": f"doc_{i}",
"title": f"Document {i}",
"content": f"This is the content of document {i}",
"source": "web",
"author": f"author_{i}",
"publish_date": (now - timedelta(days=i * 30)).strftime("%Y-%m-%d"),
"event_timestamp": now - timedelta(days=i),
"created_timestamp": now - timedelta(days=i, hours=1),
}
)
df_metadata = pd.DataFrame(metadata)
df_metadata.to_parquet("data/document_metadata.parquet", index=False)
print("Created RAG data files successfully!")