Skip to content

Commit 9645a46

Browse files
committed
Merge branch 'main' into gen_ai_flags
2 parents f6aef69 + b1b9505 commit 9645a46

File tree

1 file changed

+45
-0
lines changed
  • util/opentelemetry-util-genai/src/opentelemetry/util/genai

1 file changed

+45
-0
lines changed

util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
16+
from dataclasses import dataclass
1517
from enum import Enum
18+
from typing import Any, Literal, Optional, Union
1619

1720

1821
class ContentCapturingMode(Enum):
@@ -24,3 +27,45 @@ class ContentCapturingMode(Enum):
2427
EVENT_ONLY = 2
2528
# Capture content in both spans and events.
2629
SPAN_AND_EVENT = 3
30+
31+
32+
@dataclass()
33+
class ToolCall:
34+
type: Literal["tool_call"] = "tool_call"
35+
arguments: Any
36+
name: str
37+
id: Optional[str]
38+
39+
40+
@dataclass()
41+
class ToolCallResponse:
42+
type: Literal["tool_call_response"] = "tool_call_response"
43+
response: Any
44+
id: Optional[str]
45+
46+
47+
FinishReason = Literal[
48+
"content_filter", "error", "length", "stop", "tool_calls"
49+
]
50+
51+
52+
@dataclass()
53+
class Text:
54+
type: Literal["text"] = "text"
55+
content: str
56+
57+
58+
MessagePart = Union[Text, ToolCall, ToolCallResponse, Any]
59+
60+
61+
@dataclass()
62+
class InputMessage:
63+
role: str
64+
parts: list[MessagePart]
65+
66+
67+
@dataclass()
68+
class OutputMessage:
69+
role: str
70+
parts: list[MessagePart]
71+
finish_reason: Union[str, FinishReason]

0 commit comments

Comments
 (0)