@onecontext/cli
v0.0.33
Published
Official CLI tool to interact with OneContext. π.
Downloads
2
Readme
Official OneContext CLI Tool
Use this CLI tool to manage your OneContext account.
What is OneContext?
OneContext is a platform that enables software engineers to compose and deploy custom RAG pipelines on SOTA infrastructure. You define the pipeline in YAML, and OneContext takes care of the rest of the infra (SSL certs, DNS, Kubernetes cluster, GPUs, autoscaling, load balancing, etc).
Where can I learn more?
Check out our docs for a in-depth treatment of how our platform works!
Sounds cool. How do I get started?
Install the tool
Install globally using npm
npm install -g @onecontext/cli
Clone this repo
git clone https://github.com/onecontext/cli.git
Build it
cd cli
npm run build
Make it available
npm link
Set up your config
Run the below to set your API key
onecli config set-api-key
Don't have an API key?
You can get one here
Or, you can run the below command to open a browser session on the correct page:
onecli config create-user
You can (probably) skip this steph
The default base URL for the serverless platform is https://api.onecontext.ai/v1/
. You'll only need to set a custom base URL if you are on the dedicated plan and have a custom domain. Users on the dedicated plan have a custom GPU cluster set up just for them on their subdomain.
Run the below to set your base URL
onecli config set-base-url
Now what?
Now you can do (almost) everything the OneContext platform allows you to do, but from the command line, with a nice TUI.
For a quick overview though, please see below:
List your pipelines
onecli pipeline list
This will list your pipelines like so.
Hint: pass a --verbose flag if you want to view the full yaml file for each pipeline.
Create a new pipeline
onecli pipeline create --pipeline-name=index_pipeline --pipeline-yaml=example_yamls/index_pipeline.yaml && \
onecli pipeline create --pipeline-name=retrieve_fast --pipeline-yaml=example_yamls/retriever_pipeline.yaml
This command will create a pipeline according to the specification in the provided yaml file.
Delete a pipeline
onecli pipeline delete --pipeline-name=index_pipeline
This will ask you for confirmation Yes / No before proceeding.
Run a pipeline
onecli pipeline run sync --pipeline-name=retriever_pipeline
Run a pipeline with overrides to certain fields
onecli pipeline run sync --pipeline-name=retrieve_fast --override-args='{"query_embedder":{"query": "the difference between ipv4 and ipv6"}, "retriever" : {"top_k": 1}}'
As this is a retriever pipeline, it will return a list of chunks from the vector index. As we've set top_k equal to 1, there will be just one chunk in the list.
List your knowledge bases
onecli knowledge-base list
Create a new knowledge bases
onecli knowledge-base create --knowledge-base-name=demo_kb
This will create a new knowledge base you can upload files to.
Delete a knowledge base
onecli knowledge-base delete --knowledge-base-name=demo_kb
This will ask you for confirmation Yes / No before deleting. Note, all the files, chunks, and embeddings connected to this Knowledge Base will be deleted.
List your vector indices
onecli vector-index list
Create a new vector index
onecli vector-index create --vector-index-name=demo_vi --model-name=BAAI/bge-base-en-v1.5
Note you must pass both the vector index name, and the model name (because each vector index is tied to a particular embedding model).
Delete a vector index
onecli vector-index delete --vector-index-name=demo_vi
This will ask you for confirmation Yes / No before deleting. Note all the embeddings in this vector index will be deleted. The source files will remain in the knowledge base.
List the files in a knowledge base
onecli knowledge-base files list --knowledge-base-name=rm_kb
Upload a new file to a knowledge base
onecli knowledge-base upload file --knowledge-base-name=rm_kb
A file picker TUI will open, showing all files in the current directory. If you select a file, it will upload the selected file to the knowledge base.
Confirmation will be shown like so:
Upload a new directory of files to a knowledge base
onecli knowledge-base upload directory --knowledge-base-name=rm_kb
A file picker TUI will open, showing all files in the current directory. If you select a directory, it will upload all PDF, .txt, .docx, and .md within that directory. Confirmation will be shown like so:
Delete a file from a knowledge base
onecli knowledge-base files delete select --knowledge-base-name=rm_kb
A file picker TUI will open, showing all files in the current knowledge base (on the server). If you select a file, it will ask you for confirmation Yes / No before deleting. If you delete it, all associated chunks and embeddings will also be deleted.
List the runs executed on your account
onecli pipeline run status
Show a particular run
onecli pipeline run status --runid=24b554e89fc64e97955cf06e0e14dfc2
Output the steps for a run
onecli pipeline run status --runid=24b554e89fc64e97955cf06e0e14dfc2 --show-steps
Hint: omit the "runid" selector to show this output for all runs on the account.
Show the full config for the run
onecli pipeline run status --runid=24b554e89fc64e97955cf06e0e14dfc2 --show-config
Hint: omit the "runid" selector to show this output for all runs on the account.
Filter the above by further parameters
If you have multiple runs, you can also further refine the output by passing flags such as:
skip
and limit
(for pagination).
sort
to sort by a field on the run.
date-created-gte
to only show runs with a date greater than or equal to the provided date.
date-created-lte
to only show runs with a date less than or equal to the provided date.
status
to only show runs with a particular status (e.g. "RUNNING").
For more information execute the below command:
onecli pipeline run status -h
Ermahgerd it's not working
Some troubleshooting tips:
Get it from the interweb
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
When that's done, run:
sudo apt-get install -y nodejs=20.13.1-1nodesource1
Get it via apt-get
sudo apt-get install npm
Get it via apt-get
sudo apt-get install git
Try it with sudo
i.e. instead of:
npm install -g @onecontext/cli
try:
sudo npm install -g @onecontext/cli
Create an issue in this repo
We'll get back to you ASAP, or one of our helpful community will beat us to it.
Email us
Always happy to hear from our users! Please feel free to reach out. help
Thanks!