Quickstart
Run Python on a server and put your API Key in PRAXIS_API_KEY. Each run creates one knowledge base and two text files, and deletes them when finished.
python -m pip install openaiSave as quickstart.py and run python quickstart.py. Upload the policy file, create the store and wait for ingestion. Upload the second file with explicit purpose=user_data, then attach and poll. A successful upload still requires checking ingestion status.
import osfrom openai import OpenAI
client = OpenAI( api_key=os.environ["PRAXIS_API_KEY"], base_url="https://api.deepraxis.com/openai/v1", timeout=120.0,)store = Nonefile_ids = []try: uploaded = client.files.create( file=("refund-policy.txt", b"Refunds are available within 30 days of purchase."), purpose="user_data", ) file_ids.append(uploaded.id) print("uploaded:", uploaded.id)
store = client.vector_stores.create( name="Knowledge quickstart", file_ids=[uploaded.id], ) print("store:", store.id) first = client.vector_stores.files.poll( uploaded.id, vector_store_id=store.id, poll_interval_ms=1000, ) if first.status != "completed": raise RuntimeError(f"Ingestion failed: {first.last_error}")
second = client.files.create( file=("refund-timing.txt", b"Refunds are processed in 5 business days."), purpose="user_data", ) file_ids.append(second.id) attached = client.vector_stores.files.create_and_poll( vector_store_id=store.id, file_id=second.id, poll_interval_ms=1000, ) print("ingestion:", attached.status) if attached.status != "completed": raise RuntimeError(f"Ingestion failed: {attached.last_error}")
results = client.vector_stores.search( vector_store_id=store.id, query="How many business days does a refund take?", max_num_results=5, ) assert results.data, "Expected at least one matching chunk" for result in results.data: print(result.filename, result.score) for part in result.content: print(part.text) print("pagination:", results.has_more, results.next_page)finally: try: if store is not None: deleted = client.vector_stores.delete(store.id) print("store deleted:", deleted.deleted) finally: for file_id in file_ids: deleted = client.files.delete(file_id) print("file deleted:", file_id, deleted.deleted) client.close()Output includes file IDs, the store ID, ingestion: completed, matching text and cleanup results. Each file appears once, with its matching chunks ordered by relevance. Search does not paginate; when nothing was cut off it prints pagination: False None.
Text, Markdown, PDF, DOCX, CSV, JSON and HTML usually take a few seconds to tens of seconds, and images take longer. These are indicative timings, not latency guarantees. Processing has a 30-minute deadline; inspect last_error if it fails.
Deleting a knowledge base retains it for 7 days for restoration. Source files are deleted separately. If you need these documents later, move cleanup after their final use in your own program.
Build one in the Console
- Open Console → 知识库 (Knowledge bases) (
/knowledge), click “新建知识库” (New knowledge base), enter a name and click “创建” (Create). - Open the knowledge base and click “添加文件” (Add files) to upload the documents the agent should search.