|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/* |
| 18 | + * This file contains a copy of unstable semantic convention definitions |
| 19 | + * used by this package. |
| 20 | + * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * The name of the operation being performed. |
| 25 | + * |
| 26 | + * @note If one of the predefined values applies, but specific system uses a different name it's **RECOMMENDED** to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries **SHOULD** use applicable predefined value. |
| 27 | + * |
| 28 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 29 | + */ |
| 30 | +export const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const; |
| 31 | + |
| 32 | +/** |
| 33 | + * The maximum number of tokens the model generates for a request. |
| 34 | + * |
| 35 | + * @example 100 |
| 36 | + * |
| 37 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 38 | + */ |
| 39 | +export const ATTR_GEN_AI_REQUEST_MAX_TOKENS = |
| 40 | + 'gen_ai.request.max_tokens' as const; |
| 41 | + |
| 42 | +/** |
| 43 | + * The name of the GenAI model a request is being made to. |
| 44 | + * |
| 45 | + * @example "gpt-4" |
| 46 | + * |
| 47 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 48 | + */ |
| 49 | +export const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const; |
| 50 | + |
| 51 | +/** |
| 52 | + * List of sequences that the model will use to stop generating further tokens. |
| 53 | + * |
| 54 | + * @example ["forest", "lived"] |
| 55 | + * |
| 56 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 57 | + */ |
| 58 | +export const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES = |
| 59 | + 'gen_ai.request.stop_sequences' as const; |
| 60 | + |
| 61 | +/** |
| 62 | + * The temperature setting for the GenAI request. |
| 63 | + * |
| 64 | + * @example 0.0 |
| 65 | + * |
| 66 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 67 | + */ |
| 68 | +export const ATTR_GEN_AI_REQUEST_TEMPERATURE = |
| 69 | + 'gen_ai.request.temperature' as const; |
| 70 | + |
| 71 | +/** |
| 72 | + * The top_p sampling setting for the GenAI request. |
| 73 | + * |
| 74 | + * @example 1.0 |
| 75 | + * |
| 76 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 77 | + */ |
| 78 | +export const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const; |
| 79 | + |
| 80 | +/** |
| 81 | + * Array of reasons the model stopped generating tokens, corresponding to each generation received. |
| 82 | + * |
| 83 | + * @example ["stop"] |
| 84 | + * @example ["stop", "length"] |
| 85 | + * |
| 86 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 87 | + */ |
| 88 | +export const ATTR_GEN_AI_RESPONSE_FINISH_REASONS = |
| 89 | + 'gen_ai.response.finish_reasons' as const; |
| 90 | + |
| 91 | +/** |
| 92 | + * The Generative AI product as identified by the client or server instrumentation. |
| 93 | + * |
| 94 | + * @example "openai" |
| 95 | + * |
| 96 | + * @note The `gen_ai.system` describes a family of GenAI models with specific model identified |
| 97 | + * by `gen_ai.request.model` and `gen_ai.response.model` attributes. |
| 98 | + * |
| 99 | + * The actual GenAI product may differ from the one identified by the client. |
| 100 | + * Multiple systems, including Azure OpenAI and Gemini, are accessible by OpenAI client |
| 101 | + * libraries. In such cases, the `gen_ai.system` is set to `openai` based on the |
| 102 | + * instrumentation's best knowledge, instead of the actual system. The `server.address` |
| 103 | + * attribute may help identify the actual system in use for `openai`. |
| 104 | + * |
| 105 | + * For custom model, a custom friendly name **SHOULD** be used. |
| 106 | + * If none of these options apply, the `gen_ai.system` **SHOULD** be set to `_OTHER`. |
| 107 | + * |
| 108 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 109 | + */ |
| 110 | +export const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const; |
| 111 | + |
| 112 | +/** |
| 113 | + * The number of tokens used in the GenAI input (prompt). |
| 114 | + * |
| 115 | + * @example 100 |
| 116 | + * |
| 117 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 118 | + */ |
| 119 | +export const ATTR_GEN_AI_USAGE_INPUT_TOKENS = |
| 120 | + 'gen_ai.usage.input_tokens' as const; |
| 121 | + |
| 122 | +/** |
| 123 | + * The number of tokens used in the GenAI response (completion). |
| 124 | + * |
| 125 | + * @example 180 |
| 126 | + * |
| 127 | + * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. |
| 128 | + */ |
| 129 | +export const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS = |
| 130 | + 'gen_ai.usage.output_tokens' as const; |
| 131 | + |
| 132 | +/** |
| 133 | + * Enum value "chat" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}. |
| 134 | + */ |
| 135 | +export const GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat' as const; |
| 136 | + |
| 137 | +/** |
| 138 | + * Enum value "aws.bedrock" for attribute {@link ATTR_GEN_AI_SYSTEM}. |
| 139 | + */ |
| 140 | +export const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock' as const; |
0 commit comments