Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

featChange `anthropic.completions` to `anthropic.messages` (#95)

Patcher993810d2c078f7
diff --git a/docs/0.0.5/connections/grafanacloud.mdx b/docs/0.0.5/connections/grafanacloud.mdx
index e9218294..2b9b3c30 100644
--- a/docs/0.0.5/connections/grafanacloud.mdx
+++ b/docs/0.0.5/connections/grafanacloud.mdx
@@ -1021,7 +1021,7 @@ curl --request POST \
"legendFormat": "__auto",
"range": true,
"rawQuery": true,
- "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM doku\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
+ "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.messages%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM doku\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
"refId": "A",
"sql": {
"columns": [
diff --git a/docs/0.0.5/connections/grafanaoss.mdx b/docs/0.0.5/connections/grafanaoss.mdx
index ce236a73..465cadaa 100644
--- a/docs/0.0.5/connections/grafanaoss.mdx
+++ b/docs/0.0.5/connections/grafanaoss.mdx
@@ -838,7 +838,7 @@ Grafana will attempt to connect to the database using the provided settings. If
"editorMode": "code",
"format": "table",
"rawQuery": true,
- "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM DOKU_LLM_DATA\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
+ "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.messages%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM DOKU_LLM_DATA\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
"refId": "A",
"sql": {
"columns": [
diff --git a/docs/0.0.6/connections/grafanacloud.mdx b/docs/0.0.6/connections/grafanacloud.mdx
index 3025d1f7..ac921511 100644
--- a/docs/0.0.6/connections/grafanacloud.mdx
+++ b/docs/0.0.6/connections/grafanacloud.mdx
@@ -1021,7 +1021,7 @@ curl --request POST \
"legendFormat": "__auto",
"range": true,
"rawQuery": true,
- "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM doku\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
+ "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.messages%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM doku\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
"refId": "A",
"sql": {
"columns": [
diff --git a/docs/0.0.6/connections/grafanaoss.mdx b/docs/0.0.6/connections/grafanaoss.mdx
index ce236a73..465cadaa 100644
--- a/docs/0.0.6/connections/grafanaoss.mdx
+++ b/docs/0.0.6/connections/grafanaoss.mdx
@@ -838,7 +838,7 @@ Grafana will attempt to connect to the database using the provided settings. If
"editorMode": "code",
"format": "table",
"rawQuery": true,
- "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM DOKU_LLM_DATA\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
+ "rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.messages%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM DOKU_LLM_DATA\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
"refId": "A",
"sql": {
"columns": [
diff --git a/src/client/src/lib/doku/category.ts b/src/client/src/lib/doku/category.ts
index c4386953..bda2f41f 100644
--- a/src/client/src/lib/doku/category.ts
+++ b/src/client/src/lib/doku/category.ts
@@ -15,7 +15,7 @@ FROM
CASE
WHEN endpoint LIKE 'openai.chat%' THEN '${GENERATION_CATEGORIZATION.chat}'
WHEN endpoint LIKE 'openai.completions%' THEN '${GENERATION_CATEGORIZATION.chat}'
- WHEN endpoint LIKE 'anthropic.completions%' THEN '${GENERATION_CATEGORIZATION.chat}'
+ WHEN endpoint LIKE 'anthropic.messages%' THEN '${GENERATION_CATEGORIZATION.chat}'
WHEN endpoint LIKE 'cohere.summarize%' THEN '${GENERATION_CATEGORIZATION.chat}'
WHEN endpoint LIKE 'cohere.generate%' THEN '${GENERATION_CATEGORIZATION.chat}'
WHEN endpoint LIKE 'cohere.chat%' THEN '${GENERATION_CATEGORIZATION.chat}'
diff --git a/src/ingester/connections/connections.go b/src/ingester/connections/connections.go
index 07fac122..f7c2d468 100644
--- a/src/ingester/connections/connections.go
+++ b/src/ingester/connections/connections.go
@@ -25,7 +25,7 @@ var (
"cohere.generate": "Chat",
"cohere.chat": "Chat",
"cohere.summarize": "Chat",
- "anthropic.completions": "Chat",
+ "anthropic.messages": "Chat",
"openai.embeddings": "Embeddings",
"cohere.embed": "Embeddings",
"openai.images.create": "Image",
diff --git a/src/ingester/connections/datadog.go b/src/ingester/connections/datadog.go
index 207279ee..b316aea1 100644
--- a/src/ingester/connections/datadog.go
+++ b/src/ingester/connections/datadog.go
@@ -32,7 +32,7 @@ func configureDataDogData(data map[string]interface{}, config ConnectionConfig)
call_type = "Unknown"
}
- if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.completions" {
+ if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.messages" {
if data["finishReason"] == nil {
data["finishReason"] = "null"
}
diff --git a/src/ingester/connections/dynatrace.go b/src/ingester/connections/dynatrace.go
index c6eb6562..1158ffe8 100644
--- a/src/ingester/connections/dynatrace.go
+++ b/src/ingester/connections/dynatrace.go
@@ -3,10 +3,11 @@ package connections
import (
"bytes"
"fmt"
- "github.com/rs/zerolog/log"
"io"
"net/http"
"strings"
+
+ "github.com/rs/zerolog/log"
)
func configureDynatraceData(data map[string]interface{}, config ConnectionConfig) {
@@ -29,7 +30,7 @@ func configureDynatraceData(data map[string]interface{}, config ConnectionConfig
call_type = "Unknown"
}
- if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.completions" {
+ if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.messages" {
if data["finishReason"] == nil {
data["finishReason"] = "null"
}
diff --git a/src/ingester/connections/grafana-cloud.go b/src/ingester/connections/grafana-cloud.go
index d627623d..1c201608 100644
--- a/src/ingester/connections/grafana-cloud.go
+++ b/src/ingester/connections/grafana-cloud.go
@@ -36,7 +36,7 @@ func configureGrafanaCloudData(data map[string]interface{}, config ConnectionCon
call_type = "Unknown"
}
- if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.completions" {
+ if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.messages" {
if data["finishReason"] == nil {
data["finishReason"] = "null"
}
diff --git a/src/ingester/connections/newrelic.go b/src/ingester/connections/newrelic.go
index 00ce80e2..6e4dd844 100644
--- a/src/ingester/connections/newrelic.go
+++ b/src/ingester/connections/newrelic.go
@@ -34,7 +34,7 @@ func configureNewRelicData(data map[string]interface{}, config ConnectionConfig)
call_type = "Unknown"
}
- if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.completions" {
+ if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.messages" {
if data["finishReason"] == nil {
data["finishReason"] = "null"
}
diff --git a/src/ingester/connections/signoz.go b/src/ingester/connections/signoz.go
index efe0df96..de66e5ee 100644
--- a/src/ingester/connections/signoz.go
+++ b/src/ingester/connections/signoz.go
@@ -29,7 +29,7 @@ func configureSignozData(data map[string]interface{}, config ConnectionConfig) {
call_type = "Unknown"
}
- if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.completions" {
+ if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "anthropic.messages" {
if data["finishReason"] == nil {
data["finishReason"] = "null"
}
diff --git a/src/ingester/db/db.go b/src/ingester/db/db.go
index 54fe8d7d..705c023d 100644
--- a/src/ingester/db/db.go
+++ b/src/ingester/db/db.go
@@ -259,7 +259,7 @@ func insertDataToDB(data map[string]interface{}) (string, int) {
// Calculate usage cost based on the endpoint type
if data["endpoint"] == "openai.embeddings" || data["endpoint"] == "cohere.embed" {
data["usageCost"], _ = cost.CalculateEmbeddingsCost(data["promptTokens"].(float64), data["model"].(string))
- } else if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "cohere.generate" {
+ } else if data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions" || data["endpoint"] == "cohere.chat" || data["endpoint"] == "cohere.summarize" || data["endpoint"] == "cohere.generate" || data["endpoint"] == "anthropic.messages" {
if data["completionTokens"] != nil && data["promptTokens"] != nil {
data["usageCost"], _ = cost.CalculateChatCost(data["promptTokens"].(float64), data["completionTokens"].(float64), data["model"].(string))
} else if (data["endpoint"] == "openai.chat.completions" || data["endpoint"] == "openai.completions") && data["prompt"] != nil && data["response"] != nil {