Spaces:
Running
Running
Download seed.py from VADITYA307/vertex-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/VADITYA307/vertex-engine/resolve/main/seed.py
- Command line
-
hf download hf://spaces/VADITYA307/vertex-engine/seed.py
-
curl -L -o seed.py https://huggingface.co/spaces/VADITYA307/vertex-engine/resolve/main/seed.py
1.39 kB
| import requests | |
| import time | |
| # The endpoint you built in main.py | |
| API_URL = "http://127.0.0.1:8000/crawl/dispatch" | |
| # The workspace profile to upload this data into | |
| WORKSPACE_PROFILE = "public" | |
| # The websites you want Vertex to learn | |
| seed_urls = [ | |
| "https://en.wikipedia.org/wiki/Search_engine", | |
| "https://en.wikipedia.org/wiki/Vector_database", | |
| "https://en.wikipedia.org/wiki/Retrieval-augmented_generation", | |
| "https://en.wikipedia.org/wiki/Distributed_computing" | |
| ] | |
| print(f"π Starting Vertex Bulk Ingestion into workspace: '{WORKSPACE_PROFILE}'\n") | |
| for url in seed_urls: | |
| payload = { | |
| "url": url, | |
| "user_profile": WORKSPACE_PROFILE | |
| } | |
| try: | |
| # Send the URL to FastAPI | |
| response = requests.post(API_URL, json=payload) | |
| if response.status_code == 200: | |
| data = response.json() | |
| print(f"β [QUEUED] {url}") | |
| print(f" Task ID: {data['task_id']}") | |
| else: | |
| print(f"β [FAILED] {url} - {response.text}") | |
| except requests.exceptions.ConnectionError: | |
| print("β [ERROR] Could not connect to FastAPI. Is uvicorn running in your other terminal?") | |
| break | |
| # Pause for half a second so we don't overwhelm the local server | |
| time.sleep(0.5) | |
| print("\nπ All URLs dispatched! Watch your Celery terminal to see the AI extracting the data.") |