gllm-core-binary 0.3.26__cp311-cp311-win_amd64.whl → 0.4.4b3__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.
@@ -0,0 +1,3 @@
1
+ from gllm_core.adapters.tool import from_google_function as from_google_function, from_langchain_tool as from_langchain_tool
2
+
3
+ __all__ = ['from_google_function', 'from_langchain_tool']
@@ -0,0 +1,4 @@
1
+ from gllm_core.adapters.tool.google_adk import from_google_function as from_google_function
2
+ from gllm_core.adapters.tool.langchain import from_langchain_tool as from_langchain_tool
3
+
4
+ __all__ = ['from_langchain_tool', 'from_google_function']
@@ -0,0 +1,23 @@
1
+ from gllm_core.schema.tool import Tool as Tool
2
+ from typing import Any, Callable
3
+
4
+ def from_google_function(function_declaration: Any, func: Callable | None = None) -> Tool:
5
+ """Convert a Google ADK function declaration into the SDK Tool representation.
6
+
7
+ The Google ADK `FunctionDeclaration` provides access to:
8
+ 1. `name`: The function name
9
+ 2. `description`: The function description
10
+ 3. `parameters`: A dict in JSON Schema format (OpenAPI 3.0 compatible)
11
+
12
+ Args:
13
+ function_declaration (Any): The Google ADK function declaration to convert.
14
+ func (Callable | None, optional): The implementation function for the tool. Defaults to None.
15
+
16
+ Returns:
17
+ Tool: The converted SDK tool.
18
+
19
+ Raises:
20
+ ValueError: If the function declaration is None or has invalid fields.
21
+ AttributeError: If required attributes are missing.
22
+ TypeError: If field types are incorrect.
23
+ """
@@ -0,0 +1,31 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.schema.tool import Tool as Tool
3
+ from typing import Any
4
+
5
+ class LangChainToolKeys:
6
+ """Constants for LangChain tool attribute keys."""
7
+ FUNC: str
8
+ COROUTINE: str
9
+ RUN: str
10
+ ARUN: str
11
+ NAME: str
12
+ DESCRIPTION: str
13
+ ARGS_SCHEMA: str
14
+
15
+ LANGCHAIN_FUNCTION_ATTRS: Incomplete
16
+
17
+ def from_langchain_tool(langchain_tool: Any) -> Tool:
18
+ """Convert a LangChain tool into the SDK Tool representation.
19
+
20
+ This function handles both traditional LangChain tools created with the @tool decorator
21
+ and tools created by subclassing the LangChain Tool class.
22
+
23
+ Args:
24
+ langchain_tool (Any): The LangChain tool to convert.
25
+
26
+ Returns:
27
+ Tool: The converted SDK tool.
28
+
29
+ Raises:
30
+ ValueError: If the input is not a valid LangChain tool.
31
+ """
gllm_core/constants.pyi CHANGED
@@ -13,7 +13,6 @@ class EventType(StrEnum):
13
13
  """Defines event types for the event emitter module."""
14
14
  ACTIVITY = 'activity'
15
15
  CODE = 'code'
16
- DATA = 'data'
17
16
  REFERENCE = 'reference'
18
17
  RESPONSE = 'response'
19
18
  STATUS = 'status'
@@ -1,11 +1,11 @@
1
1
  from _typeshed import Incomplete
2
- from gllm_core.constants import EventLevel as EventLevel, EventType as EventType
2
+ from gllm_core.constants import EventLevel as EventLevel
3
3
  from gllm_core.event.handler import ConsoleEventHandler as ConsoleEventHandler, PrintEventHandler as PrintEventHandler, StreamEventHandler as StreamEventHandler
4
4
  from gllm_core.event.handler.event_handler import BaseEventHandler as BaseEventHandler
5
5
  from gllm_core.event.hook.event_hook import BaseEventHook as BaseEventHook
6
6
  from gllm_core.schema import Event as Event
7
7
  from gllm_core.utils import validate_string_enum as validate_string_enum
8
- from typing import Any, AsyncGenerator
8
+ from typing import AsyncGenerator
9
9
 
10
10
  class EventEmitter:
11
11
  '''Handles events emitting using event handlers with various levels and types.
@@ -123,31 +123,19 @@ class EventEmitter:
123
123
  Returns:
124
124
  EventEmitter: A new instance of the EventEmitter class with a single StreamEventHandler.
125
125
  """
126
- async def emit(self, value: str | dict[str, Any] | Event, event_level: EventLevel = ..., event_type: str = ..., metadata: dict[str, Any] | None = None, event_id: str | None = None, disabled_handlers: list[str] | None = None) -> None:
127
- '''Emits an event using the configured event handlers.
126
+ async def emit(self, event: Event, disabled_handlers: list[str] | None = None) -> None:
127
+ """Emits an event using the configured event handlers.
128
128
 
129
- If the value is an Event object, it is used directly and other parameters are ignored.
130
- Otherwise, a new Event object is created with the provided parameters. The event is
131
- then passed to all handlers except those listed in disabled_handlers. Events are only
132
- processed if their severity level meets or exceeds the EventEmitter\'s configured level.
129
+ Events are emitted by passing them to all handlers except those listed in disabled_handlers.
130
+ Events are only processed if their severity level meets or exceeds the EventEmitter's configured level.
133
131
 
134
132
  Args:
135
- value (str | dict[str, Any] | Event): The event value or Event object to emit. If an Event object
136
- is provided, other parameters are ignored and the Event is used as-is.
137
- event_level (EventLevel, optional): The severity level of the event.
138
- Defaults to EventLevel.DEBUG.
139
- event_type (str, optional): The type of event (e.g., "status", "response").
140
- Defaults to EventType.STATUS.value.
141
- metadata (dict[str, Any] | None, optional): Additional metadata for the event.
142
- Defaults to None, which creates an empty dictionary.
143
- event_id (str | None, optional): Unique identifier for the event.
144
- Defaults to None, which creates an empty string.
145
- disabled_handlers (list[str] | None, optional): Names of handlers to skip for
146
- this event. Defaults to None.
133
+ event (Event): The event to emit.
134
+ disabled_handlers (list[str] | None, optional): Names of handlers to skip for this event. Defaults to None.
147
135
 
148
136
  Raises:
149
137
  ValueError: If the provided event_level is not a valid EventLevel.
150
- '''
138
+ """
151
139
  async def close(self) -> None:
