import honeyhive
from honeyhive.models import components
s = honeyhive.HoneyHive(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.metrics.create_metric(request=components.Metric(
name='<value>',
task='<value>',
type=components.MetricType.MODEL,
description='Fully-configurable neutral framework',
return_type=components.ReturnType.STRING,
))
if res is not None:
# handle response
passimport { HoneyHive } from "honeyhive";
import { MetricType, ReturnTypeT } from "honeyhive/dist/models/components";
async function run() {
const sdk = new HoneyHive({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.metrics.createMetric({
name: "<value>",
task: "<value>",
type: MetricType.Model,
description: "Fully-configurable neutral framework",
returnType: ReturnTypeT.String,
threshold: {},
});
if (res.statusCode == 200) {
// handle response
}
}
run();curl --request POST \
--url https://api.honeyhive.ai/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"task": "<string>",
"description": "<string>",
"criteria": "<string>",
"code_snippet": "<string>",
"prompt": "<string>",
"enabled_in_prod": true,
"needs_ground_truth": true,
"threshold": {
"min": 123,
"max": 123
},
"pass_when": true,
"_id": "<string>",
"event_name": "<string>",
"event_type": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
task: '<string>',
description: '<string>',
criteria: '<string>',
code_snippet: '<string>',
prompt: '<string>',
enabled_in_prod: true,
needs_ground_truth: true,
threshold: {min: 123, max: 123},
pass_when: true,
_id: '<string>',
event_name: '<string>',
event_type: '<string>'
})
};
fetch('https://api.honeyhive.ai/metrics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.honeyhive.ai/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'task' => '<string>',
'description' => '<string>',
'criteria' => '<string>',
'code_snippet' => '<string>',
'prompt' => '<string>',
'enabled_in_prod' => true,
'needs_ground_truth' => true,
'threshold' => [
'min' => 123,
'max' => 123
],
'pass_when' => true,
'_id' => '<string>',
'event_name' => '<string>',
'event_type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.honeyhive.ai/metrics"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.honeyhive.ai/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.honeyhive.ai/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyCreate a new metric
Add a new metric
import honeyhive
from honeyhive.models import components
s = honeyhive.HoneyHive(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
)
res = s.metrics.create_metric(request=components.Metric(
name='<value>',
task='<value>',
type=components.MetricType.MODEL,
description='Fully-configurable neutral framework',
return_type=components.ReturnType.STRING,
))
if res is not None:
# handle response
passimport { HoneyHive } from "honeyhive";
import { MetricType, ReturnTypeT } from "honeyhive/dist/models/components";
async function run() {
const sdk = new HoneyHive({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.metrics.createMetric({
name: "<value>",
task: "<value>",
type: MetricType.Model,
description: "Fully-configurable neutral framework",
returnType: ReturnTypeT.String,
threshold: {},
});
if (res.statusCode == 200) {
// handle response
}
}
run();curl --request POST \
--url https://api.honeyhive.ai/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"task": "<string>",
"description": "<string>",
"criteria": "<string>",
"code_snippet": "<string>",
"prompt": "<string>",
"enabled_in_prod": true,
"needs_ground_truth": true,
"threshold": {
"min": 123,
"max": 123
},
"pass_when": true,
"_id": "<string>",
"event_name": "<string>",
"event_type": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
task: '<string>',
description: '<string>',
criteria: '<string>',
code_snippet: '<string>',
prompt: '<string>',
enabled_in_prod: true,
needs_ground_truth: true,
threshold: {min: 123, max: 123},
pass_when: true,
_id: '<string>',
event_name: '<string>',
event_type: '<string>'
})
};
fetch('https://api.honeyhive.ai/metrics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.honeyhive.ai/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'task' => '<string>',
'description' => '<string>',
'criteria' => '<string>',
'code_snippet' => '<string>',
'prompt' => '<string>',
'enabled_in_prod' => true,
'needs_ground_truth' => true,
'threshold' => [
'min' => 123,
'max' => 123
],
'pass_when' => true,
'_id' => '<string>',
'event_name' => '<string>',
'event_type' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.honeyhive.ai/metrics"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.honeyhive.ai/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.honeyhive.ai/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"task\": \"<string>\",\n \"description\": \"<string>\",\n \"criteria\": \"<string>\",\n \"code_snippet\": \"<string>\",\n \"prompt\": \"<string>\",\n \"enabled_in_prod\": true,\n \"needs_ground_truth\": true,\n \"threshold\": {\n \"min\": 123,\n \"max\": 123\n },\n \"pass_when\": true,\n \"_id\": \"<string>\",\n \"event_name\": \"<string>\",\n \"event_type\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Name of the metric
Name of the project associated with metric
Type of the metric - "custom", "model" or "human"
custom, model, human Short description of what the metric does
The data type of the metric value - "boolean", "float", "string"
boolean, float, string Criteria for human metrics
Associated code block for the metric
Evaluator prompt for the metric
Whether to compute on all production events automatically
Whether a ground truth (on metadata) is required to compute it
Threshold for numeric metrics to decide passing or failing in tests
Show child attributes
Show child attributes
Threshold for boolean metrics to decide passing or failing in tests
Unique idenitifier
Name of event that the metric is set to be computed on
Type of event that the metric is set to be computed on
Response
Metric created successfully
Was this page helpful?

