From 18478910c247ceebc5730f53a0228eeb7adc547b Mon Sep 17 00:00:00 2001 From: colegottdank Date: Mon, 13 May 2024 10:33:56 -0700 Subject: [PATCH 1/7] change kafka consumption rate (#1897) --- valhalla/jawn/src/lib/clients/KafkaConsumer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/valhalla/jawn/src/lib/clients/KafkaConsumer.ts b/valhalla/jawn/src/lib/clients/KafkaConsumer.ts index 50ccfcdedc..d3b3ef9777 100644 --- a/valhalla/jawn/src/lib/clients/KafkaConsumer.ts +++ b/valhalla/jawn/src/lib/clients/KafkaConsumer.ts @@ -49,8 +49,8 @@ if (KAFKA_ENABLED && KAFKA_BROKER && KAFKA_USERNAME && KAFKA_PASSWORD) { // Average message is 1kB, so we can set minBytes to 1kB and maxBytes to 10kB const consumer = kafka?.consumer({ groupId: "jawn-consumer", - minBytes: 1000, // 1 kB - maxBytes: 200_000, // 200 kB + minBytes: 100_000, + maxBytes: 10_000_000, }); export const consume = async () => { @@ -90,7 +90,7 @@ export const consume = async () => { commitOffsetsIfNecessary, }) => { console.log(`Received batch with ${batch.messages.length} messages.`); - const maxMessages = 100; + const maxMessages = 150; const miniBatches = createMiniBatches(batch.messages, maxMessages); for (const miniBatch of miniBatches) { From ba60aa1d8b86e4268d8408e9212e95023831f7f1 Mon Sep 17 00:00:00 2001 From: Scott <50155740+ScottMktn@users.noreply.github.com> Date: Mon, 13 May 2024 10:52:04 -0700 Subject: [PATCH 2/7] add-koala (#1896) --- web/pages/_app.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index 7c81266972..b7642ecd0c 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -17,6 +17,7 @@ import { DndProvider } from "react-dnd"; import { HTML5Backend } from "react-dnd-html5-backend"; import { OrgContextProvider } from "../components/layout/organizationContext"; import { ThemeContextProvider } from "../components/shared/theme/themeContext"; +import Script from "next/script"; if ( typeof window !== "undefined" && @@ -67,6 +68,16 @@ export default function MyApp({ Component, pageProps }: AppPropsWithLayout) { {trackingEnabled && } + {trackingEnabled && ( + `, + }} + /> + )} ); } From 8e7b461d361c85030b59666daca52242213e47c2 Mon Sep 17 00:00:00 2001 From: Scott <50155740+ScottMktn@users.noreply.github.com> Date: Mon, 13 May 2024 11:08:33 -0700 Subject: [PATCH 3/7] fix-lang (#1894) --- web/pages/blog/langsmith/src.mdx | 89 -------------------------------- 1 file changed, 89 deletions(-) diff --git a/web/pages/blog/langsmith/src.mdx b/web/pages/blog/langsmith/src.mdx index 43ca3d1478..019db6d575 100644 --- a/web/pages/blog/langsmith/src.mdx +++ b/web/pages/blog/langsmith/src.mdx @@ -98,97 +98,8 @@ Finally, Helicone places a strong focus on developer experience. Its simple inte --- -## Don't Take Our Word for It - - - - - - - - - - - ---- - ## Stay Ahead with Helicone. → Try Helicone for Free → Get in Touch With Us -<<<<<<< HEAD -======= - -> > > > > > > origin/main From 2dda3484589966312f36d190a849f604ed8e7e42 Mon Sep 17 00:00:00 2001 From: LinaLam <65078897+LinaLam@users.noreply.github.com> Date: Mon, 13 May 2024 11:27:54 -0700 Subject: [PATCH 4/7] Header directory rewrite (#1887) --- docs/features/prompts.mdx | 2 +- docs/getting-started/quick-start.mdx | 14 +-- docs/helicone-headers/header-directory.mdx | 121 +++++++++++++++++---- 3 files changed, 101 insertions(+), 36 deletions(-) diff --git a/docs/features/prompts.mdx b/docs/features/prompts.mdx index 5f06d16ed1..59a83d07f0 100644 --- a/docs/features/prompts.mdx +++ b/docs/features/prompts.mdx @@ -127,7 +127,7 @@ Let's say we have an app that generates a short story, where users are able to i Assigning an id allows us to associate your prompt with future versions of your prompt, and automatically manage versions on your behalf. - Depending on the package you are using, you will need to add a header. For more information on adding headers to packages, please see [Header Directory](/header-directory). + Depending on the package you are using, you will need to add a header. For more information on adding headers to packages, please see [Header Directory](/helicone-headers/header-directory). ```tsx headers: { diff --git a/docs/getting-started/quick-start.mdx b/docs/getting-started/quick-start.mdx index ebd33ee170..37e947a7e5 100644 --- a/docs/getting-started/quick-start.mdx +++ b/docs/getting-started/quick-start.mdx @@ -13,13 +13,6 @@ description: "Helicone is the observability platform purpose-built for LLM devel ## Quick Start Integrate with Helicone and send your first events in seconds. - - - - The optimal method to integrate with Helicone is through our Gateway. - - - Python, Node, cURL, Langchain @@ -44,14 +37,15 @@ Integrate with Helicone and send your first events in seconds. + + Don't see your provider above? Try Helicone's universal Gateway. + ## New to Helicone? To help you get the most out of Helicone, we curated a list of actions that you can do next. Our users typically find themselves doing majority of the following, but you're welcome to explore the product on your own! - - Label your requests. We will walk you through how to segment, analyze, and visualize them. @@ -182,7 +176,6 @@ Discover features for monitoring and experimenting with your prompts. - ## Further Reading @@ -197,7 +190,6 @@ Discover features for monitoring and experimenting with your prompts. - ## Questions? Although we designed the docs to be as self-serving as possible, you are welcome to join our [Discord](https://discord.com/invite/HwUbV3Q8qz) or contact [help@helicone.ai](help@helicone.ai) with any questions or feedback you have. diff --git a/docs/helicone-headers/header-directory.mdx b/docs/helicone-headers/header-directory.mdx index bb8fe10ce2..8cd684cc95 100644 --- a/docs/helicone-headers/header-directory.mdx +++ b/docs/helicone-headers/header-directory.mdx @@ -1,14 +1,15 @@ --- title: "Header Directory" -description: Every header you need to know to access Helicone features and unlock advanced observability capabilities. +description: Every header you need to know to access Helicone features. --- + ```bash Curl curl https://gateway.hconeai.com/v1/completions \ -H 'Content-Type: application/json' \ - -H 'Helicone-Auth: Bearer HELICONE_API_KEY' \ - -H 'Helicone-
: ' + -H 'Helicone-Auth: Bearer HELICONE_API_KEY' \ # required header + -H 'Helicone-
: ' # all headers will follow this format -d ... ``` @@ -18,8 +19,8 @@ openai.Completion.create( model="text-davinci-003", prompt="This is a test", headers={ - "Helicone-Auth": f"Bearer {HELICONE_API_KEY}", - "Helicone-
": "", + "Helicone-Auth": f"Bearer {HELICONE_API_KEY}", # required header + "Helicone-
": "", # all headers will follow this format } ) ``` @@ -28,8 +29,8 @@ openai.Completion.create( const openai = new OpenAI({ baseURL: "https://gateway.hconeai.com/v1", defaultHeaders: { - "Helicone-Auth": `Bearer [HELICONE_API_KEY]`, - "Helicone-
": "", + "Helicone-Auth": `Bearer [HELICONE_API_KEY]`, // required header + "Helicone-
": "", // all headers will follow this format }, }); ``` @@ -41,8 +42,8 @@ const configuration = new Configuration({ basePath: "https://gateway.hconeai.com", baseOptions: { headers: { - "Helicone-Auth": `Bearer [HELICONE_API_KEY]`, - "Helicone-
": "", + "Helicone-Auth": `Bearer [HELICONE_API_KEY]`, // required header + "Helicone-
": "", // all headers will follow this format }, }, }); @@ -55,8 +56,8 @@ llm = ChatOpenAI( openai_api_key="", openai_api_base="https://gateway.hconeai.com/v1", headers={ - "Helicone-Auth": "Bearer ", - "Helicone-
": "", + "Helicone-Auth": "Bearer ", # required header + "Helicone-
": "", # all headers will follow this format } ) ``` @@ -67,8 +68,8 @@ const model = new ChatOpenAI({ configuration: { organization: "[organization]", defaultHeaders: { - "Helicone-Auth": `Bearer ${heliconeApiKey}`, - "Helicone-
": "", + "Helicone-Auth": `Bearer ${heliconeApiKey}`, // required header + "Helicone-
": "", // all headers will follow this format }, }, }); @@ -76,18 +77,90 @@ const model = new ChatOpenAI({ ## Supported Headers + + + This is the first header you will use, which authenticates you to send requests to the Helicone API. Here's the format: `"Helicone-Auth": "Bearer "`. Remember to replace it with your actual Helicone API key. + + + The URL to proxy the request to when using _gateway.hconeai.com_. For example, `https://api.openai.com/`. + + + The URL to proxy the request to when using _oai.hconeai.com_. For example, `https://[YOUR_AZURE_DOMAIN].openai.azure.com`. + + + The ID of the request, in the format: `123e4567-e89b-12d3-a456-426614174000` + + + Overrides the model used to calculate costs and mapping. Useful for when the model does not exist in URL, request or response. For example, `gpt-4-1106-preview`. + + + Assigning an ID allows Helicone to associate your prompt with future versions of your prompt, and automatically manage versions on your behalf. For example, both `prompt_story` and `this is the first prompt` are valid. + + + Custom Properties allow you to add any additional information to your requests, such as session, conversation, or app IDs. Here are some examples of custom property headers and values: `Helicone-Property-Session: 121`, `Helicone-Property-App: mobile`, or `Helicone-Property-MyUser: John Doe`. There are no restrictions on the value. + + + Specify the user making the request to track and analyze user metrics, such as the number of requests, costs, and activity associated with that particular user. For example, `alicebob@gmail.com` or `db513bc9-ff1b-4747-a47b-7750d0c701d3` are both valid. + + + Utilize any provider through a single endpoint by setting fallbacks. See how it's used in [Gateway Fallbacks](https://docs.helicone.ai/getting-started/integration-method/gateway-fallbacks). + + + Set up a rate limit policy. The value should follow the format: `[quota];w=[time_window];u=[unit];s=[segment]`. For example, `10;w=1000;u=cents;s=user` is a policy that allows 10 cents of requests per 1000 seconds per user. + + -| Header Name | Type | Description | Example | -| ------------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | -| Helicone-Target-URL | string (url) | The URL to proxy the request to when using gateway.hconeai.com | https://api.openai.com/v1/engines/davinci/completions | -| Helicone-OpenAI-Api-Base | string (url) | The URL to proxy the request to when using oai.hconeai.com | https://[YOUR_AZURE_DOMAIN].openai.azure.com | -| Helicone-Request-Id | string (uuid) | The ID of the request | 123e4567-e89b-12d3-a456-426614174000 | -| Helicone-Omit-Response | boolean | Whether to exclude the response from the request | true | -| Helicone-Omit-Request | boolean | Whether to exclude the request from the response | true | -| Helicone-Model-Override | string (model) | Overrides the model used to calculate costs and mapping. Useful for when the model does not exist in url, request or response | gpt-4-1106-preview | ## Feature Flags + + + Whether to exclude the response from the request. Set to `true` or `false`. + + + Whether to exclude the request from the response. Set to `true` or `false`. + + + Whether to cache your responses. Set to `true` or `false`. You can customize the behavior of the cache feature by setting additional headers in your request. + + | Parameter | Description | + | --------------------------------- | ------------------------------------------------- | + | `Cache-control` | Configure cache limit in `seconds`. | + | `Helicone-Cache-Bucket-Max-Size` | Configure cache bucket size as a `number`. | + | `Helicone-Cache-Seed` | Generate predictable results and maintain separate cache states for each cache seed, type `string`. | + + + + Retry requests to overcome rate limits and overloaded servers. Set to `true` or `false`. + You can customize the behavior of the retries feature by setting additional headers in your request. + + | Parameter | Description | + | ---------------------------- | ------------------------------------------------- | + | `helicone-retry-num` | Number of retries | + | `helicone-retry-factor` | Exponential backoff factor | + | `helicone-retry-min-timeout` | Minimum timeout (in milliseconds) between retries | + | `helicone-retry-max-timeout` | Maximum timeout (in milliseconds) between retries | + + + + Activate OpenAI moderation to safeguard your chat completions. Set to `true` or `false`. + + + Secure OpenAI chat completions against prompt injections. Set to `true` or `false`. + + + Enforce proper stream formatting for libraries that do not inherently support it, such as Ruby. Set to `true` or `false`. + + + +## Response Headers + +| Headers | Description | +| ----------------------------------------- | ------------------------------------------------------------------------------- | +| `Helicone-Id` | Indicates the ID of the request. ! +| `Helicone-Cache` | Indicates whether the response was cached. Returns `HIT` or `MISS`. | +| `Helicone-Cache-Bucket-Idx` | Indicates the cache bucket index used as a `number`. | +| `Helicone-Fallback-Index` | Indicates fallback idex used as a `number`. | +| `Helicone-RateLimit-Limit` | Indicates the quota for the `number` of requests allowed in the time window. | +| `Helicone-RateLimit-Remaining` | Indicates the remaining quota in the current window as a `number`. | +| `Helicone-RateLimit-Policy` | Indicates the active rate limit policy.| -| Header Name | Type | Description | Example | -| ---------------------------- | ------- | ----------------------------------------------------------------------------------------------- | ------- | -| Helicone-Stream-Force-Format | boolean | Enforce proper stream formatting for libraries that do not inherently support it, such as Ruby. | true | From 442d066b0931b77a20a9a885c1e4d7281fe1cb1e Mon Sep 17 00:00:00 2001 From: Scott <50155740+ScottMktn@users.noreply.github.com> Date: Mon, 13 May 2024 11:37:36 -0700 Subject: [PATCH 5/7] koala (#1899) * add-koala * script --------- Co-authored-by: Scott Nguyen --- web/pages/_app.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index b7642ecd0c..11b36c4ab3 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -72,9 +72,7 @@ export default function MyApp({ Component, pageProps }: AppPropsWithLayout) { `, + __html: `!function(t){if(window.ko)return;window.ko=[],["identify","track","removeListeners","open","on","off","qualify","ready"].forEach(function(t){ko[t]=function(){var n=[].slice.call(arguments);return n.unshift(t),ko.push(n),ko}});var n=document.createElement("script");n.async=!0,n.setAttribute("src","https://cdn.getkoala.com/v1/pk_3d24ae9e69e18decfcb68b9d7b668c4501b5/sdk.js"),(document.body || document.head).appendChild(n)}();`, }} /> )} From fb0c459ff96de786c30dc3e83793362603497c33 Mon Sep 17 00:00:00 2001 From: Justin Torre Date: Mon, 13 May 2024 12:09:10 -0700 Subject: [PATCH 6/7] gpt4o support (#1901) --- costs/__tests__/ensureOnlyOne.ts | 137 ++++++++++++++++++ costs/src/providers/mappings.ts | 2 +- costs/src/providers/openai/index.ts | 22 +++ .../src/packages/cost/providers/mappings.ts | 2 +- .../packages/cost/providers/openai/index.ts | 22 +++ web/packages/cost/providers/mappings.ts | 2 +- web/packages/cost/providers/openai/index.ts | 22 +++ .../src/packages/cost/providers/mappings.ts | 2 +- .../packages/cost/providers/openai/index.ts | 22 +++ 9 files changed, 229 insertions(+), 4 deletions(-) diff --git a/costs/__tests__/ensureOnlyOne.ts b/costs/__tests__/ensureOnlyOne.ts index 03066aa8c8..54be3a5fb7 100644 --- a/costs/__tests__/ensureOnlyOne.ts +++ b/costs/__tests__/ensureOnlyOne.ts @@ -91,6 +91,14 @@ test("cost calc snapshot test", () => { "name": "gpt-4-1106-vision-preview", "provider": "OPENAI" }, + { + "name": "gpt-4o", + "provider": "OPENAI" + }, + { + "name": "gpt-4o-2024-05-13", + "provider": "OPENAI" + }, { "name": "gpt-3.5-turbo-0613", "provider": "OPENAI" @@ -126,6 +134,94 @@ test("cost calc snapshot test", () => { { "name": "claude-3-haiku-20240307", "provider": "ANTHROPIC" + }, + { + "name": "gpt-3.5-turbo", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-0301", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-1106", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-instruct", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-instruct-0914", + "provider": "AZURE" + }, + { + "name": "gpt-4", + "provider": "AZURE" + }, + { + "name": "gpt-4-0314", + "provider": "AZURE" + }, + { + "name": "gpt-4-0613", + "provider": "AZURE" + }, + { + "name": "gpt-4-32k", + "provider": "AZURE" + }, + { + "name": "gpt-4-32k-0314", + "provider": "AZURE" + }, + { + "name": "gpt-4-32k-0613", + "provider": "AZURE" + }, + { + "name": "gpt-4-0125-preview", + "provider": "AZURE" + }, + { + "name": "gpt-4-1106-preview", + "provider": "AZURE" + }, + { + "name": "gpt-4-1106-vision-preview", + "provider": "AZURE" + }, + { + "name": "gpt-4o", + "provider": "AZURE" + }, + { + "name": "gpt-4o-2024-05-13", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-0613", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-16k-0613", + "provider": "AZURE" + }, + { + "name": "gpt-3.5-turbo-0125", + "provider": "AZURE" + }, + { + "name": "gpt-4-turbo", + "provider": "AZURE" + }, + { + "name": "gpt-4-turbo-2024-04-09", + "provider": "AZURE" + }, + { + "name": "gpt-4-turbo-0125-preview", + "provider": "AZURE" } ]" `); @@ -163,6 +259,45 @@ WHEN (request_response_log.model = 'gpt35') THEN 1500 * request_response_log.pro WHEN (request_response_log.model = 'gpt-35-turbo-0613') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-35-16k') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-4-vision') THEN 10000 * request_response_log.prompt_tokens + 300000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'ada') THEN 400 * request_response_log.prompt_tokens + 400 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-ada-001') THEN 400 * request_response_log.prompt_tokens + 400 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'babbage') THEN 500 * request_response_log.prompt_tokens + 500 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'curie') THEN 2000 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-curie-001') THEN 2000 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'davinci') THEN 20000 * request_response_log.prompt_tokens + 20000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-davinci-001') THEN 20000 * request_response_log.prompt_tokens + 20000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-davinci-002') THEN 20000 * request_response_log.prompt_tokens + 20000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-davinci-003') THEN 20000 * request_response_log.prompt_tokens + 20000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-0301') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-35-turbo') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-1106') THEN 1000 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-instruct') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-instruct-0914') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4') THEN 30000 * request_response_log.prompt_tokens + 60000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-0314') THEN 30000 * request_response_log.prompt_tokens + 60000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-0613') THEN 30000 * request_response_log.prompt_tokens + 60000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-32k') THEN 60000 * request_response_log.prompt_tokens + 120000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-32k-0314') THEN 60000 * request_response_log.prompt_tokens + 120000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-32k-0613') THEN 60000 * request_response_log.prompt_tokens + 120000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-0125-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-1106-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-1106-vision-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4o') THEN 15000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4o-2024-05-13') THEN 15000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-0613') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-35-turbo-16k') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-16k-0613') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-3.5-turbo-0125') THEN 500 * request_response_log.prompt_tokens + 1500 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-turbo') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-turbo-2024-04-09') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-turbo-0125-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-embedding-ada-002') THEN 100 * request_response_log.prompt_tokens + 0 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-embedding-ada') THEN 100 * request_response_log.prompt_tokens + 0 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-embedding-ada-002-v2') THEN 100 * request_response_log.prompt_tokens + 0 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'text-embedding-3-small') THEN 20 * request_response_log.prompt_tokens + 0 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4-vision-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-35-turbo-16k-0613') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens ELSE 0 END ) @@ -449,6 +584,8 @@ WHEN (request_response_log.model = 'gpt-4-32k-0613') THEN 60000 * request_respon WHEN (request_response_log.model = 'gpt-4-0125-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-4-1106-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-4-1106-vision-preview') THEN 10000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4o') THEN 15000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens +WHEN (request_response_log.model = 'gpt-4o-2024-05-13') THEN 15000 * request_response_log.prompt_tokens + 30000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-3.5-turbo-0613') THEN 1500 * request_response_log.prompt_tokens + 2000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-35-turbo-16k') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens WHEN (request_response_log.model = 'gpt-3.5-turbo-16k-0613') THEN 3000 * request_response_log.prompt_tokens + 4000 * request_response_log.completion_tokens diff --git a/costs/src/providers/mappings.ts b/costs/src/providers/mappings.ts index f830fd2d62..3065d9b393 100644 --- a/costs/src/providers/mappings.ts +++ b/costs/src/providers/mappings.ts @@ -77,7 +77,7 @@ export const providers: { { pattern: azurePattern, provider: "AZURE", - costs: azureCosts, + costs: [...azureCosts, ...openaiCosts], }, { pattern: localProxyPattern, diff --git a/costs/src/providers/openai/index.ts b/costs/src/providers/openai/index.ts index 77e8db60ce..fe397b954f 100644 --- a/costs/src/providers/openai/index.ts +++ b/costs/src/providers/openai/index.ts @@ -260,6 +260,28 @@ export const costs: ModelRow[] = [ }, showInPlayground: true, }, + { + model: { + operator: "equals", + value: "gpt-4o", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, + { + model: { + operator: "equals", + value: "gpt-4o-2024-05-13", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, { model: { operator: "equals", diff --git a/valhalla/jawn/src/packages/cost/providers/mappings.ts b/valhalla/jawn/src/packages/cost/providers/mappings.ts index f830fd2d62..3065d9b393 100644 --- a/valhalla/jawn/src/packages/cost/providers/mappings.ts +++ b/valhalla/jawn/src/packages/cost/providers/mappings.ts @@ -77,7 +77,7 @@ export const providers: { { pattern: azurePattern, provider: "AZURE", - costs: azureCosts, + costs: [...azureCosts, ...openaiCosts], }, { pattern: localProxyPattern, diff --git a/valhalla/jawn/src/packages/cost/providers/openai/index.ts b/valhalla/jawn/src/packages/cost/providers/openai/index.ts index 77e8db60ce..fe397b954f 100644 --- a/valhalla/jawn/src/packages/cost/providers/openai/index.ts +++ b/valhalla/jawn/src/packages/cost/providers/openai/index.ts @@ -260,6 +260,28 @@ export const costs: ModelRow[] = [ }, showInPlayground: true, }, + { + model: { + operator: "equals", + value: "gpt-4o", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, + { + model: { + operator: "equals", + value: "gpt-4o-2024-05-13", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, { model: { operator: "equals", diff --git a/web/packages/cost/providers/mappings.ts b/web/packages/cost/providers/mappings.ts index f830fd2d62..3065d9b393 100644 --- a/web/packages/cost/providers/mappings.ts +++ b/web/packages/cost/providers/mappings.ts @@ -77,7 +77,7 @@ export const providers: { { pattern: azurePattern, provider: "AZURE", - costs: azureCosts, + costs: [...azureCosts, ...openaiCosts], }, { pattern: localProxyPattern, diff --git a/web/packages/cost/providers/openai/index.ts b/web/packages/cost/providers/openai/index.ts index 77e8db60ce..fe397b954f 100644 --- a/web/packages/cost/providers/openai/index.ts +++ b/web/packages/cost/providers/openai/index.ts @@ -260,6 +260,28 @@ export const costs: ModelRow[] = [ }, showInPlayground: true, }, + { + model: { + operator: "equals", + value: "gpt-4o", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, + { + model: { + operator: "equals", + value: "gpt-4o-2024-05-13", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, { model: { operator: "equals", diff --git a/worker/src/packages/cost/providers/mappings.ts b/worker/src/packages/cost/providers/mappings.ts index f830fd2d62..3065d9b393 100644 --- a/worker/src/packages/cost/providers/mappings.ts +++ b/worker/src/packages/cost/providers/mappings.ts @@ -77,7 +77,7 @@ export const providers: { { pattern: azurePattern, provider: "AZURE", - costs: azureCosts, + costs: [...azureCosts, ...openaiCosts], }, { pattern: localProxyPattern, diff --git a/worker/src/packages/cost/providers/openai/index.ts b/worker/src/packages/cost/providers/openai/index.ts index 77e8db60ce..fe397b954f 100644 --- a/worker/src/packages/cost/providers/openai/index.ts +++ b/worker/src/packages/cost/providers/openai/index.ts @@ -260,6 +260,28 @@ export const costs: ModelRow[] = [ }, showInPlayground: true, }, + { + model: { + operator: "equals", + value: "gpt-4o", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, + { + model: { + operator: "equals", + value: "gpt-4o-2024-05-13", + }, + cost: { + prompt_token: 0.000015, + completion_token: 0.00003, + }, + showInPlayground: true, + }, { model: { operator: "equals", From 8ff1400f867e9f2e78a177a1d2fdcfc9a2293ac5 Mon Sep 17 00:00:00 2001 From: Scott <50155740+ScottMktn@users.noreply.github.com> Date: Mon, 13 May 2024 12:30:12 -0700 Subject: [PATCH 7/7] node package fix (#1903) --- docs/integrations/openai/node.mdx | 89 +++++++++++++++---------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/docs/integrations/openai/node.mdx b/docs/integrations/openai/node.mdx index f039f80563..81507c0a6c 100644 --- a/docs/integrations/openai/node.mdx +++ b/docs/integrations/openai/node.mdx @@ -53,48 +53,47 @@ const openai = new OpenAIApi(configuration); ## Package Integration - - - Log into www.helicone.ai or create an account. Once you have an account, you - can generate an [API key](https://helicone.ai/developer). - - -```javascript -export HELICONE_API_KEY= -``` - - - - -```javascript OpenAI V4+ -import OpenAI from "openai"; - -const openai = new OpenAI({ - apiKey: request.env.OPENAI_API_KEY, - baseURL: "https://oai.hconeai.com/v1", - defaultHeaders: { - "Helicone-Auth": `Bearer ${request.env.HELICONE_API_KEY}`, - }, -}); -``` - -```javascript OpenAI - - - + + + ```bash + npm install @helicone/helicone + ``` + + + ```bash + export HELICONE_API_KEY=sk- + ``` + You can also set the Helicone API Key in your code (See below) + + + ```typescript + const { ClientOptions, OpenAI } = require("openai"); + ``` + + with + + ```typescript + const { HeliconeAsyncOpenAI as OpenAI, + IHeliconeAsyncClientOptions as ClientOptions } = require("helicone"); + ``` + + + Chat, Completion, Embedding, etc usage is equivalent to OpenAI package. + ```typescript + const openai = new OpenAI({ + apiKey: process.env.OPENAI_API_KEY, + heliconeMeta: { + apiKey: process.env.HELICONE_API_KEY, // Can be set as env variable + // ... additional helicone meta fields + }, + }); + + const chatCompletion = await openai.chat.completion.create({ + model: "gpt-3.5-turbo", + messages: [{ role: "user", content: "Hello world" }], + }); + + console.log(chatCompletion.data.choices[0].message); + ``` + +