152
140
  """Closes all handlers in the handler list.
153
141
 
@@ -1,5 +1,4 @@
1
1
  from _typeshed import Incomplete
2
- from gllm_core.constants import EventType as EventType
3
2
  from gllm_core.event.handler.event_handler import BaseEventHandler as BaseEventHandler
4
3
  from gllm_core.schema import Event as Event
5
4
 
@@ -15,7 +15,7 @@ class PrintEventHandler(BaseEventHandler):
15
15
  """
16
16
  padding_char: Incomplete
17
17
  console: Incomplete
18
- def __init__(self, name: str | None = None, color_map: dict[str, str] | None = None, padding_char: str = '=', separator_length: int | None = None) -> None:
18
+ def __init__(self, name: str | None = None, color_map: dict[str, str] | None = None, padding_char: str = '=') -> None:
19
19
  '''Initializes a new instance of the PrintEventHandler class.
20
20
 
21
21
  Args:
@@ -24,7 +24,6 @@ class PrintEventHandler(BaseEventHandler):
24
24
  color_map (dict[str, str], optional): The dictionary that maps certain event types to their corresponding
25
25
  colors in Rich format. Defaults to None, in which case the default color map will be used.
26
26
  padding_char (str, optional): The character to use for padding. Defaults to "=".
27
- separator_length (int | None, optional): Deprecated parameter. Defaults to None.
28
27
  '''
29
28
  async def emit(self, event: Event) -> None:
30
29
  """Emits the given event.
@@ -1,6 +1,6 @@
1
1
  from gllm_core.schema.chunk import Chunk as Chunk
2
- from gllm_core.schema.component import Component as Component
2
+ from gllm_core.schema.component import Component as Component, main as main
3
3
  from gllm_core.schema.event import Event as Event
4
4
  from gllm_core.schema.tool import Tool as Tool, tool as tool
5
5
 
6
- __all__ = ['Chunk', 'Component', 'Event', 'Tool', 'tool']
6
+ __all__ = ['Chunk', 'Component', 'Event', 'Tool', 'main', 'tool']
@@ -1,26 +1,71 @@
1
- import abc
2
- from abc import ABC
3
1
  from gllm_core.event.event_emitter import EventEmitter as EventEmitter
2
+ from gllm_core.schema.schema_generator import generate_params_model as generate_params_model
3
+ from gllm_core.schema.tool import Tool as Tool, tool as tool
4
4
  from gllm_core.utils import BinaryHandlingStrategy as BinaryHandlingStrategy, binary_handler_factory as binary_handler_factory
5
- from gllm_core.utils.analyzer import MethodSignature as MethodSignature, ParameterInfo as ParameterInfo, ParameterKind as ParameterKind, RunAnalyzer as RunAnalyzer, RunProfile as RunProfile
5
+ from gllm_core.utils.analyzer import MethodSignature as MethodSignature, ParameterInfo as ParameterInfo, ParameterKind as ParameterKind, RunProfile as RunProfile, analyze_method as analyze_method
6
6
  from gllm_core.utils.logger_manager import LoggerManager as LoggerManager
7
- from typing import Any
7
+ from gllm_core.utils.main_method_resolver import MainMethodResolver as MainMethodResolver
8
+ from pydantic import BaseModel as BaseModel
9
+ from typing import Any, Callable
8
10
 
9
- class Component(ABC, metaclass=abc.ABCMeta):
11
+ def main(method: Callable) -> Callable:
12
+ """Decorate a Component method as the async main entrypoint.
13
+
14
+ Usage:
15
+ Declare the coroutine that should act as the primary execution path
16
+ for a `Component` subclass. The decorated coroutine will be resolved by
17
+ `Component.run()` unless another subclass overrides the decoration.
18
+
19
+ Args:
20
+ method (Callable): Coroutine to mark as the main entrypoint.
21
+
22
+ Returns:
23
+ Callable: The same coroutine that is passed to the decorator. The decorator only marks the method as the main
24
+ entrypoint. It does not wrap or change its behavior or signature.
25
+
26
+ Raises:
27
+ TypeError: If the decorated callable is not asynchronous.
28
+ """
29
+
30
+ class Component:
10
31
  '''An abstract base class for all components used throughout the Gen AI applications.
11
32
 
12
33
  Every instance of Component has access to class-level `_default_log_level` and `_logger`, as detailed below.
13
34
  For components that require high observability, it is recommended to set `_default_log_level` to `logging.INFO`
14
35
  or higher.
15
36
 
16
- Example:
17
- ```python
18
- class MyComponent(Component):
19
- _default_log_level = logging.INFO
37
+ Defining Custom Components:
38
+ There are two ways to define the main execution logic for a component:
39
+
40
+ 1. **Using the @main decorator (Recommended)**:
41
+ Decorate an async method with `@main` to mark it as the primary entrypoint.
42
+ This is the preferred approach as it provides explicit control over the main method.
43
+
44
+ ```python
45
+ class MyComponent(Component):
46
+ _default_log_level = logging.INFO
47
+
48
+ @main
49
+ async def execute(self, **kwargs: Any) -> Any:
50
+ return "Hello from @main!"
51
+ ```
52
+
53
+ 2. **Implementing _run method (Deprecated)**:
54
+ Override the abstract `_run` method. This is the traditional approach and still supported.
55
+
56
+ ```python
57
+ class MyComponent(Component):
58
+ _default_log_level = logging.INFO
20
59
 
21
- def _run(self, **kwargs: Any) -> Any:
22
- return "Hello, World!"
23
- ```
60
+ async def _run(self, **kwargs: Any) -> Any:
61
+ return "Hello, World!"
62
+ ```
63
+
64
+ The `run()` method resolves the main entrypoint using the following precedence:
65
+ 1. Method decorated with @main in the current class.
66
+ 2. Method decorated with @main in the nearest ancestor class.
67
+ 3. Method named in __main_method__ property.
68
+ 4. The _run method (with deprecation warning).
24
69
 
25
70
  Attributes:
26
71
  run_profile (RunProfile): The profile of the `_run` method.
@@ -31,21 +76,122 @@ class Component(ABC, metaclass=abc.ABCMeta):
31
76
  **Do not override this property in your subclass.**
32
77
 
33
78
  You also do not need to write this attribute in your component\'s docstring.
34
- _default_log_level (int): The default log level for the component. Defaults to DEBUG.
35
- _logger (logging.Logger): The logger instance for the component.
36
79
  '''
80
+ def __init_subclass__(cls, **kwargs) -> None:
81
+ """Hook called when a subclass is created.
82
+
83
+ This validates the __main_method__ property and checks for multiple @main decorators
84
+ within the current class definition. Uses MainMethodResolver for consistent validation logic.
85
+
86
+ Note: Multiple inheritance conflicts are intentionally deferred to runtime (get_main())
87
+ to allow class definition to succeed.
88
+
89
+ Raises:
90
+ AttributeError: If __main_method__ refers to a non-existent method.
91
+ TypeError: If multiple methods are decorated with @main in the same class.
92
+ """
93
+ @classmethod
94
+ def get_main(cls) -> Callable | None:
95
+ """Return the resolved main coroutine for this Component class.
96
+
97
+ This method resolves the main method for the Component class following
98
+ the precedence rules:
99
+ 1. Most derived coroutine decorated with `@main`.
100
+ 2. Method named by `__main_method__`.
101
+ 3. `_run` coroutine as a deprecated fallback.
102
+
103
+ Results are cached for performance.
104
+
105
+ Returns:
106
+ Callable | None: The coroutine that will be executed by `run()` or
107
+ `None` when no entrypoint can be determined.
108
+
109
+ Raises:
110
+ TypeError: If conflicting main methods are inherited from multiple ancestors.
111
+ """
112
+ @property
113
+ def input_params(self) -> type[BaseModel] | None:
114
+ '''Return the Pydantic model describing this component\'s main method input parameters.
115
+
116
+ Returns:
117
+ type[BaseModel] | None: The cached model that mirrors the signature of
118
+ the resolved main method, or `None` if no main method can be
119
+ determined.
120
+
121
+ Examples:
122
+ ```python
123
+ from pydantic import ValidationError
124
+
125
+ component = SomeComponent()
126
+ ParamsModel = component.input_params
127
+ assert ParamsModel.__name__ == "SomeComponentParams"
128
+ fields = list(ParamsModel.model_fields)
129
+
130
+ # Validation with valid params
131
+ params = ParamsModel(text="hello")
132
+
133
+ # Validation catches missing required fields
134
+ try:
135
+ invalid_params = ParamsModel() # Missing required \'text\' field
136
+ except ValidationError as e:
137
+ print(f"Validation failed: {e.error_count()} errors")
138
+
139
+ # Argument construction
140
+ payload = params.model_dump()
141
+ result = await component.run(**payload)
142
+ ```
143
+ '''
37
144
  async def run(self, **kwargs: Any) -> Any:
38
145
  """Runs the operations defined for the component.
39
146
 
40
- This method emits the provided input arguments using an EventEmitter instance if available, executes a process
41
- defined in the `_run` method, and emits the resulting output if the EventEmitter is provided.
147
+ This method emits the provided input arguments using an EventEmitter instance if available, executes the
148
+ resolved main method, and emits the resulting output if the EventEmitter is provided.
149
+
150
+ The main method is resolved using the following precedence:
151
+ 1. Method decorated with @main in the current class.
152
+ 2. Method decorated with @main in the nearest ancestor class.
153
+ 3. Method named in __main_method__ property.
154
+ 4. The _run method (with deprecation warning).
42
155
 
43
156
  Args:
44
157
  **kwargs (Any): A dictionary of arguments to be processed. May include an `event_emitter`
45
158
  key with an EventEmitter instance.
46
159
 
47
160
  Returns:
