gllm-inference-binary 0.5.43__cp313-cp313-win_amd64.whl → 0.5.45__cp313-cp313-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/lm_invoker/lm_invoker.pyi +1 -1
- 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 +19 -6
- gllm_inference/schema/__init__.pyi +2 -2
- gllm_inference/schema/activity.pyi +13 -11
- gllm_inference/schema/enums.pyi +15 -0
- gllm_inference/schema/events.pyi +57 -42
- gllm_inference.cp313-win_amd64.pyd +0 -0
- gllm_inference.pyi +6 -1
- {gllm_inference_binary-0.5.43.dist-info → gllm_inference_binary-0.5.45.dist-info}/METADATA +2 -2
- {gllm_inference_binary-0.5.43.dist-info → gllm_inference_binary-0.5.45.dist-info}/RECORD +16 -12
- {gllm_inference_binary-0.5.43.dist-info → gllm_inference_binary-0.5.45.dist-info}/WHEEL +0 -0
- {gllm_inference_binary-0.5.43.dist-info → gllm_inference_binary-0.5.45.dist-info}/top_level.txt +0 -0
|
@@ -7,7 +7,7 @@ from gllm_core.utils import RetryConfig
|
|
|
7
7
|
from gllm_inference.constants import DOCUMENT_MIME_TYPES as DOCUMENT_MIME_TYPES, INVOKER_DEFAULT_TIMEOUT as INVOKER_DEFAULT_TIMEOUT
|
|
8
8
|
from gllm_inference.exceptions import BaseInvokerError as BaseInvokerError, convert_to_base_invoker_error as convert_to_base_invoker_error
|
|
9
9
|
from gllm_inference.lm_invoker.batch import BatchOperations as BatchOperations
|
|
10
|
-
from gllm_inference.schema import
|
|
10
|
+
from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, BatchStatus as BatchStatus, LMEventType as LMEventType, LMInput as LMInput, LMOutput as LMOutput, Message as Message, MessageContent as MessageContent, MessageRole as MessageRole, ModelId as ModelId, Reasoning as Reasoning, ResponseSchema as ResponseSchema, ToolCall as ToolCall, ToolResult as ToolResult
|
|
11
11
|
from langchain_core.tools import Tool as LangChainTool
|
|
12
12
|
from typing import Any
|
|
13
13
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
from gllm_inference.prompt_builder.format_strategy.jinja_format_strategy import JinjaFormatStrategy as JinjaFormatStrategy
|
|
2
|
+
from gllm_inference.prompt_builder.format_strategy.string_format_strategy import StringFormatStrategy as StringFormatStrategy
|
|
3
|
+
|
|
4
|
+
__all__ = ['StringFormatStrategy', 'JinjaFormatStrategy']
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from gllm_inference.schema.message import MessageContent as MessageContent
|
|
5
|
+
|
|
6
|
+
class BasePromptFormattingStrategy(ABC, metaclass=abc.ABCMeta):
|
|
7
|
+
"""Base class for prompt formatting strategies.
|
|
8
|
+
|
|
9
|
+
This class defines the interface for different prompt templating engines. Subclasses
|
|
10
|
+
implement specific formatting strategies to render templates with variable
|
|
11
|
+
substitution.
|
|
12
|
+
|
|
13
|
+
The strategy pattern allows the PromptBuilder to work with different templating engines
|
|
14
|
+
without changing its core logic.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
key_defaults (dict[str, str]): The default values for the keys.
|
|
18
|
+
"""
|
|
19
|
+
key_defaults: Incomplete
|
|
20
|
+
def __init__(self, key_defaults: dict[str, str] | None = None) -> None:
|
|
21
|
+
"""Initialize the BasePromptFormattingStrategy.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
key_defaults (dict[str, str] | None, optional): The default values for the keys. Defaults to None,
|
|
25
|
+
in which case no default values are used.
|
|
26
|
+
"""
|
|
27
|
+
def format(self, template: str, variables_map: dict[str, str] | None = None, extra_contents: list[MessageContent] | None = None) -> list[str]:
|
|
28
|
+
"""Format template with variables using the template method pattern.
|
|
29
|
+
|
|
30
|
+
This is a template method that defines the algorithm for formatting:
|
|
31
|
+
1. Merge key_defaults and variables_map
|
|
32
|
+
2. Render the template (delegated to subclass via _render_template)
|
|
33
|
+
3. Append extra_contents to the result
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
template (str): Template string to format.
|
|
37
|
+
variables_map (dict[str, str] | None, optional): Variables for substitution. Defaults to None.
|
|
38
|
+
extra_contents (list[MessageContent] | None, optional): Extra contents to format. Defaults to None.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
str: Formatted template string.
|
|
42
|
+
"""
|
|
43
|
+
@abstractmethod
|
|
44
|
+
def extract_keys(self, template: str | None) -> set[str]:
|
|
45
|
+
"""Extract variable keys from template.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
template (str | None): Template string to extract keys from.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
set[str]: Set of variable keys found in template.
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
NotImplementedError: If the method is not implemented.
|
|
55
|
+
"""
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_inference.prompt_builder.format_strategy.format_strategy import BasePromptFormattingStrategy as BasePromptFormattingStrategy
|
|
3
|
+
from gllm_inference.schema import JinjaEnvType as JinjaEnvType
|
|
4
|
+
from jinja2.sandbox import SandboxedEnvironment
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
JINJA_DEFAULT_BLACKLISTED_FILTERS: list[str]
|
|
8
|
+
JINJA_DEFAULT_SAFE_GLOBALS: dict[str, Any]
|
|
9
|
+
JINJA_DANGEROUS_PATTERNS: list[str]
|
|
10
|
+
PROMPT_BUILDER_VARIABLE_START_STRING: str
|
|
11
|
+
PROMPT_BUILDER_VARIABLE_END_STRING: str
|
|
12
|
+
|
|
13
|
+
class JinjaFormatStrategy(BasePromptFormattingStrategy):
|
|
14
|
+
"""Jinja2 template engine for formatting prompts.
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
jinja_env (SandboxedEnvironment): The Jinja environment for rendering templates.
|
|
18
|
+
key_defaults (dict[str, str]): The default values for the keys.
|
|
19
|
+
"""
|
|
20
|
+
jinja_env: Incomplete
|
|
21
|
+
def __init__(self, environment: JinjaEnvType | SandboxedEnvironment = ..., key_defaults: dict[str, str] | None = None) -> None:
|
|
22
|
+
"""Initialize the JinjaFormatStrategy.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
environment (JinjaEnvType | SandboxedEnvironment, optional): The environment for Jinja rendering.
|
|
26
|
+
It can be one of the following:
|
|
27
|
+
1. `JinjaEnvType.RESTRICTED`: Uses a minimal, restricted Jinja environment.
|
|
28
|
+
Safest for most cases.
|
|
29
|
+
2. `JinjaEnvType.JINJA_DEFAULT`: Uses the full Jinja environment. Allows more powerful templating,
|
|
30
|
+
but with fewer safety restrictions.
|
|
31
|
+
3. `SandboxedEnvironment` instance: A custom Jinja `SandboxedEnvironment` object provided by the
|
|
32
|
+
user. Offers fine-grained control over template execution.
|
|
33
|
+
Defaults to `JinjaEnvType.RESTRICTED`
|
|
34
|
+
key_defaults (dict[str, str], optional): The default values for the keys. Defaults to None, in which
|
|
35
|
+
case no default values are used.
|
|
36
|
+
"""
|
|
37
|
+
def extract_keys(self, template: str | None) -> set[str]:
|
|
38
|
+
"""Extract keys from Jinja template using AST analysis.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
template (str | None): The template to extract keys from.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
set[str]: The set of keys found in the template.
|
|
45
|
+
"""
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_inference.prompt_builder.format_strategy.format_strategy import BasePromptFormattingStrategy as BasePromptFormattingStrategy
|
|
3
|
+
|
|
4
|
+
KEY_EXTRACTOR_REGEX: Incomplete
|
|
5
|
+
|
|
6
|
+
class StringFormatStrategy(BasePromptFormattingStrategy):
|
|
7
|
+
"""String format strategy using str.format() method.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
key_defaults (dict[str, str]): The default values for the keys.
|
|
11
|
+
"""
|
|
12
|
+
def extract_keys(self, template: str | None) -> set[str]:
|
|
13
|
+
"""Extract keys from a template.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
template (str | None): The template to extract keys from.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
set[str]: The set of keys found in the template.
|
|
20
|
+
"""
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from gllm_inference.
|
|
2
|
+
from gllm_inference.prompt_builder.format_strategy import JinjaFormatStrategy as JinjaFormatStrategy, StringFormatStrategy as StringFormatStrategy
|
|
3
|
+
from gllm_inference.schema import JinjaEnvType as JinjaEnvType, Message as Message, MessageContent as MessageContent, MessageRole as MessageRole
|
|
4
|
+
from jinja2.sandbox import SandboxedEnvironment as SandboxedEnvironment
|
|
3
5
|
from typing import Any
|
|
4
6
|
|
|
5
|
-
KEY_EXTRACTOR_REGEX: Incomplete
|
|
6
|
-
|
|
7
7
|
class PromptBuilder:
|
|
8
8
|
"""A prompt builder class used in Gen AI applications.
|
|
9
9
|
|
|
@@ -12,12 +12,14 @@ class PromptBuilder:
|
|
|
12
12
|
user_template (str): The user prompt template. May contain placeholders enclosed in curly braces `{}`.
|
|
13
13
|
prompt_key_set (set[str]): A set of expected keys that must be present in the prompt templates.
|
|
14
14
|
key_defaults (dict[str, str]): Default values for the keys in the prompt templates.
|
|
15
|
+
strategy (BasePromptFormattingStrategy): The format strategy to be used for formatting the prompt.
|
|
15
16
|
"""
|
|
17
|
+
key_defaults: Incomplete
|
|
16
18
|
system_template: Incomplete
|
|
17
19
|
user_template: Incomplete
|
|
20
|
+
strategy: Incomplete
|
|
18
21
|
prompt_key_set: Incomplete
|
|
19
|
-
key_defaults:
|
|
20
|
-
def __init__(self, system_template: str = '', user_template: str = '', key_defaults: dict[str, str] | None = None, ignore_extra_keys: bool | None = None) -> None:
|
|
22
|
+
def __init__(self, system_template: str = '', user_template: str = '', key_defaults: dict[str, str] | None = None, ignore_extra_keys: bool | None = None, use_jinja: bool = False, jinja_env: JinjaEnvType | SandboxedEnvironment = ...) -> None:
|
|
21
23
|
"""Initializes a new instance of the PromptBuilder class.
|
|
22
24
|
|
|
23
25
|
Args:
|
|
@@ -30,6 +32,17 @@ class PromptBuilder:
|
|
|
30
32
|
Defaults to None, in which case no default values will be assigned to the keys.
|
|
31
33
|
ignore_extra_keys (bool | None, optional): Deprecated parameter. Will be removed in v0.6. Extra keys
|
|
32
34
|
will always raise a warning only instead of raising an error.
|
|
35
|
+
use_jinja (bool, optional): Whether to use Jinja for rendering the prompt templates.
|
|
36
|
+
Defaults to False.
|
|
37
|
+
jinja_env (JinjaEnvType | SandboxedEnvironment, optional): The environment for Jinja rendering.
|
|
38
|
+
It can be one of the following:
|
|
39
|
+
1. `JinjaEnvType.RESTRICTED`: Uses a minimal, restricted Jinja environment.
|
|
40
|
+
Safest for most cases.
|
|
41
|
+
2. `JinjaEnvType.JINJA_DEFAULT`: Uses the full Jinja environment. Allows more powerful templating,
|
|
42
|
+
but with fewer safety restrictions.
|
|
43
|
+
3. `SandboxedEnvironment` instance: A custom Jinja `SandboxedEnvironment` object provided by the
|
|
44
|
+
user. Offers fine-grained control over template execution.
|
|
45
|
+
Defaults to `JinjaEnvType.RESTRICTED`
|
|
33
46
|
|
|
34
47
|
Raises:
|
|
35
48
|
ValueError: If both `system_template` and `user_template` are empty.
|
|
@@ -49,7 +62,7 @@ class PromptBuilder:
|
|
|
49
62
|
Values must be either a string or an object that can be serialized to a string.
|
|
50
63
|
|
|
51
64
|
Returns:
|
|
52
|
-
list[Message]: A
|
|
65
|
+
list[Message]: A list of formatted messages.
|
|
53
66
|
|
|
54
67
|
Raises:
|
|
55
68
|
ValueError: If a required key for the prompt template is missing from `kwargs`.
|
|
@@ -2,7 +2,7 @@ from gllm_inference.schema.activity import Activity as Activity, MCPCallActivity
|
|
|
2
2
|
from gllm_inference.schema.attachment import Attachment as Attachment
|
|
3
3
|
from gllm_inference.schema.code_exec_result import CodeExecResult as CodeExecResult
|
|
4
4
|
from gllm_inference.schema.config import TruncationConfig as TruncationConfig
|
|
5
|
-
from gllm_inference.schema.enums import AttachmentType as AttachmentType, BatchStatus as BatchStatus, EmitDataType as EmitDataType, MessageRole as MessageRole, TruncateSide as TruncateSide
|
|
5
|
+
from gllm_inference.schema.enums import AttachmentType as AttachmentType, BatchStatus as BatchStatus, EmitDataType as EmitDataType, JinjaEnvType as JinjaEnvType, LMEventType as LMEventType, MessageRole as MessageRole, TruncateSide as TruncateSide
|
|
6
6
|
from gllm_inference.schema.events import ActivityEvent as ActivityEvent, CodeEvent as CodeEvent, ThinkingEvent as ThinkingEvent
|
|
7
7
|
from gllm_inference.schema.lm_input import LMInput as LMInput
|
|
8
8
|
from gllm_inference.schema.lm_output import LMOutput as LMOutput
|
|
@@ -15,4 +15,4 @@ from gllm_inference.schema.tool_call import ToolCall as ToolCall
|
|
|
15
15
|
from gllm_inference.schema.tool_result import ToolResult as ToolResult
|
|
16
16
|
from gllm_inference.schema.type_alias import EMContent as EMContent, MessageContent as MessageContent, ResponseSchema as ResponseSchema, Vector as Vector
|
|
17
17
|
|
|
18
|
-
__all__ = ['Activity', 'ActivityEvent', 'Attachment', 'AttachmentType', 'BatchStatus', 'CodeEvent', 'CodeExecResult', 'EMContent', 'EmitDataType', 'InputTokenDetails', 'LMInput', 'LMOutput', 'MCPCall', 'MCPCallActivity', 'MCPListToolsActivity', 'MCPServer', 'Message', 'MessageContent', 'MessageRole', 'ModelId', 'ModelProvider', 'OutputTokenDetails', 'Reasoning', 'ThinkingEvent', 'ResponseSchema', 'TokenUsage', 'ToolCall', 'ToolResult', 'TruncateSide', 'TruncationConfig', 'Vector', 'WebSearchActivity']
|
|
18
|
+
__all__ = ['Activity', 'ActivityEvent', 'Attachment', 'AttachmentType', 'BatchStatus', 'CodeEvent', 'CodeExecResult', 'EMContent', 'EmitDataType', 'LMEventType', 'InputTokenDetails', 'JinjaEnvType', 'LMInput', 'LMOutput', 'MCPCall', 'MCPCallActivity', 'MCPListToolsActivity', 'MCPServer', 'Message', 'MessageContent', 'MessageRole', 'ModelId', 'ModelProvider', 'OutputTokenDetails', 'Reasoning', 'ThinkingEvent', 'ResponseSchema', 'TokenUsage', 'ToolCall', 'ToolResult', 'TruncateSide', 'TruncationConfig', 'Vector', 'WebSearchActivity']
|
|
@@ -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.
|
gllm_inference/schema/enums.pyi
CHANGED
|
@@ -14,6 +14,16 @@ class BatchStatus(StrEnum):
|
|
|
14
14
|
FINISHED = 'finished'
|
|
15
15
|
UNKNOWN = 'unknown'
|
|
16
16
|
|
|
17
|
+
class LMEventType(StrEnum):
|
|
18
|
+
"""Defines event types to be emitted by the LM invoker."""
|
|
19
|
+
ACTIVITY = 'activity'
|
|
20
|
+
CODE_START = 'code_start'
|
|
21
|
+
CODE = 'code'
|
|
22
|
+
CODE_END = 'code_end'
|
|
23
|
+
THINKING_START = 'thinking_start'
|
|
24
|
+
THINKING = 'thinking'
|
|
25
|
+
THINKING_END = 'thinking_end'
|
|
26
|
+
|
|
17
27
|
class EmitDataType(StrEnum):
|
|
18
28
|
"""Defines valid data types for emitting events."""
|
|
19
29
|
ACTIVITY = 'activity'
|
|
@@ -44,6 +54,11 @@ class TruncateSide(StrEnum):
|
|
|
44
54
|
RIGHT = 'RIGHT'
|
|
45
55
|
LEFT = 'LEFT'
|
|
46
56
|
|
|
57
|
+
class JinjaEnvType(StrEnum):
|
|
58
|
+
"""Enumeration for Jinja environment types."""
|
|
59
|
+
JINJA_DEFAULT = 'jinja_default'
|
|
60
|
+
RESTRICTED = 'restricted'
|
|
61
|
+
|
|
47
62
|
class WebSearchKey(StrEnum):
|
|
48
63
|
"""Defines valid web search keys."""
|
|
49
64
|
PATTERN = 'pattern'
|
gllm_inference/schema/events.pyi
CHANGED
|
@@ -1,108 +1,123 @@
|
|
|
1
|
-
from
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
2
|
from gllm_core.schema import Event
|
|
3
3
|
from gllm_inference.schema.activity import Activity as Activity
|
|
4
|
-
from gllm_inference.schema.enums import
|
|
5
|
-
from typing import Literal
|
|
4
|
+
from gllm_inference.schema.enums import LMEventType as LMEventType
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
CodeEventType: Incomplete
|
|
8
|
+
ThinkingEventType: Incomplete
|
|
6
9
|
|
|
7
10
|
class ActivityEvent(Event):
|
|
8
|
-
"""Event schema for model-triggered activities (e.g. web search, MCP).
|
|
11
|
+
"""Event schema for model-triggered activities (e.g. web search, MCP call, etc.).
|
|
9
12
|
|
|
10
13
|
Attributes:
|
|
11
|
-
id (str): The
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
15
20
|
"""
|
|
16
|
-
|
|
17
|
-
type: Literal[
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
value: dict[str, Any]
|
|
22
|
+
type: Literal[LMEventType.ACTIVITY]
|
|
23
|
+
@classmethod
|
|
24
|
+
def from_activity(cls, id_: str | None = None, activity: Activity | None = None) -> ActivityEvent:
|
|
25
|
+
"""Create an activity event from an Activity object.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
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.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
ActivityEvent: The activity event.
|
|
34
|
+
"""
|
|
20
35
|
|
|
21
36
|
class CodeEvent(Event):
|
|
22
|
-
"""Event schema for model-
|
|
37
|
+
"""Event schema for model-generated code to be executed.
|
|
23
38
|
|
|
24
39
|
Attributes:
|
|
25
|
-
id (str): The
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
id (str): The ID of the code event. Defaults to None.
|
|
41
|
+
value (str): The value of the code event. Defaults to an empty string.
|
|
42
|
+
level (EventLevel): The severity level of the code event. Defaults to EventLevel.INFO.
|
|
43
|
+
type (CodeEventType): The type of the code event. Defaults to EventType.CODE.
|
|
44
|
+
timestamp (datetime): The timestamp of the code event. Defaults to the current timestamp.
|
|
45
|
+
metadata (dict[str, Any]): The metadata of the code event. Defaults to an empty dictionary.
|
|
29
46
|
"""
|
|
30
|
-
id: str
|
|
31
|
-
type: Literal[EmitDataType.CODE, EmitDataType.CODE_START, EmitDataType.CODE_END]
|
|
32
47
|
value: str
|
|
33
|
-
|
|
48
|
+
type: CodeEventType
|
|
34
49
|
@classmethod
|
|
35
|
-
def start(cls, id_: str | None =
|
|
50
|
+
def start(cls, id_: str | None = None) -> CodeEvent:
|
|
36
51
|
"""Create a code start event.
|
|
37
52
|
|
|
38
53
|
Args:
|
|
39
|
-
id_ (str | None): The
|
|
54
|
+
id_ (str | None, optional): The ID of the code event. Defaults to None.
|
|
40
55
|
|
|
41
56
|
Returns:
|
|
42
57
|
CodeEvent: The code start event.
|
|
43
58
|
"""
|
|
44
59
|
@classmethod
|
|
45
|
-
def content(cls, id_: str | None =
|
|
60
|
+
def content(cls, id_: str | None = None, value: str = '') -> CodeEvent:
|
|
46
61
|
"""Create a code content event.
|
|
47
62
|
|
|
48
63
|
Args:
|
|
49
|
-
id_ (str | None): The
|
|
50
|
-
value (str): The code content.
|
|
64
|
+
id_ (str | None, optional): The ID of the code event. Defaults to None.
|
|
65
|
+
value (str, optional): The code content. Defaults to an empty string.
|
|
51
66
|
|
|
52
67
|
Returns:
|
|
53
68
|
CodeEvent: The code value event.
|
|
54
69
|
"""
|
|
55
70
|
@classmethod
|
|
56
|
-
def end(cls, id_: str | None =
|
|
71
|
+
def end(cls, id_: str | None = None) -> CodeEvent:
|
|
57
72
|
"""Create a code end event.
|
|
58
73
|
|
|
59
74
|
Args:
|
|
60
|
-
id_ (str | None): The
|
|
75
|
+
id_ (str | None, optional): The ID of the code event. Defaults to None.
|
|
61
76
|
|
|
62
77
|
Returns:
|
|
63
78
|
CodeEvent: The code end event.
|
|
64
79
|
"""
|
|
65
80
|
|
|
66
81
|
class ThinkingEvent(Event):
|
|
67
|
-
"""Event schema for model thinking.
|
|
82
|
+
"""Event schema for model-generated thinking.
|
|
68
83
|
|
|
69
84
|
Attributes:
|
|
70
|
-
id (str): The
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
id (str): The ID of the thinking event. Defaults to None.
|
|
86
|
+
value (str): The value of the thinking event. Defaults to an empty string.
|
|
87
|
+
level (EventLevel): The severity level of the thinking event. Defaults to EventLevel.INFO.
|
|
88
|
+
type (ThinkingEventType): The type of the thinking event. Defaults to EventType.THINKING.
|
|
89
|
+
timestamp (datetime): The timestamp of the thinking event. Defaults to the current timestamp.
|
|
90
|
+
metadata (dict[str, Any]): The metadata of the thinking event. Defaults to an empty dictionary.
|
|
74
91
|
"""
|
|
75
|
-
id: str
|
|
76
|
-
type: Literal[EmitDataType.THINKING, EmitDataType.THINKING_START, EmitDataType.THINKING_END]
|
|
77
92
|
value: str
|
|
78
|
-
|
|
93
|
+
type: ThinkingEventType
|
|
79
94
|
@classmethod
|
|
80
|
-
def start(cls, id_: str | None =
|
|
95
|
+
def start(cls, id_: str | None = None) -> ThinkingEvent:
|
|
81
96
|
"""Create a thinking start event.
|
|
82
97
|
|
|
83
98
|
Args:
|
|
84
|
-
id_ (str | None): The
|
|
99
|
+
id_ (str | None, optional): The ID of the thinking event. Defaults to None.
|
|
85
100
|
|
|
86
101
|
Returns:
|
|
87
102
|
ThinkingEvent: The thinking start event.
|
|
88
103
|
"""
|
|
89
104
|
@classmethod
|
|
90
|
-
def content(cls, id_: str | None =
|
|
105
|
+
def content(cls, id_: str | None = None, value: str = '') -> ThinkingEvent:
|
|
91
106
|
"""Create a thinking value event.
|
|
92
107
|
|
|
93
108
|
Args:
|
|
94
|
-
id_ (str | None): The
|
|
95
|
-
value (str): The thinking content or message.
|
|
109
|
+
id_ (str | None, optional): The ID of the thinking event. Defaults to None.
|
|
110
|
+
value (str, optional): The thinking content or message. Defaults to an empty string.
|
|
96
111
|
|
|
97
112
|
Returns:
|
|
98
113
|
ThinkingEvent: The thinking value event.
|
|
99
114
|
"""
|
|
100
115
|
@classmethod
|
|
101
|
-
def end(cls, id_: str | None =
|
|
116
|
+
def end(cls, id_: str | None = None) -> ThinkingEvent:
|
|
102
117
|
"""Create a thinking end event.
|
|
103
118
|
|
|
104
119
|
Args:
|
|
105
|
-
id_ (str | None): The
|
|
120
|
+
id_ (str | None, optional): The ID of the thinking event. Defaults to None.
|
|
106
121
|
|
|
107
122
|
Returns:
|
|
108
123
|
ThinkingEvent: The thinking end event.
|
|
Binary file
|
gllm_inference.pyi
CHANGED
|
@@ -114,7 +114,7 @@ import inspect
|
|
|
114
114
|
import time
|
|
115
115
|
import jsonschema
|
|
116
116
|
import gllm_inference.lm_invoker.batch.BatchOperations
|
|
117
|
-
import gllm_inference.schema.
|
|
117
|
+
import gllm_inference.schema.LMEventType
|
|
118
118
|
import gllm_inference.schema.MessageContent
|
|
119
119
|
import __future__
|
|
120
120
|
import gllm_inference.schema.ActivityEvent
|
|
@@ -131,6 +131,11 @@ import xai_sdk.search
|
|
|
131
131
|
import xai_sdk.proto
|
|
132
132
|
import xai_sdk.proto.v5
|
|
133
133
|
import xai_sdk.proto.v5.chat_pb2
|
|
134
|
+
import jinja2
|
|
135
|
+
import jinja2.sandbox
|
|
136
|
+
import gllm_inference.schema.JinjaEnvType
|
|
137
|
+
import gllm_inference.prompt_builder.format_strategy.JinjaFormatStrategy
|
|
138
|
+
import gllm_inference.prompt_builder.format_strategy.StringFormatStrategy
|
|
134
139
|
import transformers
|
|
135
140
|
import gllm_inference.prompt_formatter.HuggingFacePromptFormatter
|
|
136
141
|
import logging
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gllm-inference-binary
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.45
|
|
4
4
|
Summary: A library containing components related to model inferences in Gen AI applications.
|
|
5
5
|
Author-email: Henry Wicaksono <henry.wicaksono@gdplabs.id>, Resti Febrina <resti.febrina@gdplabs.id>
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: poetry<3.0.0,>=2.1.3
|
|
9
|
-
Requires-Dist: gllm-core-binary<0.4.0,>=0.3.
|
|
9
|
+
Requires-Dist: gllm-core-binary<0.4.0,>=0.3.21
|
|
10
10
|
Requires-Dist: aiohttp<4.0.0,>=3.12.14
|
|
11
11
|
Requires-Dist: filetype<2.0.0,>=1.2.0
|
|
12
12
|
Requires-Dist: httpx<0.29.0,>=0.28.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
gllm_inference.cp313-win_amd64.pyd,sha256=
|
|
2
|
-
gllm_inference.pyi,sha256=
|
|
1
|
+
gllm_inference.cp313-win_amd64.pyd,sha256=tAwGqwenK1geHt_I26Ee6y1xY14Ta__bFkQhIiWiIeo,3739648
|
|
2
|
+
gllm_inference.pyi,sha256=d_2YUYVy-BJvaYSyEgXSn5QBfMPFlDbdo3TmDKkRodI,5143
|
|
3
3
|
gllm_inference/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
gllm_inference/constants.pyi,sha256=PncjVw-mkzcJ3ln1ohvVZGdJ-TD-VZy1Ygn4Va8Z7i0,350
|
|
5
5
|
gllm_inference/builder/__init__.pyi,sha256=-bw1uDx7CAM7pkvjvb1ZXku9zXlQ7aEAyC83KIn3bz8,506
|
|
@@ -47,7 +47,7 @@ gllm_inference/lm_invoker/datasaur_lm_invoker.pyi,sha256=LR0EM4vTfufq9OWk8JVIwLy
|
|
|
47
47
|
gllm_inference/lm_invoker/google_lm_invoker.pyi,sha256=aSmEgoYj_V72Nb6erDResphw9RaHfbE5C6PhqpMfEeQ,17674
|
|
48
48
|
gllm_inference/lm_invoker/langchain_lm_invoker.pyi,sha256=tJIxkFUKjLF-yz0niaDjN3L0QNCbn4sT8hmPKtERpog,12742
|
|
49
49
|
gllm_inference/lm_invoker/litellm_lm_invoker.pyi,sha256=IJxRUkmgXY8oQwS7tJoskO8fiESB7M4pyvpE64pyXDo,12648
|
|
50
|
-
gllm_inference/lm_invoker/lm_invoker.pyi,sha256=
|
|
50
|
+
gllm_inference/lm_invoker/lm_invoker.pyi,sha256=PS4cJ5VLNfHqeTgCerY-c1Xaa7ktdWAiT-f3Lnc0wvE,8665
|
|
51
51
|
gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi,sha256=uYJFgi4tJGab77232IC1gdoU9h9AqoClIUj6tM6O47s,15177
|
|
52
52
|
gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi,sha256=T9sShA_9fgEuaaAuT2gJZq_EYNbEhf3IkWwMCwfszY8,4244
|
|
53
53
|
gllm_inference/lm_invoker/openai_lm_invoker.pyi,sha256=10iKCyleqHNbJc8M1rj3ogRcNlNxcVgyk0v6TcS6gf4,23452
|
|
@@ -77,7 +77,11 @@ gllm_inference/output_parser/__init__.pyi,sha256=dhAeRTBxc6CfS8bhnHjbtrnyqJ1iyff
|
|
|
77
77
|
gllm_inference/output_parser/json_output_parser.pyi,sha256=YtgQh8Uzy8W_Tgh8DfuR7VFFS7qvLEasiTwRfaGZZEU,2993
|
|
78
78
|
gllm_inference/output_parser/output_parser.pyi,sha256=-Xu5onKCBDqShcO-VrQh5icqAmXdihGc3rkZxL93swg,975
|
|
79
79
|
gllm_inference/prompt_builder/__init__.pyi,sha256=mPsbiafzSNHsgN-CuzjhgZpfXfi1pPC3_gdsq2p0EM4,120
|
|
80
|
-
gllm_inference/prompt_builder/prompt_builder.pyi,sha256=
|
|
80
|
+
gllm_inference/prompt_builder/prompt_builder.pyi,sha256=67X0MXPRGb_Azifk5fM9lAsQX48rASsQk2gCPikqU5k,4626
|
|
81
|
+
gllm_inference/prompt_builder/format_strategy/__init__.pyi,sha256=BliNAdrN2yNoQt8muLe1IknuE78UDQys_3L_8_2Tn9E,312
|
|
82
|
+
gllm_inference/prompt_builder/format_strategy/format_strategy.pyi,sha256=Uay07qR0nMGbrOZ2twEyrIWYRKevBQL9ju_4fVfByyQ,2328
|
|
83
|
+
gllm_inference/prompt_builder/format_strategy/jinja_format_strategy.pyi,sha256=W8SdOPWPz_U355G8rQwiIQ0Ys78vomUBFEEZiz3AS5k,2270
|
|
84
|
+
gllm_inference/prompt_builder/format_strategy/string_format_strategy.pyi,sha256=Xbx8xAtj3AbgFuPY8A3OuC6MlwenjYm6OXnQwxAP45k,713
|
|
81
85
|
gllm_inference/prompt_formatter/__init__.pyi,sha256=q5sPPrnoCf-4tMGowh7hXxs63uyWfaZyEI-wjLBTGsA,747
|
|
82
86
|
gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi,sha256=qp4L3x7XK7oZaSYP8B4idewKpPioB4XELeKVV-dNi-Q,2067
|
|
83
87
|
gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi,sha256=kH60A_3DnHd3BrqbgS_FqQTCTHIjC9BTsk6_FNgcZw8,2784
|
|
@@ -99,13 +103,13 @@ gllm_inference/realtime_chat/output_streamer/output_streamer.pyi,sha256=5P9NQ0aJ
|
|
|
99
103
|
gllm_inference/request_processor/__init__.pyi,sha256=giEme2WFQhgyKiBZHhSet0_nKSCHwGy-_2p6NRzg0Zc,231
|
|
100
104
|
gllm_inference/request_processor/lm_request_processor.pyi,sha256=0fy1HyILCVDw6y46E-7tLnQTRYx4ppeRMe0QP6t9Jyw,5990
|
|
101
105
|
gllm_inference/request_processor/uses_lm_mixin.pyi,sha256=LYHq-zLoXEMel1LfVdYv7W3BZ8WtBLo_WWFjRf10Yto,6512
|
|
102
|
-
gllm_inference/schema/__init__.pyi,sha256=
|
|
103
|
-
gllm_inference/schema/activity.pyi,sha256=
|
|
106
|
+
gllm_inference/schema/__init__.pyi,sha256=Rv821pgyUUbcVhnGJ0CnXVWJMi2pgaglv6Pq4RHK7yE,2223
|
|
107
|
+
gllm_inference/schema/activity.pyi,sha256=atrU4OwLesA9FEt1H7K3gsUWYNdOqpI5i2VdWkmo6cs,2367
|
|
104
108
|
gllm_inference/schema/attachment.pyi,sha256=9zgAjGXBjLfzPGaKi68FMW6b5mXdEA352nDe-ynOSvY,3385
|
|
105
109
|
gllm_inference/schema/code_exec_result.pyi,sha256=WQ-ARoGM9r6nyRX-A0Ro1XKiqrc9R3jRYXZpu_xo5S4,573
|
|
106
110
|
gllm_inference/schema/config.pyi,sha256=NVmjQK6HipIE0dKSfx12hgIC0O-S1HEcAc-TWlXAF5A,689
|
|
107
|
-
gllm_inference/schema/enums.pyi,sha256=
|
|
108
|
-
gllm_inference/schema/events.pyi,sha256=
|
|
111
|
+
gllm_inference/schema/enums.pyi,sha256=dN6FzT4zNbSfqVxmrl3hO7IIiP-Qy4lAP_tf4tp8dNI,1827
|
|
112
|
+
gllm_inference/schema/events.pyi,sha256=iG3sFAhvek-fSJgmUE6nJ5M0XzSpRKKpJJiXyuB4Wq0,5058
|
|
109
113
|
gllm_inference/schema/lm_input.pyi,sha256=HxQiZgY7zcXh_Dw8nK8LSeBTZEHMPZVwmPmnfgSsAbs,197
|
|
110
114
|
gllm_inference/schema/lm_output.pyi,sha256=DIV8BiIOPaSnMKxzKzH_Mp7j7-MScWCvmllegJDLqFg,2479
|
|
111
115
|
gllm_inference/schema/mcp.pyi,sha256=4SgQ83pEowfWm2p-w9lupV4NayqqVBOy7SuYxIFeWRs,1045
|
|
@@ -121,7 +125,7 @@ gllm_inference/utils/io_utils.pyi,sha256=Eg7dvHWdXslTKdjh1j3dG50i7r35XG2zTmJ9XXv
|
|
|
121
125
|
gllm_inference/utils/langchain.pyi,sha256=4AwFiVAO0ZpdgmqeC4Pb5NJwBt8vVr0MSUqLeCdTscc,1194
|
|
122
126
|
gllm_inference/utils/validation.pyi,sha256=-RdMmb8afH7F7q4Ao7x6FbwaDfxUHn3hA3WiOgzB-3s,397
|
|
123
127
|
gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
124
|
-
gllm_inference_binary-0.5.
|
|
125
|
-
gllm_inference_binary-0.5.
|
|
126
|
-
gllm_inference_binary-0.5.
|
|
127
|
-
gllm_inference_binary-0.5.
|
|
128
|
+
gllm_inference_binary-0.5.45.dist-info/METADATA,sha256=RLBqUxp1nnQSWcpsyb5R3g0PWAmQ3Q5k4fQl8jLjJIs,5852
|
|
129
|
+
gllm_inference_binary-0.5.45.dist-info/WHEEL,sha256=O_u6PJIQ2pIcyIInxVQ9r-yArMuUZbBIaF1kpYVkYxA,96
|
|
130
|
+
gllm_inference_binary-0.5.45.dist-info/top_level.txt,sha256=FpOjtN80F-qVNgbScXSEyqa0w09FYn6301iq6qt69IQ,15
|
|
131
|
+
gllm_inference_binary-0.5.45.dist-info/RECORD,,
|
|
File without changes
|
{gllm_inference_binary-0.5.43.dist-info → gllm_inference_binary-0.5.45.dist-info}/top_level.txt
RENAMED
|
File without changes
|