gllm-inference-binary 0.5.40__cp311-cp311-win_amd64.whl → 0.5.66__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gllm_inference/builder/_build_invoker.pyi +28 -0
- gllm_inference/builder/build_em_invoker.pyi +12 -16
- gllm_inference/builder/build_lm_invoker.pyi +65 -17
- gllm_inference/constants.pyi +3 -2
- gllm_inference/em_invoker/__init__.pyi +3 -1
- gllm_inference/em_invoker/bedrock_em_invoker.pyi +16 -4
- gllm_inference/em_invoker/cohere_em_invoker.pyi +127 -0
- gllm_inference/em_invoker/jina_em_invoker.pyi +103 -0
- gllm_inference/em_invoker/schema/bedrock.pyi +7 -0
- gllm_inference/em_invoker/schema/cohere.pyi +20 -0
- gllm_inference/em_invoker/schema/jina.pyi +29 -0
- gllm_inference/exceptions/provider_error_map.pyi +1 -0
- gllm_inference/lm_invoker/__init__.pyi +3 -1
- gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +95 -109
- gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +92 -109
- gllm_inference/lm_invoker/batch/batch_operations.pyi +2 -1
- gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +52 -65
- gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +36 -36
- gllm_inference/lm_invoker/google_lm_invoker.pyi +195 -110
- gllm_inference/lm_invoker/langchain_lm_invoker.pyi +52 -64
- gllm_inference/lm_invoker/litellm_lm_invoker.pyi +86 -106
- gllm_inference/lm_invoker/lm_invoker.pyi +20 -1
- gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +87 -107
- gllm_inference/lm_invoker/openai_lm_invoker.pyi +237 -186
- gllm_inference/lm_invoker/portkey_lm_invoker.pyi +296 -0
- gllm_inference/lm_invoker/schema/google.pyi +12 -0
- gllm_inference/lm_invoker/schema/openai.pyi +22 -0
- gllm_inference/lm_invoker/schema/portkey.pyi +31 -0
- gllm_inference/lm_invoker/sea_lion_lm_invoker.pyi +48 -0
- gllm_inference/lm_invoker/xai_lm_invoker.pyi +94 -131
- gllm_inference/model/__init__.pyi +5 -1
- gllm_inference/model/em/cohere_em.pyi +17 -0
- gllm_inference/model/em/jina_em.pyi +22 -0
- gllm_inference/model/lm/anthropic_lm.pyi +2 -0
- gllm_inference/model/lm/google_lm.pyi +1 -0
- gllm_inference/model/lm/sea_lion_lm.pyi +16 -0
- gllm_inference/model/lm/xai_lm.pyi +19 -0
- gllm_inference/prompt_builder/format_strategy/__init__.pyi +4 -0
- gllm_inference/prompt_builder/format_strategy/format_strategy.pyi +55 -0
- gllm_inference/prompt_builder/format_strategy/jinja_format_strategy.pyi +45 -0
- gllm_inference/prompt_builder/format_strategy/string_format_strategy.pyi +20 -0
- gllm_inference/prompt_builder/prompt_builder.pyi +23 -6
- gllm_inference/schema/__init__.pyi +4 -3
- gllm_inference/schema/activity.pyi +13 -11
- gllm_inference/schema/attachment.pyi +20 -6
- gllm_inference/schema/enums.pyi +30 -1
- gllm_inference/schema/events.pyi +69 -73
- gllm_inference/schema/formatter.pyi +31 -0
- gllm_inference/schema/lm_output.pyi +245 -23
- gllm_inference/schema/model_id.pyi +27 -3
- gllm_inference/utils/validation.pyi +3 -0
- gllm_inference.cp311-win_amd64.pyd +0 -0
- gllm_inference.pyi +23 -13
- {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/METADATA +10 -6
- {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/RECORD +57 -40
- {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/WHEEL +0 -0
- {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/top_level.txt +0 -0
|
@@ -4,12 +4,13 @@ from pydantic import BaseModel
|
|
|
4
4
|
from typing import Literal
|
|
5
5
|
|
|
6
6
|
WEB_SEARCH_VISIBLE_FIELDS: Incomplete
|
|
7
|
+
WebSearchActivityTypes: Incomplete
|
|
7
8
|
|
|
8
9
|
class Activity(BaseModel):
|
|
9
10
|
"""Base schema for any activity.
|
|
10
11
|
|
|
11
12
|
Attributes:
|
|
12
|
-
type (str): The type of activity being performed.
|
|
13
|
+
type (str): The type of activity being performed. Defaults to an empty string.
|
|
13
14
|
"""
|
|
14
15
|
type: str
|
|
15
16
|
|
|
@@ -17,9 +18,10 @@ class MCPListToolsActivity(Activity):
|
|
|
17
18
|
"""Schema for listing tools in MCP.
|
|
18
19
|
|
|
19
20
|
Attributes:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
type (Literal[ActivityType.MCP_LIST_TOOLS]): The type of activity being performed.
|
|
22
|
+
Defaults to ActivityType.MCP_LIST_TOOLS.
|
|
23
|
+
server_name (str): The name of the MCP server. Defaults to an empty string.
|
|
24
|
+
tools (list[dict[str, str]] | None): The tools in the MCP server. Defaults to None.
|
|
23
25
|
"""
|
|
24
26
|
type: Literal[ActivityType.MCP_LIST_TOOLS]
|
|
25
27
|
server_name: str
|
|
@@ -29,10 +31,10 @@ class MCPCallActivity(Activity):
|
|
|
29
31
|
"""Schema for MCP tool call.
|
|
30
32
|
|
|
31
33
|
Attributes:
|
|
34
|
+
type (Literal[ActivityType.MCP_CALL]): The type of activity being performed. Defaults to ActivityType.MCP_CALL.
|
|
32
35
|
server_name (str): The name of the MCP server.
|
|
33
36
|
tool_name (str): The name of the tool.
|
|
34
37
|
args (dict[str, str]): The arguments of the tool.
|
|
35
|
-
type (str): The type of activity being performed.
|
|
36
38
|
"""
|
|
37
39
|
type: Literal[ActivityType.MCP_CALL]
|
|
38
40
|
server_name: str
|
|
@@ -43,16 +45,16 @@ class WebSearchActivity(Activity):
|
|
|
43
45
|
"""Schema for web search tool call.
|
|
44
46
|
|
|
45
47
|
Attributes:
|
|
46
|
-
type (
|
|
47
|
-
|
|
48
|
-
url (str): The URL of the page.
|
|
49
|
-
|
|
48
|
+
type (WebSearchActivityTypes): The type of activity being performed. Defaults to ActivityType.SEARCH.
|
|
49
|
+
query (str | None): The query of the web search. Defaults to None.
|
|
50
|
+
url (str | None): The URL of the page. Defaults to None.
|
|
51
|
+
pattern (str | None): The pattern of the web search. Defaults to None.
|
|
50
52
|
sources (list[dict[str, str]] | None): The sources of the web search.
|
|
51
53
|
"""
|
|
52
|
-
type:
|
|
54
|
+
type: WebSearchActivityTypes
|
|
55
|
+
query: str | None
|
|
53
56
|
url: str | None
|
|
54
57
|
pattern: str | None
|
|
55
|
-
query: str | None
|
|
56
58
|
sources: list[dict[str, str]] | None
|
|
57
59
|
def model_dump(self, *args, **kwargs) -> dict[str, str]:
|
|
58
60
|
"""Serialize the activity for display.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from gllm_inference.constants import HEX_REPR_LENGTH as HEX_REPR_LENGTH
|
|
3
2
|
from pydantic import BaseModel
|
|
3
|
+
from typing import Any
|
|
4
4
|
|
|
5
|
+
HEX_REPR_LENGTH: int
|
|
6
|
+
METADATA_ITEM_REPR_LENGTH: int
|
|
5
7
|
logger: Incomplete
|
|
6
8
|
|
|
7
9
|
class Attachment(BaseModel):
|
|
@@ -13,68 +15,80 @@ class Attachment(BaseModel):
|
|
|
13
15
|
mime_type (str): The mime type of the file attachment.
|
|
14
16
|
extension (str): The extension of the file attachment.
|
|
15
17
|
url (str | None): The URL of the file attachment. Defaults to None.
|
|
18
|
+
metadata (dict[str, Any]): The metadata of the file attachment. Defaults to an empty dictionary.
|
|
16
19
|
"""
|
|
17
20
|
data: bytes
|
|
18
21
|
filename: str
|
|
19
22
|
mime_type: str
|
|
20
23
|
extension: str
|
|
21
24
|
url: str | None
|
|
25
|
+
metadata: dict[str, Any]
|
|
22
26
|
@classmethod
|
|
23
|
-
def from_bytes(cls, bytes: bytes, filename: str | None = None) -> Attachment:
|
|
27
|
+
def from_bytes(cls, bytes: bytes, filename: str | None = None, metadata: dict[str, Any] | None = None) -> Attachment:
|
|
24
28
|
"""Creates an Attachment from bytes.
|
|
25
29
|
|
|
26
30
|
Args:
|
|
27
31
|
bytes (bytes): The bytes of the file.
|
|
28
32
|
filename (str | None, optional): The filename of the file. Defaults to None,
|
|
29
33
|
in which case the filename will be derived from the extension.
|
|
34
|
+
metadata (dict[str, Any] | None, optional): The metadata of the file attachment. Defaults to None,
|
|
35
|
+
in which case an empty dictionary will be used.
|
|
30
36
|
|
|
31
37
|
Returns:
|
|
32
38
|
Attachment: The instantiated Attachment.
|
|
33
39
|
"""
|
|
34
40
|
@classmethod
|
|
35
|
-
def from_base64(cls, base64_data: str, filename: str | None = None) -> Attachment:
|
|
41
|
+
def from_base64(cls, base64_data: str, filename: str | None = None, metadata: dict[str, Any] | None = None) -> Attachment:
|
|
36
42
|
"""Creates an Attachment from a base64 string.
|
|
37
43
|
|
|
38
44
|
Args:
|
|
39
45
|
base64_data (str): The base64 string of the file.
|
|
40
46
|
filename (str | None, optional): The filename of the file. Defaults to None,
|
|
41
47
|
in which case the filename will be derived from the mime type.
|
|
48
|
+
metadata (dict[str, Any] | None, optional): The metadata of the file attachment. Defaults to None,
|
|
49
|
+
in which case an empty dictionary will be used.
|
|
42
50
|
|
|
43
51
|
Returns:
|
|
44
52
|
Attachment: The instantiated Attachment.
|
|
45
53
|
"""
|
|
46
54
|
@classmethod
|
|
47
|
-
def from_data_url(cls, data_url: str, filename: str | None = None) -> Attachment:
|
|
55
|
+
def from_data_url(cls, data_url: str, filename: str | None = None, metadata: dict[str, Any] | None = None) -> Attachment:
|
|
48
56
|
"""Creates an Attachment from a data URL (data:[mime/type];base64,[bytes]).
|
|
49
57
|
|
|
50
58
|
Args:
|
|
51
59
|
data_url (str): The data URL of the file.
|
|
52
60
|
filename (str | None, optional): The filename of the file. Defaults to None,
|
|
53
61
|
in which case the filename will be derived from the mime type.
|
|
62
|
+
metadata (dict[str, Any] | None, optional): The metadata of the file attachment. Defaults to None,
|
|
63
|
+
in which case an empty dictionary will be used.
|
|
54
64
|
|
|
55
65
|
Returns:
|
|
56
66
|
Attachment: The instantiated Attachment.
|
|
57
67
|
"""
|
|
58
68
|
@classmethod
|
|
59
|
-
def from_url(cls, url: str, filename: str | None = None) -> Attachment:
|
|
69
|
+
def from_url(cls, url: str, filename: str | None = None, metadata: dict[str, Any] | None = None) -> Attachment:
|
|
60
70
|
"""Creates an Attachment from a URL.
|
|
61
71
|
|
|
62
72
|
Args:
|
|
63
73
|
url (str): The URL of the file.
|
|
64
74
|
filename (str | None, optional): The filename of the file. Defaults to None,
|
|
65
75
|
in which case the filename will be derived from the URL.
|
|
76
|
+
metadata (dict[str, Any] | None, optional): The metadata of the file attachment. Defaults to None,
|
|
77
|
+
in which case an empty dictionary will be used.
|
|
66
78
|
|
|
67
79
|
Returns:
|
|
68
80
|
Attachment: The instantiated Attachment.
|
|
69
81
|
"""
|
|
70
82
|
@classmethod
|
|
71
|
-
def from_path(cls, path: str, filename: str | None = None) -> Attachment:
|
|
83
|
+
def from_path(cls, path: str, filename: str | None = None, metadata: dict[str, Any] | None = None) -> Attachment:
|
|
72
84
|
"""Creates an Attachment from a path.
|
|
73
85
|
|
|
74
86
|
Args:
|
|
75
87
|
path (str): The path to the file.
|
|
76
88
|
filename (str | None, optional): The filename of the file. Defaults to None,
|
|
77
89
|
in which case the filename will be derived from the path.
|
|
90
|
+
metadata (dict[str, Any] | None, optional): The metadata of the file attachment. Defaults to None,
|
|
91
|
+
in which case an empty dictionary will be used.
|
|
78
92
|
|
|
79
93
|
Returns:
|
|
80
94
|
Attachment: The instantiated Attachment.
|
gllm_inference/schema/enums.pyi
CHANGED
|
@@ -9,11 +9,24 @@ class AttachmentType(StrEnum):
|
|
|
9
9
|
|
|
10
10
|
class BatchStatus(StrEnum):
|
|
11
11
|
"""Defines the status of a batch job."""
|
|
12
|
-
CANCELING = 'canceling'
|
|
13
12
|
IN_PROGRESS = 'in_progress'
|
|
14
13
|
FINISHED = 'finished'
|
|
14
|
+
FAILED = 'failed'
|
|
15
|
+
CANCELING = 'canceling'
|
|
16
|
+
EXPIRED = 'expired'
|
|
15
17
|
UNKNOWN = 'unknown'
|
|
16
18
|
|
|
19
|
+
class LMEventType(StrEnum):
|
|
20
|
+
"""Defines event types to be emitted by the LM invoker."""
|
|
21
|
+
ACTIVITY = 'activity'
|
|
22
|
+
CODE = 'code'
|
|
23
|
+
THINKING = 'thinking'
|
|
24
|
+
|
|
25
|
+
class LMEventTypeSuffix(StrEnum):
|
|
26
|
+
"""Defines suffixes for LM event types."""
|
|
27
|
+
START = '_start'
|
|
28
|
+
END = '_end'
|
|
29
|
+
|
|
17
30
|
class EmitDataType(StrEnum):
|
|
18
31
|
"""Defines valid data types for emitting events."""
|
|
19
32
|
ACTIVITY = 'activity'
|
|
@@ -24,6 +37,17 @@ class EmitDataType(StrEnum):
|
|
|
24
37
|
THINKING_START = 'thinking_start'
|
|
25
38
|
THINKING_END = 'thinking_end'
|
|
26
39
|
|
|
40
|
+
class LMOutputType(StrEnum):
|
|
41
|
+
"""Defines valid types for language model outputs."""
|
|
42
|
+
TEXT = 'text'
|
|
43
|
+
STRUCTURED = 'structured'
|
|
44
|
+
ATTACHMENT = 'attachment'
|
|
45
|
+
TOOL_CALL = 'tool_call'
|
|
46
|
+
THINKING = 'thinking'
|
|
47
|
+
CITATION = 'citation'
|
|
48
|
+
CODE_EXEC_RESULT = 'code_exec_result'
|
|
49
|
+
MCP_CALL = 'mcp_call'
|
|
50
|
+
|
|
27
51
|
class ActivityType(StrEnum):
|
|
28
52
|
"""Defines valid activity types."""
|
|
29
53
|
FIND_IN_PAGE = 'find_in_page'
|
|
@@ -44,6 +68,11 @@ class TruncateSide(StrEnum):
|
|
|
44
68
|
RIGHT = 'RIGHT'
|
|
45
69
|
LEFT = 'LEFT'
|
|
46
70
|
|
|
71
|
+
class JinjaEnvType(StrEnum):
|
|
72
|
+
"""Enumeration for Jinja environment types."""
|
|
73
|
+
JINJA_DEFAULT = 'jinja_default'
|
|
74
|
+
RESTRICTED = 'restricted'
|
|
75
|
+
|
|
47
76
|
class WebSearchKey(StrEnum):
|
|
48
77
|
"""Defines valid web search keys."""
|
|
49
78
|
PATTERN = 'pattern'
|
gllm_inference/schema/events.pyi
CHANGED
|
@@ -1,109 +1,105 @@
|
|
|
1
|
-
from
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_core.constants import EventType
|
|
2
3
|
from gllm_core.schema import Event
|
|
3
4
|
from gllm_inference.schema.activity import Activity as Activity
|
|
4
|
-
from
|
|
5
|
-
from typing import Literal
|
|
5
|
+
from typing import Any, Literal, Self
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Attributes:
|
|
11
|
-
id (str): The unique identifier for the activity event. Defaults to an UUID string.
|
|
12
|
-
type (Literal): The type of event, always 'activity'.
|
|
13
|
-
value (Activity): The activity data containing message and type.
|
|
14
|
-
level (EventLevel): The severity level of the event. Defined through the EventLevel constants.
|
|
15
|
-
"""
|
|
16
|
-
id: str
|
|
17
|
-
type: Literal[EmitDataType.ACTIVITY]
|
|
18
|
-
value: Activity
|
|
19
|
-
level: EventLevel
|
|
7
|
+
CodeEventType: Incomplete
|
|
8
|
+
ThinkingEventType: Incomplete
|
|
20
9
|
|
|
21
|
-
class
|
|
22
|
-
"""Event schema for model-triggered
|
|
10
|
+
class ActivityEvent(Event):
|
|
11
|
+
"""Event schema for model-triggered activities (e.g. web search, MCP call, etc.).
|
|
23
12
|
|
|
24
13
|
Attributes:
|
|
25
|
-
id (str): The
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
id (str): The ID of the activity event. Defaults to None.
|
|
15
|
+
value (dict[str, Any]): The value of the activity event.
|
|
16
|
+
level (EventLevel): The severity level of the activity event. Defaults to EventLevel.INFO.
|
|
17
|
+
type (Literal[EventType.ACTIVITY]): The type of the activity event. Defaults to EventType.ACTIVITY.
|
|
18
|
+
timestamp (datetime): The timestamp of the activity event. Defaults to the current timestamp.
|
|
19
|
+
metadata (dict[str, Any]): The metadata of the activity event. Defaults to an empty dictionary.
|
|
29
20
|
"""
|
|
30
|
-
|
|
31
|
-
type: Literal[
|
|
32
|
-
value: str
|
|
33
|
-
level: EventLevel
|
|
34
|
-
@classmethod
|
|
35
|
-
def start(cls, id: str | None = None) -> CodeEvent:
|
|
36
|
-
"""Create a code start event.
|
|
37
|
-
|
|
38
|
-
Args:
|
|
39
|
-
id (str | None): The unique identifier for the code event. Defaults to an UUID string.
|
|
40
|
-
|
|
41
|
-
Returns:
|
|
42
|
-
CodeEvent: The code start event.
|
|
43
|
-
"""
|
|
44
|
-
@classmethod
|
|
45
|
-
def content(cls, id: str | None = None, value: str = '') -> CodeEvent:
|
|
46
|
-
"""Create a code content event.
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
id (str | None): The unique identifier for the code event. Defaults to an UUID string.
|
|
50
|
-
value (str): The code content.
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
CodeEvent: The code value event.
|
|
54
|
-
"""
|
|
21
|
+
value: dict[str, Any]
|
|
22
|
+
type: Literal[EventType.ACTIVITY]
|
|
55
23
|
@classmethod
|
|
56
|
-
def
|
|
57
|
-
"""Create
|
|
24
|
+
def from_activity(cls, id_: str | None = None, activity: Activity | None = None) -> ActivityEvent:
|
|
25
|
+
"""Create an activity event from an Activity object.
|
|
58
26
|
|
|
59
27
|
Args:
|
|
60
|
-
|
|
28
|
+
id_ (str | None, optional): The ID of the activity event. Defaults to None.
|
|
29
|
+
activity (Activity | None, optional): The activity object to create the event from.
|
|
30
|
+
Defaults to None, in which case the value will be an empty dictionary.
|
|
61
31
|
|
|
62
32
|
Returns:
|
|
63
|
-
|
|
33
|
+
ActivityEvent: The activity event.
|
|
64
34
|
"""
|
|
65
35
|
|
|
66
|
-
class
|
|
67
|
-
"""Event schema
|
|
36
|
+
class BlockBasedEvent(Event):
|
|
37
|
+
"""Event schema block-based events, which are limited by start and end events.
|
|
68
38
|
|
|
69
39
|
Attributes:
|
|
70
|
-
id (str): The
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
id (str): The ID of the block-based event. Defaults to None.
|
|
41
|
+
value (str): The value of the block-based event. Defaults to an empty string.
|
|
42
|
+
level (EventLevel): The severity level of the block-based event. Defaults to EventLevel.INFO.
|
|
43
|
+
type (str): The type of the block-based event. Defaults to an empty string.
|
|
44
|
+
timestamp (datetime): The timestamp of the block-based event. Defaults to the current timestamp.
|
|
45
|
+
metadata (dict[str, Any]): The metadata of the block-based event. Defaults to an empty dictionary.
|
|
74
46
|
"""
|
|
75
|
-
id: str
|
|
76
|
-
type: Literal[EmitDataType.THINKING, EmitDataType.THINKING_START, EmitDataType.THINKING_END]
|
|
77
47
|
value: str
|
|
78
|
-
|
|
48
|
+
type: str
|
|
79
49
|
@classmethod
|
|
80
|
-
def start(cls,
|
|
81
|
-
"""Create a
|
|
50
|
+
def start(cls, id_: str | None = None) -> Self:
|
|
51
|
+
"""Create a block-based start event.
|
|
82
52
|
|
|
83
53
|
Args:
|
|
84
|
-
|
|
54
|
+
id_ (str | None, optional): The ID of the block-based event. Defaults to None.
|
|
85
55
|
|
|
86
56
|
Returns:
|
|
87
|
-
|
|
57
|
+
Self: The block-based start event.
|
|
88
58
|
"""
|
|
89
59
|
@classmethod
|
|
90
|
-
def content(cls,
|
|
91
|
-
"""Create a
|
|
60
|
+
def content(cls, id_: str | None = None, value: str = '') -> Self:
|
|
61
|
+
"""Create a block-based content event.
|
|
92
62
|
|
|
93
63
|
Args:
|
|
94
|
-
|
|
95
|
-
value (str): The
|
|
64
|
+
id_ (str | None, optional): The ID of the block-based event. Defaults to None.
|
|
65
|
+
value (str, optional): The block-based content. Defaults to an empty string.
|
|
96
66
|
|
|
97
67
|
Returns:
|
|
98
|
-
|
|
68
|
+
Self: The block-based content event.
|
|
99
69
|
"""
|
|
100
70
|
@classmethod
|
|
101
|
-
def end(cls,
|
|
102
|
-
"""Create a
|
|
71
|
+
def end(cls, id_: str | None = None) -> Self:
|
|
72
|
+
"""Create a block-based end event.
|
|
103
73
|
|
|
104
74
|
Args:
|
|
105
|
-
|
|
75
|
+
id_ (str | None, optional): The ID of the block-based event. Defaults to None.
|
|
106
76
|
|
|
107
77
|
Returns:
|
|
108
|
-
|
|
78
|
+
Self: The block-based end event.
|
|
109
79
|
"""
|
|
80
|
+
|
|
81
|
+
class CodeEvent(BlockBasedEvent):
|
|
82
|
+
"""Event schema for model-generated code to be executed.
|
|
83
|
+
|
|
84
|
+
Attributes:
|
|
85
|
+
id (str): The ID of the code event. Defaults to None.
|
|
86
|
+
value (str): The value of the code event. Defaults to an empty string.
|
|
87
|
+
level (EventLevel): The severity level of the code event. Defaults to EventLevel.INFO.
|
|
88
|
+
type (CodeEventType): The type of the code event. Defaults to EventType.CODE.
|
|
89
|
+
timestamp (datetime): The timestamp of the code event. Defaults to the current timestamp.
|
|
90
|
+
metadata (dict[str, Any]): The metadata of the code event. Defaults to an empty dictionary.
|
|
91
|
+
"""
|
|
92
|
+
type: CodeEventType
|
|
93
|
+
|
|
94
|
+
class ThinkingEvent(BlockBasedEvent):
|
|
95
|
+
"""Event schema for model-generated thinking.
|
|
96
|
+
|
|
97
|
+
Attributes:
|
|
98
|
+
id (str): The ID of the thinking event. Defaults to None.
|
|
99
|
+
value (str): The value of the thinking event. Defaults to an empty string.
|
|
100
|
+
level (EventLevel): The severity level of the thinking event. Defaults to EventLevel.INFO.
|
|
101
|
+
type (ThinkingEventType): The type of the thinking event. Defaults to EventType.THINKING.
|
|
102
|
+
timestamp (datetime): The timestamp of the thinking event. Defaults to the current timestamp.
|
|
103
|
+
metadata (dict[str, Any]): The metadata of the thinking event. Defaults to an empty dictionary.
|
|
104
|
+
"""
|
|
105
|
+
type: ThinkingEventType
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from gllm_inference.schema.enums import MessageRole as MessageRole
|
|
2
|
+
from gllm_inference.schema.message import Message as Message
|
|
3
|
+
from gllm_inference.schema.type_alias import MessageContent as MessageContent
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
class HistoryFormatter(BaseModel):
|
|
7
|
+
"""Configuration for history formatting.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
prefix_user_message (str): Prefix for user messages.
|
|
11
|
+
suffix_user_message (str): Suffix for user messages.
|
|
12
|
+
prefix_assistant_message (str): Prefix for assistant messages.
|
|
13
|
+
suffix_assistant_message (str): Suffix for assistant messages.
|
|
14
|
+
"""
|
|
15
|
+
prefix_user_message: str
|
|
16
|
+
suffix_user_message: str
|
|
17
|
+
prefix_assistant_message: str
|
|
18
|
+
suffix_assistant_message: str
|
|
19
|
+
def format_history(self, history: list[Message]) -> list[Message]:
|
|
20
|
+
"""Formats a list of messages based on their roles.
|
|
21
|
+
|
|
22
|
+
This method formats each message in the history list by applying the appropriate
|
|
23
|
+
formatting based on the message role (user or assistant). Other message types
|
|
24
|
+
are added to the result without modification.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
history (list[Message]): The list of messages to format.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
list[Message]: A new list containing the formatted messages.
|
|
31
|
+
"""
|