0.5.1 • Published 5 days ago

honeyhive v0.5.1

Weekly downloads
-
License
-
Repository
github
Last release
5 days ago

HoneyHive

SDK Installation

NPM

npm add https://github.com/honeyhiveai/typescript-sdk

Yarn

yarn add https://github.com/honeyhiveai/typescript-sdk

SDK Example Usage

Example

import { HoneyHive } from "honeyhive";

async function run() {
    const sdk = new HoneyHive({
        bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
    });

    const res = await sdk.session.startSession({
        session: {
            project: "Simple RAG Project",
            sessionName: "Playground Session",
            source: "playground",
            sessionId: "caf77ace-3417-4da4-944d-f4a0688f3c23",
            childrenIds: ["7f22137a-6911-4ed3-bc36-110f1dde6b66"],
            config: {
                key: "<value>",
            },
            inputs: {
                context: "Hello world",
                question: "What is in the context?",
                chat_history: "<value>",
            },
            outputs: {
                role: "assistant",
                content: "Hello world",
            },
            error: null,
            duration: 824.8056,
            userProperties: {
                user: "google-oauth2|111840237613341303366",
            },
            metrics: {},
            feedback: {},
            metadata: {},
            startTime: 1712025501605,
            endTime: 1712025499832,
        },
    });

    if (res.statusCode == 200) {
        // handle response
    }
}

run();

Available Resources and Operations

session

events

metrics

tools

datapoints

datasets

projects

configurations

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.

Error ObjectStatus CodeContent Type
errors.SDKError4xx-5xx/

Example

import { HoneyHive } from "honeyhive";

async function run() {
    const sdk = new HoneyHive({
        bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
    });

    let res;
    try {
        res = await sdk.session.startSession({
            session: {
                project: "Simple RAG Project",
                sessionName: "Playground Session",
                source: "playground",
                sessionId: "caf77ace-3417-4da4-944d-f4a0688f3c23",
                childrenIds: ["7f22137a-6911-4ed3-bc36-110f1dde6b66"],
                config: {
                    key: "<value>",
                },
                inputs: {
                    context: "Hello world",
                    question: "What is in the context?",
                    chat_history: "<value>",
                },
                outputs: {
                    role: "assistant",
                    content: "Hello world",
                },
                error: null,
                duration: 824.8056,
                userProperties: {
                    user: "google-oauth2|111840237613341303366",
                },
                metrics: {},
                feedback: {},
                metadata: {},
                startTime: 1712025501605,
                endTime: 1712025499832,
            },
        });
    } catch (err) {
        if (err instanceof errors.SDKError) {
            console.error(err); // handle exception
            throw err;
        }
    }

    if (res.statusCode == 200) {
        // handle response
    }
}

run();

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the serverIdx: number optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

#ServerVariables
0https://api.honeyhive.aiNone

Example

import { HoneyHive } from "honeyhive";

async function run() {
    const sdk = new HoneyHive({
        serverIdx: 0,
        bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
    });

    const res = await sdk.session.startSession({
        session: {
            project: "Simple RAG Project",
            sessionName: "Playground Session",
            source: "playground",
            sessionId: "caf77ace-3417-4da4-944d-f4a0688f3c23",
            childrenIds: ["7f22137a-6911-4ed3-bc36-110f1dde6b66"],
            config: {
                key: "<value>",
            },
            inputs: {
                context: "Hello world",
                question: "What is in the context?",
                chat_history: "<value>",
            },
            outputs: {
                role: "assistant",
                content: "Hello world",
            },
            error: null,
            duration: 824.8056,
            userProperties: {
                user: "google-oauth2|111840237613341303366",
            },
            metrics: {},
            feedback: {},
            metadata: {},
            startTime: 1712025501605,
            endTime: 1712025499832,
        },
    });

    if (res.statusCode == 200) {
        // handle response
    }
}

run();

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the serverURL: str optional parameter when initializing the SDK client instance. For example:

import { HoneyHive } from "honeyhive";

async function run() {
    const sdk = new HoneyHive({
        serverURL: "https://api.honeyhive.ai",
        bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
    });

    const res = await sdk.session.startSession({
        session: {
            project: "Simple RAG Project",
            sessionName: "Playground Session",
            source: "playground",
            sessionId: "caf77ace-3417-4da4-944d-f4a0688f3c23",
            childrenIds: ["7f22137a-6911-4ed3-bc36-110f1dde6b66"],
            config: {
                key: "<value>",
            },
            inputs: {
                context: "Hello world",
                question: "What is in the context?",
                chat_history: "<value>",
            },
            outputs: {
                role: "assistant",
                content: "Hello world",
            },
            error: null,
            duration: 824.8056,
            userProperties: {
                user: "google-oauth2|111840237613341303366",
            },
            metrics: {},
            feedback: {},
            metadata: {},
            startTime: 1712025501605,
            endTime: 1712025499832,
        },
    });

    if (res.statusCode == 200) {
        // handle response
    }
}

run();

Custom HTTP Client

The Typescript SDK makes API calls using the axios HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance object.

For example, you could specify a header for every request that your sdk makes as follows:

import { honeyhive } from "HoneyHive";
import axios from "axios";

const httpClient = axios.create({
    headers: {'x-custom-header': 'someValue'}
})

const sdk = new HoneyHive({defaultClient: httpClient});

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

NameTypeScheme
bearerAuthhttpHTTP Bearer

To authenticate with the API the bearerAuth parameter must be set when initializing the SDK client instance. For example:

import { HoneyHive } from "honeyhive";

async function run() {
    const sdk = new HoneyHive({
        bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
    });

    const res = await sdk.session.startSession({
        session: {
            project: "Simple RAG Project",
            sessionName: "Playground Session",
            source: "playground",
            sessionId: "caf77ace-3417-4da4-944d-f4a0688f3c23",
            childrenIds: ["7f22137a-6911-4ed3-bc36-110f1dde6b66"],
            config: {
                key: "<value>",
            },
            inputs: {
                context: "Hello world",
                question: "What is in the context?",
                chat_history: "<value>",
            },
            outputs: {
                role: "assistant",
                content: "Hello world",
            },
            error: null,
            duration: 824.8056,
            userProperties: {
                user: "google-oauth2|111840237613341303366",
            },
            metrics: {},
            feedback: {},
            metadata: {},
            startTime: 1712025501605,
            endTime: 1712025499832,
        },
    });

    if (res.statusCode == 200) {
        // handle response
    }
}

run();

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy

0.5.1

5 days ago

0.5.0

11 days ago

0.3.14

19 days ago

0.3.13

2 months ago

0.3.12

2 months ago

0.3.11

2 months ago

0.3.9

6 months ago

0.3.8

6 months ago

0.3.7

6 months ago

0.3.6

7 months ago

0.3.5

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago