1.2.0 • Published 7 months ago

@orquesta/angular v1.2.0

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

Orquesta provides your product teams with no-code collaboration tooling to experiment, operate and monitor LLMs and remote configurations within your SaaS

npm

Orquesta Angular SDK

Contents

Installation

npm install @orquesta/angular
yarn add @orquesta/angular

Creating a client instance

You can get your workspace API key from the settings section in your Orquesta workspace. https://my.orquesta.dev/<workspace>/settings/developers

Initialize the Orquesta client with your API key:

import { provideOrquesta } from '@orquesta/angular';

bootstrapApplication(AppComponent, {
  providers: [
    provideOrquesta({
      api_key: '__API_KEY__',
      ttl: 3000,
    }),
  ],
});

When creating a client instance, the following connection settings can be adjusted:

  • api_key: string - your workspace API key to use for authentication.
  • ttl?: number - the time to live in seconds for the local cache. Default is 3600 seconds (1 hour).

Usage

Important Note: If you want to use the Prompts API reach out to support@orquesta.cloud

Orquesta comes with a powerful Remote Configurations API that allows you to dynamically configure and run all your environments and services remotely.

Orquesta supports different types of remote configurations; we recommend always typing the query method to help Typescript infer the correct type.

The useOrquestaRemoteConfig hook receives an object of type OrquestaRemoteConfigQuery as parameter.

Supported types: boolean, number, string, json, array

Example: Querying a configuration of type boolean

import { inject } from '@angular/core';
import { OrquestaClient } from '@orquesta/angular';
import { OrquestaRemoteConfig } from '@orquesta/js-sdk';
import { tap } from 'rxjs';

@Component({})
export class AppComponent {
  private orquesta = inject(OrquestaClient);

  config$: Observable<OrquestaRemoteConfig<boolean>> =
    this.orquesta.remoteConfigs.query<boolean>({
      key: 'boolean_config',
      default_value: false,
      context: { environments: 'production', role: 'admin' },
      metadata: { timestamp: Date.now() },
    });

  addMetadata(): void {
    this.config$.pipe(
      tap((config) =>
        config.addMetrics({
          metadata: {
            user_id: '123',
          },
        })
      )
    );
  }
}

Example: Querying a configuration of type string

config$: Observable<OrquestaRemoteConfig<string>> =
  this.orquesta.remoteConfigs.query<string>({
    key: "string_config",
    default_value: "string_value",
    context: { environments: "production", country: "NL" },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type number

config$: Observable<OrquestaRemoteConfig<number>> =
  this.orquesta.remoteConfigs.query<number>({
    key: "number_config",
    default_value: 1990,
    context: { environments: "production", market: "US", domain: "ecommerce" },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type array

config$: Observable<OrquestaRemoteConfig<string[]>> =
  this.orquesta.remoteConfigs.query<string[]>({
    key: "array_config",
    default_value: ["value1", "value2"],
    context: { environments: "acceptance", isEnable: true },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type JSON

It's recommended to add an interface to the JSON configuration to help Typescript infer the correct type.

config$: Observable<OrquestaRemoteConfig<object>> =
  this.orquesta.remoteConfigs.query<object>({
    key: "json_config",
    default_value: { dashboardEnabled: false, theme: "dark" },
    context: { environments: "develop", platform: "mobile" },
    metadata: { timestamp: Date.now() },
  });

Example: Add metrics to your request log

After every query, Orquesta will generate a log with data about the request. You can add metadata to the log by using the addMetrics method.

metadata is a set of key-value pairs that you can use to add custom information to the log.

  public reportMetrics() {
    config$.pipe(
      tap((config) =>
        config.addMetrics({
          metadata: {
            user_id: '123',
          },
        })
      )
    );
  }

Remote Configurations API

OrquestaRemoteConfigQuery

ParameterTypeDescriptionRequired
keystringKey of remote configurationYes
default_valueTThe value to be returned in case there is a en error during evaluation or the remote configuration does not existsYes
contextRecord<string, unknown>Set of key-value pairs from your data model that should be compared against the values in the configuration matrixNo
metadataRecord<string, unknown>Set of key-value pairs of metadata you want to attach to the generated log after the prompt is evaluated. This is optionalNo

OrquestaRemoteConfig

ParameterTypeDescription
valueTThe value of the remote configuration
typeOrquestaRemoteConfigTypeReturn type of the remote configuration.
trace_idstringKey of remote configuration
addMetrics(payload: OrquestaRemoteConfigMetrics) => Promise<void>A method that report metadata to the request log after the configuration value is returned. At least one of the properties is required

OrquestaRemoteConfigMetrics

ParameterTypeDescriptionRequired
metadataRecord<string, unknown>Set of key-value pairs of metadata you want to attach to the generated log after the prompt is evaluated. This is optionalNo

OrquestaRemoteConfigMetrics

export enum OrquestaRemoteConfigType {
  Boolean = 'boolean',
  Integer = 'integer',
  String = 'string',
  List = 'list',
  Json = 'json',
}
1.2.0

7 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

10 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

1.0.8-alpha6.1

2 years ago

1.0.8-alpha6.0

2 years ago

1.0.7-alpha6.0

2 years ago

1.0.0-alpha.0

2 years ago