1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = { "text": """Retrieval-Augmented Generation (RAG) combines a language model with an external knowledge base. Instead of relying only on what the model memorized during training, RAG retrieves relevant chunks of text and feeds them to the model as context.
9
10To build a RAG system you first split your documents into chunks, create embeddings for each chunk, and store them in a vector database. At query time you embed the user's question, find the most similar chunks, and pass them to the model alongside the prompt.
11
12Chunking matters a lot. Chunks that are too large dilute relevance and waste tokens, while chunks that are too small lose context. A common starting point is around 1000 characters per chunk with a small overlap, so that ideas spanning a boundary are not lost between neighbouring chunks.""" }
13
14
15run = client.actor("zenomastro/text-splitter-for-llm").call(run_input=run_input)
16
17
18print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
19for item in client.dataset(run["defaultDatasetId"]).iterate_items():
20 print(item)
21
22