48
- Any: The result of the `_run` method.
161
+ Any: The result of the resolved main method.
162
+
163
+ Raises:
164
+ TypeError: If conflicting main methods are inherited from multiple ancestors.
165
+ AttributeError: If __main_method__ refers to a non-existent method.
166
+ """
167
+ def as_tool(self, name: str | None = None, description: str | None = None, title: str | None = None) -> Tool:
168
+ """Convert the component's main method into a `Tool` instance.
169
+
170
+ Example:
171
+ ```python
172
+ from gllm_core.schema import Component, main
173
+
174
+ class MyComponent(Component):
175
+ @main
176
+ async def my_method(self, param: str) -> str:
177
+ return param
178
+
179
+ component = MyComponent()
180
+ tool = component.as_tool()
181
+ ```
182
+
183
+ Args:
184
+ name (str | None, optional): Identifier for the resulting tool. Defaults to the component class name.
185
+ description (str | None, optional): Summary of the tool's behavior. Defaults to None, in which case the
186
+ main method's docstring is used.
187
+ title (str | None, optional): Optional display title for the tool. Defaults to None, in which case the
188
+ component's class name is used.
189
+
190
+ Returns:
191
+ Tool: The tool wrapping the component's main method.
192
+
193
+ Raises:
194
+ RuntimeError: If the component does not declare a main method using @main or __main_method__.
49
195
  """
50
196
  @property
51
197
  def run_profile(self) -> RunProfile:
@@ -0,0 +1,35 @@
1
+ from gllm_core.utils.analyzer import analyze_method as analyze_method
2
+ from pydantic import BaseModel as BaseModel
3
+ from typing import Callable
4
+
5
+ def generate_params_model(method: Callable, class_name: str) -> type[BaseModel]:
6
+ '''Generate a Pydantic model representing a component method signature.
7
+
8
+ The generated class is named `{class_name}Params` and contains one field for
9
+ every parameter in `method`. The first `self` parameter is ignored, `*args` are
10
+ skipped entirely, and `**kwargs` trigger `extra="allow"` to permit arbitrary
11
+ keyword arguments at runtime.
12
+
13
+ For legacy `_run` methods with only `**kwargs`, this function will use
14
+ RunAnalyzer to infer parameters from the method body usage patterns.
15
+
16
+ Args:
17
+ method (Callable): Method whose signature should be represented.
18
+ class_name (str): Component class name used to derive the generated model name.
19
+
20
+ Returns:
21
+ type[BaseModel]: A Pydantic `BaseModel` subclass describing the method\'s
22
+ parameters.
23
+
24
+ Example:
25
+ ```python
26
+ class_name = "TextProcessor"
27
+
28
+ def process(self, text: str, count: int = 5) -> str:
29
+ return text * count
30
+
31
+ Model = generate_params_model(process, class_name)
32
+ assert Model.__name__ == "TextProcessorParams"
33
+ assert Model(text="hello", count=2).model_dump() == {"text": "hello", "count": 2}
34
+ ```
35
+ '''
gllm_core/schema/tool.pyi CHANGED
@@ -110,6 +110,27 @@ class Tool(BaseModel):
110
110
  is_async: bool
111
111
  model_config: Incomplete
112
112
  @classmethod
113
+ def from_langchain(cls, langchain_tool: Any) -> Tool:
114
+ """Create a Tool from a LangChain tool instance.
115
+
116
+ Args:
117
+ langchain_tool (Any): LangChain tool implementation to convert.
118
+
119
+ Returns:
120
+ Tool: Tool instance derived from the LangChain representation.
121
+ """
122
+ @classmethod
123
+ def from_google_adk(cls, function_declaration: Any, func: Callable | None = None) -> Tool:
124
+ """Create a Tool from a Google ADK function declaration.
125
+
126
+ Args:
127
+ function_declaration (Any): Google ADK function declaration to convert.
128
+ func (Callable | None): Optional implementation callable for the tool.
129
+
130
+ Returns:
131
+ Tool: Tool instance derived from the Google ADK definition.
132
+ """
133
+ @classmethod
113
134
  def validate_input_schema(cls, v: Any):
114
135
  """Validate and convert input_schema to JSON Schema dict if it's a Pydantic model.
115
136
 
@@ -5,8 +5,9 @@ from gllm_core.utils.concurrency import asyncify as asyncify, get_default_portal
5
5
  from gllm_core.utils.event_formatter import format_chunk_message as format_chunk_message, get_placeholder_keys as get_placeholder_keys
6
6
  from gllm_core.utils.google_sheets import load_gsheets as load_gsheets
7
7
  from gllm_core.utils.logger_manager import LoggerManager as LoggerManager
8
+ from gllm_core.utils.main_method_resolver import MainMethodResolver as MainMethodResolver
8
9
  from gllm_core.utils.merger_method import MergerMethod as MergerMethod
9
10
  from gllm_core.utils.retry import RetryConfig as RetryConfig, retry as retry
10
11
  from gllm_core.utils.validation import validate_string_enum as validate_string_enum
11
12
 
12
- __all__ = ['BinaryHandlingStrategy', 'ChunkMetadataMerger', 'LoggerManager', 'MergerMethod', 'RunAnalyzer', 'RetryConfig', 'asyncify', 'get_default_portal', 'binary_handler_factory', 'format_chunk_message', 'get_placeholder_keys', 'load_gsheets', 'syncify', 'retry', 'validate_string_enum']
13
+ __all__ = ['BinaryHandlingStrategy', 'ChunkMetadataMerger', 'LoggerManager', 'MainMethodResolver', 'MergerMethod', 'RunAnalyzer', 'RetryConfig', 'asyncify', 'get_default_portal', 'binary_handler_factory', 'format_chunk_message', 'get_placeholder_keys', 'load_gsheets', 'syncify', 'retry', 'validate_string_enum']
@@ -2,7 +2,7 @@ import ast
2
2
  from _typeshed import Incomplete
3
3
  from enum import StrEnum
4
4
  from pydantic import BaseModel
5
- from typing import Any
5
+ from typing import Any, Callable
6
6
 
7
7
  class ParameterKind(StrEnum):
8
8
  """Enum representing the different kinds of parameters a method can have."""
@@ -107,3 +107,17 @@ class RunAnalyzer(ast.NodeVisitor):
107
107
  Args:
108
108
  node (ast.Subscript): The Subscript node to visit.
