cat > ingest-filtering.py << 'EOF'
#!/usr/bin/env python3
import requests
import json
BASE_URL = "http://localhost:8001/ai-rag-injector/b924e3e8-7893-4706-aacb-e75793a1d2e9/ingest_chunk"
chunks = [
{
"content": "Q4 2024 Financial Results: Revenue increased 15% year-over-year to $2.3B. Operating margin improved to 24%, up from 21% in Q3. Key drivers included strong enterprise sales and improved operational efficiency.",
"metadata": {
"collection": "finance-reports",
"source": "internal",
"date": "2024-10-14T00:00:00Z",
"report_type": "quarterly",
"tags": ["finance", "quarterly", "q4", "2024", "current"]
}
},
{
"content": "Q3 2024 Financial Results: Revenue reached $2.0B with 12% year-over-year growth. Operating margin held steady at 21%. International markets contributed 35% of total revenue.",
"metadata": {
"collection": "finance-reports",
"source": "internal",
"date": "2024-07-15T00:00:00Z",
"report_type": "quarterly",
"tags": ["finance", "quarterly", "q3", "2024", "current"]
}
},
{
"content": "2024 Annual Report: Full-year revenue totaled $8.7B, representing 20% growth. The company expanded into five new markets and launched seven major product updates. Board approved $600M share buyback program.",
"metadata": {
"collection": "finance-reports",
"source": "internal",
"date": "2024-12-31T00:00:00Z",
"report_type": "annual",
"tags": ["finance", "annual", "2024", "current"]
}
},
{
"content": "2023 Annual Report: Full-year revenue totaled $7.8B, representing 18% growth. The company expanded into three new markets and launched five major product updates. Board approved $500M share buyback program.",
"metadata": {
"collection": "finance-reports",
"source": "internal",
"date": "2023-12-31T00:00:00Z",
"report_type": "annual",
"tags": ["finance", "annual", "2023"]
}
},
{
"content": "Morgan Stanley Analyst Report (Oct 2024): Maintains 'Overweight' rating with $145 price target. Cites strong execution, market expansion, and operating leverage as key positives. Recommends Buy.",
"metadata": {
"collection": "finance-reports",
"source": "external",
"date": "2024-10-20T00:00:00Z",
"report_type": "analyst",
"tags": ["analyst", "external", "2024", "recommendation"]
}
},
{
"content": "Goldman Sachs Sector Analysis (Sep 2024): Software sector shows resilient growth despite macro headwinds. Enterprise software spending expected to grow 12-15% in 2025. Cloud migration remains primary driver.",
"metadata": {
"collection": "finance-reports",
"source": "external",
"date": "2024-09-15T00:00:00Z",
"report_type": "analyst",
"tags": ["analyst", "external", "sector", "2024"]
}
},
{
"content": "Historical Data Archive: Q2 2022 revenue was $1.5B with 8% growth. This data is retained for historical analysis but may not reflect current business conditions or reporting standards.",
"metadata": {
"collection": "finance-reports",
"source": "archive",
"date": "2022-06-15T00:00:00Z",
"report_type": "quarterly",
"tags": ["finance", "quarterly", "q2", "2022", "archive"]
}
}
]
def ingest_chunks():
headers = {"Content-Type": "application/json"}
for i, chunk in enumerate(chunks, 1):
try:
response = requests.post(BASE_URL, json=chunk, headers=headers)
response.raise_for_status()
print(f"[{i}/{len(chunks)}] Ingested: {chunk['content'][:50]}...")
print(response.json())
except requests.exceptions.RequestException as e:
print(f"[{i}/{len(chunks)}] Failed: {e}")
if hasattr(e.response, 'text'):
print(f" Response: {e.response.text}")
if __name__ == "__main__":
ingest_chunks()
EOF