|
| 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 | +from dataclasses import dataclass |
| 17 | +from typing import Any, Literal, Optional, Union |
| 18 | + |
| 19 | + |
| 20 | +@dataclass() |
| 21 | +class ToolCall: |
| 22 | + type: Literal["tool_call"] = "tool_call" |
| 23 | + arguments: Any |
| 24 | + name: str |
| 25 | + id: Optional[str] |
| 26 | + |
| 27 | + |
| 28 | +@dataclass() |
| 29 | +class ToolCallResponse: |
| 30 | + type: Literal["tool_call_response"] = "tool_call_response" |
| 31 | + response: Any |
| 32 | + id: Optional[str] |
| 33 | + |
| 34 | + |
| 35 | +FinishReason = Literal[ |
| 36 | + "content_filter", "error", "length", "stop", "tool_calls" |
| 37 | +] |
| 38 | + |
| 39 | + |
| 40 | +@dataclass() |
| 41 | +class Text: |
| 42 | + type: Literal["text"] = "text" |
| 43 | + content: str |
| 44 | + |
| 45 | + |
| 46 | +MessagePart = Union[Text, ToolCall, ToolCallResponse, Any] |
| 47 | + |
| 48 | + |
| 49 | +@dataclass() |
| 50 | +class InputMessage: |
| 51 | + role: str |
| 52 | + parts: list[MessagePart] |
| 53 | + |
| 54 | + |
| 55 | +@dataclass() |
| 56 | +class OutputMessage: |
| 57 | + role: str |
| 58 | + parts: list[MessagePart] |
| 59 | + finish_reason: Union[str, FinishReason] |
0 commit comments