109
109
  '''
110
+
111
+ def analyze_method(cls, method: Callable) -> RunProfile:
112
+ """Analyze a method using RunAnalyzer.
113
+
114
+ This function encapsulates the common analysis logic used by both
115
+ Component._analyze_run_method() and schema_generator._generate_from_analyzer().
116
+
117
+ Args:
118
+ cls (type): The class containing the method (for analyzer context).
119
+ method (Callable): The method to analyze.
120
+
121
+ Returns:
122
+ RunProfile: The analysis results.
123
+ """
@@ -9,6 +9,8 @@ DEFAULT_DATE_FORMAT: str
9
9
  TEXT_COLOR_MAP: Incomplete
10
10
  LOG_FORMAT_KEY: str
11
11
  RICH_CLOSE_TAG: str
12
+ JSON_LOG_FIELDS: Incomplete
13
+ JSON_ERROR_FIELDS_MAP: Incomplete
12
14
 
13
15
  class TextRichHandler(RichHandler):
14
16
  """Custom RichHandler that applies specific colors and log format."""
@@ -0,0 +1,54 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.utils.logger_manager import LoggerManager as LoggerManager
3
+ from typing import Callable
4
+
5
+ class MainMethodResolver:
6
+ """Resolves the main entrypoint method for Component classes.
7
+
8
+ This resolver implements the precedence rules for determining which method
9
+ should be used as the main entrypoint:
10
+ 1. Method decorated with @main in the most derived class.
11
+ 2. Method named by __main_method__ property.
12
+ 3. _run method (with deprecation warning).
13
+
14
+ Attributes:
15
+ cls (type): The Component class to resolve the main method for.
16
+ """
17
+ cls: Incomplete
18
+ def __init__(self, component_class: type) -> None:
19
+ """Initialize the resolver with a Component class.
20
+
21
+ Args:
22
+ component_class (type): The Component class to resolve the main method for.
23
+ """
24
+ @staticmethod
25
+ def validate_class(component_class: type) -> None:
26
+ """Validate main method configuration at class definition time.
27
+
28
+ This performs early validation that can be done when a Component subclass
29
+ is defined, before any instances are created or methods are called.
30
+
31
+ Validations performed:
32
+ 1. Check that __main_method__ property points to an existing method
33
+ 2. Check that only one @main decorator is used within the same class
34
+
35
+ Note: Multiple inheritance conflicts are intentionally NOT checked here,
36
+ as they are deferred to runtime (get_main()) to allow class definition
37
+ to succeed.
38
+
39
+ Args:
40
+ component_class (type): The Component class to validate.
41
+
42
+ Raises:
43
+ AttributeError: If __main_method__ refers to a non-existent method.
44
+ TypeError: If multiple methods are decorated with @main in the same class.
45
+ """
46
+ def resolve(self) -> Callable | None:
47
+ """Resolve the main method following precedence rules.
48
+
49
+ Returns:
50
+ Callable | None: The resolved main method, or None if not found.
51
+
52
+ Raises:
53
+ TypeError: If conflicting main methods are inherited from multiple ancestors.
54
+ """
gllm_core/utils/retry.pyi CHANGED
@@ -1,7 +1,8 @@
1
1
  from _typeshed import Incomplete
2
2
  from gllm_core.utils import LoggerManager as LoggerManager
3
+ from gllm_core.utils.concurrency import syncify as syncify
3
4
  from pydantic import BaseModel
4
- from typing import Any, Callable, TypeVar
5
+ from typing import Any, Callable, TypeVar, overload
5
6
 
6
7
  logger: Incomplete
7
8
  T = TypeVar('T')
@@ -14,7 +15,6 @@ class RetryConfig(BaseModel):
14
15
  max_retries (int): Maximum number of retry attempts.
15
16
  base_delay (float): Base delay in seconds between retries.
16
17
  max_delay (float): Maximum delay in seconds between retries.
17
- exponential_base (float): Base for exponential backoff. Deprecated and will be removed in v0.4.
18
18
  jitter (bool): Whether to add random jitter to delays.
19
19
  timeout (float | None): Overall timeout in seconds for the entire operation. If None, timeout is disabled.
20
20
  retry_on_exceptions (tuple[type[Exception], ...]): Tuple of exception types to retry on.
@@ -22,7 +22,6 @@ class RetryConfig(BaseModel):
22
22
  max_retries: int
23
23
  base_delay: float
24
24
  max_delay: float
25
- exponential_base: float
26
25
  jitter: bool
27
26
  timeout: float | None
28
27
  retry_on_exceptions: tuple[type[Exception], ...]
@@ -36,29 +35,7 @@ class RetryConfig(BaseModel):
36
35
  ValueError: If max_delay is less than base_delay.
37
36
  """
38
37
 
39
- async def retry(func: Callable[..., Any], *args: Any, retry_config: RetryConfig | None = None, **kwargs: Any) -> T:
40
- """Executes a function with retry logic and exponential backoff.
41
-
42
- This function executes the provided function with retry logic. It will first try to execute the function once.
43
- If the function raises an exception that matches the retry_on_exceptions, it will retry up to max_retries times
44
- with exponential backoff. Therefore, the max number of attempts is max_retries + 1. If provided, the timeout
45
- applies to the entire retry operation, including all attempts and delays.
46
-
47
- Example:
48
- If you set timeout=10.0 and max_retries=3, the entire retry operation (including all attempts
49
- and delays) will timeout after 10 seconds, not 10 seconds per attempt.
50
-
51
- Args:
52
- func (Callable[..., Any]): The function to execute.
53
- *args (Any): Positional arguments to pass to the function.
54
- retry_config (RetryConfig | None, optional): Retry configuration. If None, uses default config.
55
- Defaults to None.
56
- **kwargs (Any): Keyword arguments to pass to the function.
57
-
58
- Returns:
59
- T: The result of the function execution.
60
-
61
- Raises:
62
- Exception: The last exception raised by the function if all retries are exhausted.
63
- asyncio.TimeoutError: If the overall timeout is exceeded.
64
- """
38
+ @overload
39
+ async def retry(func: Callable[..., Any], *args: Any, retry_config: RetryConfig | None = None, **kwargs: Any) -> T: ...
40
+ @overload
41
+ def retry(config: RetryConfig | None = None) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
Binary file
gllm_core.pyi CHANGED
@@ -9,36 +9,38 @@ __name__ = ...
9
9
 
10
10
  # Modules used internally, to allow implicit dependencies to be seen:
11
11
  import os
12
- import enum
13
- import datetime
12
+ import gllm_core.adapters.tool.from_google_function
13
+ import gllm_core.adapters.tool.from_langchain_tool
14
+ import asyncio
14
15
  import typing
16
+ import enum
15
17
  import gllm_core.event.handler.ConsoleEventHandler
16
18
  import gllm_core.event.handler.PrintEventHandler
17
19
  import gllm_core.event.handler.StreamEventHandler
18
20
  import gllm_core.schema.Event
19
21
  import gllm_core.utils.validate_string_enum
20
- import json
21
22
  import rich
22
23
  import rich.console
23
24
  import abc
24
25
  import gllm_core.utils.LoggerManager
25
26
  import rich.panel
26
27
  import rich.style
27
- import asyncio
28
+ import json
28
29
  import gllm_core.event.EventEmitter
29
30
  import gllm_core.schema.Component
30
31
  import gllm_core.utils.get_placeholder_keys
31
32
  import uuid
32
33
  import pydantic
33
34
  import __future__
34
- import ast
35
35
  import inspect
36
36
  import logging
37
- import textwrap
38
37
  import warnings
39
38
  import functools
40
39
  import traceback
41
40
  import gllm_core.utils.BinaryHandlingStrategy
41
+ import datetime
42
+ import ast
43
+ import textwrap
42
44
  import base64
43
45
  import atexit
44
46
  import threading
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gllm-core-binary
3
- Version: 0.3.26
3
+ Version: 0.4.4b3
4
4
  Summary: A library containing core components for Gen AI applications.
5
5
  Author-email: Dimitrij Ray <dimitrij.ray@gdplabs.id>, Henry Wicaksono <henry.wicaksono@gdplabs.id>, Resti Febriana <resti.febriana@gdplabs.id>
6
6
  Requires-Python: <3.14,>=3.11
@@ -27,6 +27,11 @@ Requires-Dist: pytest<9.0.0,>=8.1.1; extra == "dev"
27
27
  Requires-Dist: pytest-asyncio<1.0.0,>=0.23.6; extra == "dev"
28
28
  Requires-Dist: pytest-cov<6.0.0,>=5.0.0; extra == "dev"
29
29
  Requires-Dist: ruff<1.0.0,>=0.6.7; extra == "dev"
30
+ Provides-Extra: langchain
31
+ Requires-Dist: langchain-core<1.0.0,>=0.3.0; extra == "langchain"
32
+ Provides-Extra: google-adk
33
+ Requires-Dist: google-adk<2.0.0,>=1.0.0; extra == "google-adk"
34
+ Requires-Dist: starlette<1.0.0,>=0.49.0; extra == "google-adk"
30
35
 
31
36
  # GLLM Core
32
37
 
@@ -0,0 +1,44 @@
1
+ gllm_core.cp311-win_amd64.pyd,sha256=4mjl0j8qNOrS45QQgXqBpIhQwiReUSdt4dKp3ujhBdQ,1234944
2
+ gllm_core.pyi,sha256=n1D4ZCjhQUKv7qxTYLWh-afK6ECPZCddwckzt6afO2w,1446
3
+ gllm_core/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ gllm_core/constants.pyi,sha256=9M5UxEkdttu4fSJTLxhjt7q1xTRYbjTFheM5EjQ5Bs4,904
5
+ gllm_core/adapters/__init__.pyi,sha256=N8JBGr2mPUMAGaMd__7XxGr2NAzfaFMuNH15QkSfbrA,187
6
+ gllm_core/adapters/tool/__init__.pyi,sha256=zRmMo1ilDaYF-cErfkQqy8zGnArHebdWmox-P34_7fI,244
7
+ gllm_core/adapters/tool/google_adk.pyi,sha256=0awaKRXmmK5NiAP9vNNYjMARDPWfWyQqy29k3WHoX2s,953
8
+ gllm_core/adapters/tool/langchain.pyi,sha256=LBqox8xFm6jSxPfBEftJr_zUmXwPk_qHNwU3bZaphhE,855
9
+ gllm_core/event/__init__.pyi,sha256=HVs5C80lFzVEH7mO8KJTUqEPi_7KyPvNeMLuoG-hDeE,177
10
+ gllm_core/event/event_emitter.pyi,sha256=dzhlOGnA2h5-OSRZHt-AJ-THul-rDUatfwr6dyYzYu8,7297
11
+ gllm_core/event/messenger.pyi,sha256=8Nvra-a7RqnfX0PAtm-Of5M8CvsYr0L_1k3HgdNCR5I,3190
12
+ gllm_core/event/handler/__init__.pyi,sha256=gZ21Fjjog3-e3-_Xv5sTpX9_Mx8X2LUzTrqp_tPisCg,377
13
+ gllm_core/event/handler/console_event_handler.pyi,sha256=eCv0SaZEpbu8W2jQPLnWwXNzhGOSM5KAtDVUYfvlvMs,1494
14
+ gllm_core/event/handler/event_handler.pyi,sha256=chEYnw3Rp9Lk3Cz4dSn6EVlzje4BG-SlM82J-4UE5Hw,2153
15
+ gllm_core/event/handler/print_event_handler.pyi,sha256=D_xNtpcBsGl7NVSCvFKEGvaUqfMTxPaQV8zXECwmZ2Q,1674
16
+ gllm_core/event/handler/stream_event_handler.pyi,sha256=5faGSFQLBN7XMqd4nIfGkdTBI_ALVaE-fmxVAjzca9w,2908
17
+ gllm_core/event/hook/__init__.pyi,sha256=gSDHYl0yi00zHHMRvU_Eg8qLqsGHESTvoNE3MXig-g0,149
18
+ gllm_core/event/hook/event_hook.pyi,sha256=rMatofdNAwHI65ya_7-q3NAfmTuKhc2WkXeiGPAvcKI,600
19
+ gllm_core/event/hook/json_stringify_event_hook.pyi,sha256=I-QxbaLc4rEyqhW_f4INN5UxBg_ZofHHN1HQKfPJ7rs,585
20
+ gllm_core/schema/__init__.pyi,sha256=X7Gv3xgtl4Ylzsg9iuGgjJPkQey7OdvvIC_X1e5_LAI,310
21
+ gllm_core/schema/chunk.pyi,sha256=ZVYQitMtvMStiFssnTCgtSIcj30VSsK2dKscSysl3R4,2378
22
+ gllm_core/schema/component.pyi,sha256=fghUD8QJRXjjUT2jn64dkM_KjMv6MV9OAQUXjc7xsD0,9164
23
+ gllm_core/schema/event.pyi,sha256=Yd74uSWhIO1lx0_p70rYt-LMz4FZHbbbqJP7xhVh_pY,1335
24
+ gllm_core/schema/schema_generator.pyi,sha256=ToadC6UKEq35k32wUK1VaMKiICRtENXUYdAQOMlTg3U,1445
25
+ gllm_core/schema/tool.pyi,sha256=T5TufJZPYUzYoSPZBX0FkqgZ9u03VAIsZdwvY1PS7nw,8848
26
+ gllm_core/utils/__init__.pyi,sha256=ZFilGPXXqc2JGwy8AV8N7pf6zmtd9clzuk310PIGkBs,1359
27
+ gllm_core/utils/analyzer.pyi,sha256=M48PRor76L5eAQBpSqpv3EkZ4kU1t5Zm3CPFd34dxWM,4470
28
+ gllm_core/utils/binary_handler_factory.pyi,sha256=imcuCL2oa-7uwTnC_vI-_KvE1hGu1-5U4ZiF5fShDmQ,1739
29
+ gllm_core/utils/chunk_metadata_merger.pyi,sha256=J1lHTFV-0IiC6xKzzC7x1D1wBoki249muEU2HrF6C58,2317
30
+ gllm_core/utils/concurrency.pyi,sha256=n_Mb9D_2hJAQ7VSwDBxhgmDv7hyFRKevDlhcHoAjvyA,3959
31
+ gllm_core/utils/event_formatter.pyi,sha256=ocQ_Ev_XorRhLzj0c2szlclz8V3_Ysbg6qHmjhmur3k,1375
32
+ gllm_core/utils/google_sheets.pyi,sha256=IjKdc7H3hBLAp8I8jxnwDfKP79D1EIBIRQKKFTUNqjM,939
33
+ gllm_core/utils/imports.pyi,sha256=-KM0pyw7yFVCUZjHjoNBRFgEnI8hlr0pquKuhcA2X9M,2196
34
+ gllm_core/utils/logger_manager.pyi,sha256=IDRgA-5jRDu4miO5Ru_tFJHql2JlHdr1GvZdmdS9Sg8,7159
35
+ gllm_core/utils/main_method_resolver.pyi,sha256=dHozSqFMwCyVorQ0ZE9N-c2V4PkpF8FdU1VGGPvTjK4,2178
36
+ gllm_core/utils/merger_method.pyi,sha256=JsgHnO47cqenqNxCrHqhAR-nnR_dEqE-7wprVrd8ZFg,1868
37
+ gllm_core/utils/retry.pyi,sha256=KxlPzURzZfCSgKC44v98nR2bqamzHqtbRuXLDEuX29c,1614
38
+ gllm_core/utils/similarity.pyi,sha256=HmSxE5VfPwYZYih_bSIz8QRDbkouO_jij-FX6TSCEdM,439
39
+ gllm_core/utils/validation.pyi,sha256=-RdMmb8afH7F7q4Ao7x6FbwaDfxUHn3hA3WiOgzB-3s,397
40
+ gllm_core.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
41
+ gllm_core_binary-0.4.4b3.dist-info/METADATA,sha256=twBMLynLeu3Z9RMIH4bBPynGtO4JBYoKxFvBo9H3s0Y,4681
42
+ gllm_core_binary-0.4.4b3.dist-info/WHEEL,sha256=l2aKBREYfqJ7T2ljmr6hUiXPoNvvXF47bG4IHjuSyS4,96
43
+ gllm_core_binary-0.4.4b3.dist-info/top_level.txt,sha256=UYoTGvK_Yec95-_QUuVCKEr6PUXb5Lc7Dr-x8SeX9uM,10
44
+ gllm_core_binary-0.4.4b3.dist-info/RECORD,,
@@ -1,38 +0,0 @@
1
- gllm_core.cp311-win_amd64.pyd,sha256=Yk3AMBvaZT6sWLfpD9w4-GnGV2RNGZv-azacDll2nhQ,1100288
2
- gllm_core.pyi,sha256=uFfH-UIH_BzQ6ZGcsg0-Yf6HN-hjUpbCzOjXoURo8Is,1343
3
- gllm_core/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- gllm_core/constants.pyi,sha256=p7-Sr-sNmjv6mboGJmALDd3UtTZ4y0m_gmUXIBbAzBk,923
5
- gllm_core/event/__init__.pyi,sha256=HVs5C80lFzVEH7mO8KJTUqEPi_7KyPvNeMLuoG-hDeE,177
6
- gllm_core/event/event_emitter.pyi,sha256=7WcK-SV4xVwh48rsc-gt_41J8qksBTxbWSWfnr85dYk,8386
7
- gllm_core/event/messenger.pyi,sha256=8Nvra-a7RqnfX0PAtm-Of5M8CvsYr0L_1k3HgdNCR5I,3190
8
- gllm_core/event/handler/__init__.pyi,sha256=gZ21Fjjog3-e3-_Xv5sTpX9_Mx8X2LUzTrqp_tPisCg,377
9
- gllm_core/event/handler/console_event_handler.pyi,sha256=h3Dpj6-UeZnKUm7iFFOmRWk8k2Hw6YsvP28FUWYjU4U,1550
10
- gllm_core/event/handler/event_handler.pyi,sha256=chEYnw3Rp9Lk3Cz4dSn6EVlzje4BG-SlM82J-4UE5Hw,2153
11
- gllm_core/event/handler/print_event_handler.pyi,sha256=Z34M73brc4eaDLDt_nmdo638qsyUVuuMLyIJ0PdBt6c,1805
12
- gllm_core/event/handler/stream_event_handler.pyi,sha256=5faGSFQLBN7XMqd4nIfGkdTBI_ALVaE-fmxVAjzca9w,2908
13
- gllm_core/event/hook/__init__.pyi,sha256=gSDHYl0yi00zHHMRvU_Eg8qLqsGHESTvoNE3MXig-g0,149
14
- gllm_core/event/hook/event_hook.pyi,sha256=rMatofdNAwHI65ya_7-q3NAfmTuKhc2WkXeiGPAvcKI,600
15
- gllm_core/event/hook/json_stringify_event_hook.pyi,sha256=I-QxbaLc4rEyqhW_f4INN5UxBg_ZofHHN1HQKfPJ7rs,585
16
- gllm_core/schema/__init__.pyi,sha256=oqfGtlLWbWJmHiKXA9Yfz1HoEpMRqStnxwNaRRIb2Vw,288
17
- gllm_core/schema/chunk.pyi,sha256=ZVYQitMtvMStiFssnTCgtSIcj30VSsK2dKscSysl3R4,2378
18
- gllm_core/schema/component.pyi,sha256=3eJs3KlLdsJ5vMebwvBRGappUZ43tmdMtl2mQpSob7k,2843
19
- gllm_core/schema/event.pyi,sha256=Yd74uSWhIO1lx0_p70rYt-LMz4FZHbbbqJP7xhVh_pY,1335
20
- gllm_core/schema/tool.pyi,sha256=miqqYG0XtNY4p7UCYRS1-A23FY9wq_LZ6RvbcgGIyNQ,8038
21
- gllm_core/utils/__init__.pyi,sha256=U13s25K_edFp2WoCHfB0NyTROXvnP62P5A2YRukSIhs,1246
22
- gllm_core/utils/analyzer.pyi,sha256=M7_KYdBqz5S5fEPvnd49e6ij01dOvJD-k7amAlvRwNQ,3989
23
- gllm_core/utils/binary_handler_factory.pyi,sha256=imcuCL2oa-7uwTnC_vI-_KvE1hGu1-5U4ZiF5fShDmQ,1739
24
- gllm_core/utils/chunk_metadata_merger.pyi,sha256=J1lHTFV-0IiC6xKzzC7x1D1wBoki249muEU2HrF6C58,2317
25
- gllm_core/utils/concurrency.pyi,sha256=n_Mb9D_2hJAQ7VSwDBxhgmDv7hyFRKevDlhcHoAjvyA,3959
26
- gllm_core/utils/event_formatter.pyi,sha256=ocQ_Ev_XorRhLzj0c2szlclz8V3_Ysbg6qHmjhmur3k,1375
27
- gllm_core/utils/google_sheets.pyi,sha256=IjKdc7H3hBLAp8I8jxnwDfKP79D1EIBIRQKKFTUNqjM,939
28
- gllm_core/utils/imports.pyi,sha256=-KM0pyw7yFVCUZjHjoNBRFgEnI8hlr0pquKuhcA2X9M,2196
29
- gllm_core/utils/logger_manager.pyi,sha256=pOXREtzMuLpWRl2-IwmPc6Kk3RCmB8Se5laX3MQhqls,7095
30
- gllm_core/utils/merger_method.pyi,sha256=JsgHnO47cqenqNxCrHqhAR-nnR_dEqE-7wprVrd8ZFg,1868
31
- gllm_core/utils/retry.pyi,sha256=2RcG5C9xQS2nCSWBmtsOfKgIk5mVXHmYBrXrqStvsrI,2839
32
- gllm_core/utils/similarity.pyi,sha256=HmSxE5VfPwYZYih_bSIz8QRDbkouO_jij-FX6TSCEdM,439
33
- gllm_core/utils/validation.pyi,sha256=-RdMmb8afH7F7q4Ao7x6FbwaDfxUHn3hA3WiOgzB-3s,397
34
- gllm_core.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
35
- gllm_core_binary-0.3.26.dist-info/METADATA,sha256=d90BKKtLhS4qjcIPXtqAcDTt_RcFuGgCz0aHH_q1LOQ,4430
36
- gllm_core_binary-0.3.26.dist-info/WHEEL,sha256=l2aKBREYfqJ7T2ljmr6hUiXPoNvvXF47bG4IHjuSyS4,96
37
- gllm_core_binary-0.3.26.dist-info/top_level.txt,sha256=UYoTGvK_Yec95-_QUuVCKEr6PUXb5Lc7Dr-x8SeX9uM,10
38
- gllm_core_binary-0.3.26.dist-info/RECORD,,