Skip to content

onecontext/onecontext-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Get it from npm (recommended)

Install globally using npm

npm install -g @onecontext/cli
Get it from GitHub

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

Your API Key

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
Your base URL
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:

Pipelines

List your pipelines

onecli pipeline list

This will list your pipelines like so.

Screenshot 2024-05-14 at 21 07 59

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.

image
Knowledge Bases

List your knowledge bases

onecli knowledge-base list
image

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.

Vector Indices

List your vector indices

onecli vector-index list
image

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.

Files

List the files in a knowledge base

onecli knowledge-base files list --knowledge-base-name=rm_kb
image

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.

image

Confirmation will be shown like so:

image

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:

image

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.

Runs

List the runs executed on your account

onecli pipeline run status
image

Show a particular run

onecli pipeline run status --runid=24b554e89fc64e97955cf06e0e14dfc2
image

Output the steps for a run

onecli pipeline run status --runid=24b554e89fc64e97955cf06e0e14dfc2 --show-steps
image

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:

I don't have node installed

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
I don't have npm installed

Get it via apt-get

sudo apt-get install npm
I don't have git installed

Get it via apt-get

sudo apt-get install git
I don't have permission to make a directory

Try it with sudo

i.e. instead of:

npm install -g @onecontext/cli

try:

sudo npm install -g @onecontext/cli
I still have an issue

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published