Creating your first Workload
Last updated
Last updated
Anything that runs on the ObitCC network is called a Workload, which is represented as a JavaScript object. This object contains details about your organization and your project, as well as configurations for the type of Workload (e.g, image generation, text generation, simulations) that you are running.
Many workloads, such as running large language models, are supported by the Scaffolding API, our set of tools that simplify many complex AI/ML use-cases.
Your use-case is called a Shader, which is a file or configuration containing your code. Shaders are fetched from our server and distributed across our network, then returned as Outputs. These can be saved temporarily on our server or uploaded directly to your servers.
It's easy to start using ObitCC. Let's use a small Large Language Model called to run some basic arithmetic on the network.
First, we import required modules from the ObitCC tools API and define our model (all models have to be set up to be web-compatible using the spec; most popular models are already converted to this format)
Now, let's define our prompts and a default prompt.
Now, let's define a default response to when a client asks for a new shader (in this case it's a prompt). This just returns a random shader, as well as the default system prompt. You can pass a single prompt, or a batch of prompts in. We recommend a maximum of 10 prompts - they will be run sequentially. Here, we just pass in one prompt (hence an array of a singular array)
Now let's set up the code for when all prompts are done. It also removes prompts that have been already completed (you may add a counter so each prompt is completed more than once). Also, a function for when all tasks are finished is defined. It cleans up the user's machine with the markAllTasksDone()
function, then exits after two minutes. You may customize this code however you want.
Now let's export the final function in accordance to the WebLLM workload (full spec is available under the Workloads tab).
You're done! Let's run it on the network and see what happens:
Two clients gave responses to the three prompts.
Congratulations, you have made your first Workload on ObitCC! You can check out workload types in the next page, or expand the Workload Types category to see detailed examples for each one.