honeyhive v0.5.1
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
- startSession - Start a new session
- getSession - Retrieve a session
events
- createEvent - Create a new event
- updateEvent - Update an event
- getEvents - Retrieve events based on filters
metrics
- getMetrics - Get all metrics
- createMetric - Create a new metric
- updateMetric - Update an existing metric
- deleteMetric - Delete a metric
tools
- getTools - Retrieve a list of tools
- createTool - Create a new tool
- updateTool - Update an existing tool
- deleteTool - Delete a tool
datapoints
- getDatapoints - Retrieve a list of datapoints
- createDatapoint - Create a new datapoint
- getDatapoint - Retrieve a specific datapoint
- updateDatapoint - Update a specific datapoint
- deleteDatapoint - Delete a specific datapoint
datasets
- getDatasets - Get datasets
- createDataset - Create a dataset
- updateDataset - Update a dataset
- deleteDataset - Delete a dataset
projects
- getProjects - Get a list of projects
- createProject - Create a new project
- updateProject - Update an existing project
- deleteProject - Delete a project
configurations
- getConfigurations - Retrieve a list of configurations
- createConfiguration - Create a new configuration
- updateConfiguration - Update an existing configuration
- deleteConfiguration - Delete a configuration
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 Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-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:
# | Server | Variables |
---|---|---|
0 | https://api.honeyhive.ai | None |
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:
Name | Type | Scheme |
---|---|---|
bearerAuth | http | HTTP 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!