0.0.1-rc.14 • Published 7 months ago

@continual/sdk v0.0.1-rc.14

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

Copyright (c) 2024 Continual, Inc. All rights reserved.

Continual SDK

This directory contains example scripts demonstrating how to use the Continual SDK.

Prerequisites

  1. Make sure you have Node.js installed on your system.
  2. Install the required dependencies by running pnpm install in the packages/sdk directory.
  3. Create a .env file in the packages/sdk directory with the necessary environment variables (see below).

Environment Variables

Create a .env file in the packages/sdk directory with the following variables:

CONTINUAL_API_URL="https://console.continual.ai/api"
CONTINUAL_API_KEY=your-auth-token
CONTINUAL_USER_ID=some-user-id
CONTINUAL_COPILOT_ID=some-valid-copilot-id

Running the Examples

To run an example, execute the following command in the packages/sdk directory:

pnpm dlx tsx examples/run-llm-chat.ts

Replace run-llm-chat.ts with the name of the example you want to run.

Remote Flows

Local Flows for Dev Mode

To run a local flow, you need to have the flow server running. You can start the flow server by running the following command in the packages/sdk directory:

In webapps.ts you can specify one or more flows to run locally. For example to run the llm-chat flow:

#!/usr/bin/env tsx
import { webserver } from "../src/webserver";
import { llmChat } from "./flows/llm-chat";

webserver({
  flows: {
    llmChat,
  },
});

You will need to set the environment variables in .env:

CONTINUAL_API_URL=http://localhost:3000/api
CONTINUAL_API_KEY=your-auth-token
CONTINUAL_USER_ID=some-user-id
CONTINUAL_COPILOT_ID=some-valid-copilot-id

Then run the flow server:

pnpm dlx tsx examples/webapps.ts

This will start a local web server on port 8080 that will run the specified flows and register them in your local dev environment.

Remote Flows for Prod Mode

If running locally you can use ngrok to expose your local server to the internet:

ngrok http 8080

This will give you a public URL for your local server, which you can then use to register the flow in the Continual console.

Set your public URL as the CONTINUAL_FUNCTION_URL in .env:

CONTINUAL_FUNCTION_URL=https://your-ngrok-subdomain.ngrok-free.app

Remember to not set CONTINUAL_API_URL in .env when using a remote flow for production. Your .env should look like this:

CONTINUAL_FUNCTION_URL=https://your-ngrok-subdomain.ngrok-free.app
CONTINUAL_API_KEY=your-auth-token
CONTINUAL_USER_ID=some-user-id
CONTINUAL_COPILOT_ID=some-valid-copilot-id