Skip to content

Commit e6f2702

Browse files
committed
Add loongsuite extended handler and attributes for incubating semconv
Change-Id: Ib41743c6729ac1aa384a3a7ecf22bd6442f427cb Co-developed-by: Cursor <[email protected]>
1 parent cb29e82 commit e6f2702

File tree

8 files changed

+3061
-0
lines changed

8 files changed

+3061
-0
lines changed

util/opentelemetry-util-genai/README-loongsuite.rst

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Extended semantic convention attributes for GenAI operations.
17+
These attributes are not yet available in the standard opentelemetry-semantic-conventions package.
18+
"""
19+
20+
from enum import Enum
21+
from typing import Final
22+
23+
# Common attributes
24+
GEN_AI_TOOL_DEFINITIONS: Final = "gen_ai.tool.definitions"
25+
"""
26+
The tool definitions used by the model.
27+
"""
28+
29+
# Embedding attributes
30+
GEN_AI_EMBEDDINGS_DIMENSION_COUNT: Final = "gen_ai.embeddings.dimension.count"
31+
"""
32+
The dimensionality of the embedding vectors generated by the model.
33+
"""
34+
35+
# Tool call attributes
36+
GEN_AI_TOOL_CALL_ARGUMENTS: Final = "gen_ai.tool.call.arguments"
37+
"""
38+
The arguments or parameters passed to the tool during invocation.
39+
"""
40+
41+
GEN_AI_TOOL_CALL_RESULT: Final = "gen_ai.tool.call.result"
42+
"""
43+
The result returned by the tool after execution.
44+
"""
45+
46+
# Retrieve attributes
47+
GEN_AI_RETRIEVAL_QUERY: Final = "gen_ai.retrieval.query"
48+
"""
49+
The query string used to retrieve documents from a vector database or search system.
50+
"""
51+
52+
GEN_AI_RETRIEVAL_DOCUMENTS: Final = "gen_ai.retrieval.documents"
53+
"""
54+
The documents retrieved from the search or vector database.
55+
"""
56+
57+
# Rerank attributes
58+
GEN_AI_RERANK_DOCUMENTS_COUNT: Final = "gen_ai.rerank.documents.count"
59+
"""
60+
The number of documents provided as input to the reranking operation.
61+
"""
62+
63+
GEN_AI_RERANK_SCORING_PROMPT: Final = "gen_ai.rerank.scoring_prompt"
64+
"""
65+
Custom scoring prompt used by LLM-based rerankers to evaluate document relevance.
66+
"""
67+
68+
GEN_AI_RERANK_RETURN_DOCUMENTS: Final = "gen_ai.rerank.return_documents"
69+
"""
70+
Whether the reranker should return the full document content in the response.
71+
"""
72+
73+
GEN_AI_RERANK_MAX_CHUNKS_PER_DOC: Final = "gen_ai.rerank.max_chunks_per_doc"
74+
"""
75+
Maximum number of chunks to consider per document during reranking.
76+
"""
77+
78+
GEN_AI_RERANK_DEVICE: Final = "gen_ai.rerank.device"
79+
"""
80+
The computation device used for inference in model-based rerankers.
81+
"""
82+
83+
GEN_AI_RERANK_BATCH_SIZE: Final = "gen_ai.rerank.batch_size"
84+
"""
85+
The batch size used for processing documents during reranking.
86+
"""
87+
88+
GEN_AI_RERANK_MAX_LENGTH: Final = "gen_ai.rerank.max_length"
89+
"""
90+
Maximum sequence length for tokenization in the reranking model.
91+
"""
92+
93+
GEN_AI_RERANK_NORMALIZE: Final = "gen_ai.rerank.normalize"
94+
"""
95+
Whether to normalize the relevance scores returned by the reranker.
96+
"""
97+
98+
GEN_AI_RERANK_INPUT_DOCUMENTS: Final = "gen_ai.rerank.input_documents"
99+
"""
100+
The documents provided as input to the reranking operation.
101+
"""
102+
103+
GEN_AI_RERANK_OUTPUT_DOCUMENTS: Final = "gen_ai.rerank.output_documents"
104+
"""
105+
The reranked documents returned by the reranking operation.
106+
"""
107+
108+
109+
class GenAiExtendedOperationNameValues(Enum):
110+
RETRIEVE_DOCUMENTS = "retrieve_documents"
111+
"""Retrieve documents operation."""
112+
113+
RERANK_DOCUMENTS = "rerank_documents"
114+
"""Rerank documents operation."""
115+
116+
117+
class GenAiExtendedProviderNameValues(Enum):
118+
DASHSCOPE = "dashscope"
119+
"""DashScope."""

0 commit comments

Comments
 (0)