gllm-inference-binary 0.5.42__cp313-cp313-win_amd64.whl → 0.5.44__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.

Potentially problematic release.


This version of gllm-inference-binary might be problematic. Click here for more details.

@@ -1,7 +1,7 @@
1
1
  from _typeshed import Incomplete
2
- from gllm_inference.em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker, BedrockEMInvoker as BedrockEMInvoker, GoogleEMInvoker as GoogleEMInvoker, JinaEMInvoker as JinaEMInvoker, LangChainEMInvoker as LangChainEMInvoker, OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker, OpenAIEMInvoker as OpenAIEMInvoker, TwelveLabsEMInvoker as TwelveLabsEMInvoker, VoyageEMInvoker as VoyageEMInvoker
2
+ from gllm_inference.em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker, BedrockEMInvoker as BedrockEMInvoker, CohereEMInvoker as CohereEMInvoker, GoogleEMInvoker as GoogleEMInvoker, JinaEMInvoker as JinaEMInvoker, LangChainEMInvoker as LangChainEMInvoker, OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker, OpenAIEMInvoker as OpenAIEMInvoker, TwelveLabsEMInvoker as TwelveLabsEMInvoker, VoyageEMInvoker as VoyageEMInvoker
3
3
  from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
4
- from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider
4
+ from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider, OPTIONAL_PATH_PROVIDERS as OPTIONAL_PATH_PROVIDERS
5
5
  from typing import Any
6
6
 
7
7
  PROVIDER_TO_EM_INVOKER_MAP: dict[str, type[BaseEMInvoker]]
@@ -1,5 +1,6 @@
1
1
  from gllm_inference.em_invoker.azure_openai_em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker
2
2
  from gllm_inference.em_invoker.bedrock_em_invoker import BedrockEMInvoker as BedrockEMInvoker
3
+ from gllm_inference.em_invoker.cohere_em_invoker import CohereEMInvoker as CohereEMInvoker
3
4
  from gllm_inference.em_invoker.google_em_invoker import GoogleEMInvoker as GoogleEMInvoker
4
5
  from gllm_inference.em_invoker.jina_em_invoker import JinaEMInvoker as JinaEMInvoker
5
6
  from gllm_inference.em_invoker.langchain_em_invoker import LangChainEMInvoker as LangChainEMInvoker
@@ -8,4 +9,4 @@ from gllm_inference.em_invoker.openai_em_invoker import OpenAIEMInvoker as OpenA
8
9
  from gllm_inference.em_invoker.twelevelabs_em_invoker import TwelveLabsEMInvoker as TwelveLabsEMInvoker
9
10
  from gllm_inference.em_invoker.voyage_em_invoker import VoyageEMInvoker as VoyageEMInvoker
10
11
 
11
- __all__ = ['AzureOpenAIEMInvoker', 'BedrockEMInvoker', 'GoogleEMInvoker', 'JinaEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
12
+ __all__ = ['AzureOpenAIEMInvoker', 'BedrockEMInvoker', 'CohereEMInvoker', 'GoogleEMInvoker', 'JinaEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
@@ -0,0 +1,128 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.utils.retry import RetryConfig as RetryConfig
3
+ from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
4
+ from gllm_inference.em_invoker.schema.cohere import CohereInputType as CohereInputType, Key as Key
5
+ from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, EMContent as EMContent, ModelId as ModelId, ModelProvider as ModelProvider, TruncationConfig as TruncationConfig, Vector as Vector
6
+ from gllm_inference.utils import validate_string_enum as validate_string_enum
7
+ from typing import Any
8
+
9
+ SUPPORTED_ATTACHMENTS: Incomplete
10
+ MULTIMODAL_MODEL_VERSION: Incomplete
11
+
12
+ class CohereEMInvoker(BaseEMInvoker):
13
+ '''An embedding model invoker to interact with Cohere embedding models.
14
+
15
+ Attributes:
16
+ model_id (str): The model ID of the embedding model.
17
+ model_provider (str): The provider of the embedding model (Cohere).
18
+ model_name (str): The name of the Cohere embedding model.
19
+ client (AsyncClient): The asynchronous client for the Cohere API.
20
+ default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the embedding model.
21
+ retry_config (RetryConfig): The retry configuration for the embedding model.
22
+ truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
23
+ input_type (CohereInputType): The input type for the embedding model. Supported values include:
24
+ 1. `CohereInputType.SEARCH_DOCUMENT`,
25
+ 2. `CohereInputType.SEARCH_QUERY`,
26
+ 3. `CohereInputType.CLASSIFICATION`,
27
+ 4. `CohereInputType.CLUSTERING`,
28
+ 5. `CohereInputType.IMAGE`.
29
+
30
+ Initialization:
31
+ You can initialize the `CohereEMInvoker` as follows:
32
+ ```python
33
+ em_invoker = CohereEMInvoker(
34
+ model_name="embed-english-v4.0",
35
+ input_type="search_document"
36
+ )
37
+ ```
38
+
39
+ Note: The `input_type` parameter can be one of the following:
40
+ 1. "search_document"
41
+ 2. "search_query"
42
+ 3. "classification"
43
+ 4. "clustering"
44
+ 5. "image"
45
+
46
+ This parameter is optional and defaults to "search_document". For more information about
47
+ input_type, please refer to https://docs.cohere.com/docs/embeddings#the-input_type-parameter.
48
+
49
+ Input types:
50
+ The `CohereEMInvoker` supports the following input types: text and image.
51
+ Non-text inputs must be passed as an `Attachment` object.
52
+
53
+ Output format:
54
+ The `CohereEMInvoker` can embed either:
55
+ 1. A single content.
56
+ 1. A single content is either a text or an image.
57
+ 2. The output will be a `Vector`, representing the embedding of the content.
58
+
59
+ # Example 1: Embedding a text content.
60
+ ```python
61
+ text = "What animal is in this image?"
62
+ result = await em_invoker.invoke(text)
63
+ ```
64
+
65
+ # Example 2: Embedding an image content.
66
+ ```python
67
+ image = Attachment.from_path("path/to/local/image.png")
68
+ result = await em_invoker.invoke(image)
69
+ ```
70
+
71
+ The above examples will return a `Vector` with a size of (embedding_size,).
72
+
73
+ 2. A list of contents.
74
+ 1. A list of contents is a list that consists of any of the above single contents.
75
+ 2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
76
+ embedding of each single content.
77
+
78
+ # Example: Embedding a list of contents.
79
+ ```python
80
+ text = "What animal is in this image?"
81
+ image = Attachment.from_path("path/to/local/image.png")
82
+ result = await em_invoker.invoke([text, image])
83
+ ```
84
+
85
+ The above examples will return a `list[Vector]` with a size of (2, embedding_size).
86
+
87
+ Retry and timeout:
88
+ The `CohereEMInvoker` supports retry and timeout configuration.
89
+ By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
90
+ They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
91
+
92
+ Retry config examples:
93
+ ```python
94
+ retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
95
+ retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
96
+ retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
97
+ retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
98
+ ```
99
+
100
+ Usage example:
101
+ ```python
102
+ em_invoker = CohereEMInvoker(..., retry_config=retry_config)
103
+ ```
104
+
105
+ '''
106
+ input_type: Incomplete
107
+ client: Incomplete
108
+ def __init__(self, model_name: str, api_key: str | None = None, base_url: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None, input_type: CohereInputType = ...) -> None:
109
+ '''Initializes a new instance of the CohereEMInvoker class.
110
+
111
+ Args:
112
+ model_name (str): The name of the Cohere embedding model to be used.
113
+ api_key (str | None, optional): The API key for authenticating with Cohere. Defaults to None, in which
114
+ case the `COHERE_API_KEY` environment variable will be used.
115
+ base_url (str | None, optional): The base URL for a custom Cohere-compatible endpoint.
116
+ Defaults to None, in which case Cohere\'s default URL will be used.
117
+ model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the Cohere client.
118
+ Defaults to None.
119
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
120
+ Defaults to None.
121
+ retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
122
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
123
+ truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
124
+ Defaults to None, in which case no truncation is applied.
125
+ input_type (CohereInputType, optional): The input type for the embedding model.
126
+ Defaults to `CohereInputType.SEARCH_DOCUMENT`. Valid values are: "search_document", "search_query",
127
+ "classification", "clustering", and "image".
128
+ '''
@@ -0,0 +1,20 @@
1
+ from enum import StrEnum
2
+
3
+ class Key(StrEnum):
4
+ """Defines valid keys in Cohere."""
5
+ BASE_URL = 'base_url'
6
+ IMAGE_URL = 'image_url'
7
+ INPUT_TYPE = 'input_type'
8
+ MAX_RETRIES = 'max_retries'
9
+ MODEL = 'model'
10
+ TIMEOUT = 'timeout'
11
+ TYPE = 'type'
12
+ URL = 'url'
13
+
14
+ class CohereInputType(StrEnum):
15
+ """Defines valid embedding input types for Cohere embedding API."""
16
+ CLASSIFICATION = 'classification'
17
+ CLUSTERING = 'clustering'
18
+ IMAGE = 'image'
19
+ SEARCH_DOCUMENT = 'search_document'
20
+ SEARCH_QUERY = 'search_query'
@@ -13,6 +13,7 @@ class ExtendedHTTPStatus(IntEnum):
13
13
  HTTP_STATUS_TO_EXCEPTION_MAP: dict[int, type[BaseInvokerError]]
14
14
  ANTHROPIC_ERROR_MAPPING: Incomplete
15
15
  BEDROCK_ERROR_MAPPING: Incomplete
16
+ COHERE_ERROR_MAPPING: Incomplete
16
17
  GOOGLE_ERROR_MAPPING: Incomplete
17
18
  LANGCHAIN_ERROR_CODE_MAPPING: Incomplete
18
19
  LITELLM_ERROR_MAPPING: Incomplete
@@ -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 Activity as Activity, Attachment as Attachment, AttachmentType as AttachmentType, BatchStatus as BatchStatus, 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
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
 
@@ -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, 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', '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
- server_name (str): The name of the MCP server.
21
- tools (list[dict[str, str]] | None): The tools in the MCP server.
22
- type (str): The type of activity being performed.
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 (str): The type of activity being performed.
47
- pattern (str): The pattern of the web search.
48
- url (str): The URL of the page.
49
- query (str): The query of the web search.
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: Literal[ActivityType.FIND_IN_PAGE, ActivityType.OPEN_PAGE, ActivityType.SEARCH]
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.
@@ -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'
@@ -1,108 +1,123 @@
1
- from gllm_core.constants import EventLevel
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 EmitDataType as EmitDataType
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 unique identifier for the activity event. Defaults to an empty 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.
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
- id: str
17
- type: Literal[EmitDataType.ACTIVITY]
18
- value: Activity
19
- level: EventLevel
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-triggered code execution.
37
+ """Event schema for model-generated code to be executed.
23
38
 
24
39
  Attributes:
25
- id (str): The unique identifier for the code event. Defaults to an empty string.
26
- type (Literal): The type of event (code, code_start, or code_end).
27
- value (str): The code content.
28
- level (EventLevel): The severity level of the event. Defined through the EventLevel constants.
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
- level: EventLevel
48
+ type: CodeEventType
34
49
  @classmethod
35
- def start(cls, id_: str | None = '') -> CodeEvent:
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 unique identifier for the code event. Defaults to an empty string.
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 = '', value: str = '') -> CodeEvent:
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 unique identifier for the code event. Defaults to an empty string.
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 = '') -> CodeEvent:
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 unique identifier for the code event. Defaults to an empty string.
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 unique identifier for the thinking event. Defaults to an empty string.
71
- type (Literal): The type of thinking event (thinking, thinking_start, or thinking_end).
72
- value (str): The thinking content or message.
73
- level (EventLevel): The severity level of the event. Defined through the EventLevel constants.
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
- level: EventLevel
93
+ type: ThinkingEventType
79
94
  @classmethod
80
- def start(cls, id_: str | None = '') -> ThinkingEvent:
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 unique identifier for the thinking event. Defaults to an empty string.
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 = '', value: str = '') -> ThinkingEvent:
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 unique identifier for the thinking event. Defaults to an empty string.
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 = '') -> ThinkingEvent:
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 unique identifier for the thinking event. Defaults to an empty string.
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.
@@ -12,6 +12,7 @@ class ModelProvider(StrEnum):
12
12
  ANTHROPIC = 'anthropic'
13
13
  AZURE_OPENAI = 'azure-openai'
14
14
  BEDROCK = 'bedrock'
15
+ COHERE = 'cohere'
15
16
  DATASAUR = 'datasaur'
16
17
  GOOGLE = 'google'
17
18
  JINA = 'jina'
@@ -46,6 +47,11 @@ class ModelId(BaseModel):
46
47
  model_id = ModelId.from_string("bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0")
47
48
  ```
48
49
 
50
+ # Using Cohere
51
+ ```python
52
+ model_id = ModelId.from_string("cohere/embed-english-v3.0")
53
+ ```
54
+
49
55
  # Using Datasaur
50
56
  ```python
51
57
  model_id = ModelId.from_string("datasaur/https://deployment.datasaur.ai/api/deployment/teamId/deploymentId/")
@@ -102,6 +108,7 @@ class ModelId(BaseModel):
102
108
  ```python
103
109
  model_id = ModelId.from_string("langchain/langchain_openai.ChatOpenAI:gpt-4o-mini")
104
110
  ```
111
+
105
112
  For the list of supported providers, please refer to the following table:
106
113
  https://python.langchain.com/docs/integrations/chat/#featured-providers
107
114
 
Binary file
gllm_inference.pyi CHANGED
@@ -14,6 +14,7 @@ import gllm_core
14
14
  import gllm_core.utils
15
15
  import gllm_inference.em_invoker.AzureOpenAIEMInvoker
16
16
  import gllm_inference.em_invoker.BedrockEMInvoker
17
+ import gllm_inference.em_invoker.CohereEMInvoker
17
18
  import gllm_inference.em_invoker.GoogleEMInvoker
18
19
  import gllm_inference.em_invoker.JinaEMInvoker
19
20
  import gllm_inference.em_invoker.LangChainEMInvoker
@@ -51,17 +52,19 @@ import gllm_inference.exceptions.BaseInvokerError
51
52
  import gllm_inference.exceptions.convert_http_status_to_base_invoker_error
52
53
  import gllm_inference.schema.Vector
53
54
  import aioboto3
54
- import asyncio.CancelledError
55
- import gllm_inference.exceptions.convert_to_base_invoker_error
55
+ import base64
56
56
  import gllm_inference.schema.Attachment
57
57
  import gllm_inference.schema.AttachmentType
58
58
  import gllm_inference.schema.EMContent
59
+ import gllm_inference.utils.validate_string_enum
60
+ import cohere
61
+ import asyncio.CancelledError
62
+ import gllm_inference.exceptions.convert_to_base_invoker_error
59
63
  import gllm_inference.schema.TruncateSide
60
64
  import google
61
65
  import google.auth
62
66
  import google.genai
63
67
  import google.genai.types
64
- import base64
65
68
  import httpx
66
69
  import gllm_inference.exceptions.ProviderInternalError
67
70
  import concurrent
@@ -111,9 +114,8 @@ import inspect
111
114
  import time
112
115
  import jsonschema
113
116
  import gllm_inference.lm_invoker.batch.BatchOperations
114
- import gllm_inference.schema.Activity
117
+ import gllm_inference.schema.LMEventType
115
118
  import gllm_inference.schema.MessageContent
116
- import gllm_inference.utils.validate_string_enum
117
119
  import __future__
118
120
  import gllm_inference.schema.ActivityEvent
119
121
  import gllm_inference.schema.CodeEvent
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: gllm-inference-binary
3
- Version: 0.5.42
3
+ Version: 0.5.44
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.0
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
@@ -30,6 +30,8 @@ Provides-Extra: anthropic
30
30
  Requires-Dist: anthropic<0.61.0,>=0.60.0; extra == "anthropic"
31
31
  Provides-Extra: bedrock
32
32
  Requires-Dist: aioboto3<16.0.0,>=15.0.0; extra == "bedrock"
33
+ Provides-Extra: cohere
34
+ Requires-Dist: cohere<6.0.0,>=5.18.0; extra == "cohere"
33
35
  Provides-Extra: datasaur
34
36
  Requires-Dist: openai<2.0.0,>=1.98.0; extra == "datasaur"
35
37
  Provides-Extra: google
@@ -1,9 +1,9 @@
1
- gllm_inference.cp313-win_amd64.pyd,sha256=FYH5KTQcK7_qnRISOhH_EgUHRR5OuNaCaJrqsP7zsmc,3619840
2
- gllm_inference.pyi,sha256=ifuvcH5p0J0Q2zXwfqXT4Sh5kcodA7O8x6SmQJ-_M0w,4852
1
+ gllm_inference.cp313-win_amd64.pyd,sha256=3Xnjm5F7tiaEIKRL19GPUPLSnwzUmugqGBtivByuSOs,3671552
2
+ gllm_inference.pyi,sha256=PN9a6F49IGwGrPXny7b-knSKeGsO_ER8e9DaBqiOD2k,4918
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
6
- gllm_inference/builder/build_em_invoker.pyi,sha256=ij24IMOYIYjia_cONdVhfW0QpulqyqG6nQhTdo5fYs0,6195
6
+ gllm_inference/builder/build_em_invoker.pyi,sha256=3vO_pLokR4BAZflOMu6qzXoKx6vibT16uwJETH5Y_yc,6283
7
7
  gllm_inference/builder/build_lm_invoker.pyi,sha256=HvQICF-qvOTzfXZUqhi7rlwcpkMZpxaC-8QZmhnXKzI,7466
8
8
  gllm_inference/builder/build_lm_request_processor.pyi,sha256=H7Rg88e7PTTCtuyY64r333moTmh4-ypOwgnG10gkEdY,4232
9
9
  gllm_inference/builder/build_output_parser.pyi,sha256=sgSTrzUmSRxPzUUum0fDU7A3NXYoYhpi6bEx4Q2XMnA,965
@@ -11,9 +11,10 @@ gllm_inference/catalog/__init__.pyi,sha256=HWgPKWIzprpMHRKe_qN9BZSIQhVhrqiyjLjIX
11
11
  gllm_inference/catalog/catalog.pyi,sha256=eWPqgQKi-SJGHabi_XOTEKpAj96OSRypKsb5ZEC1VWU,4911
12
12
  gllm_inference/catalog/lm_request_processor_catalog.pyi,sha256=FiveqPDkV58XbDO2znXL-Ix5tFbZwNiVnitlEa90YOY,5536
13
13
  gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=iViWB4SaezzjQY4UY1YxeoXUNxqxa2cTJGaD9JSx4Q8,3279
14
- gllm_inference/em_invoker/__init__.pyi,sha256=ClcAHvB87iqUZ-clWxKqT0dD3v6Tas43pQiRWOgYnog,1100
14
+ gllm_inference/em_invoker/__init__.pyi,sha256=uCWfCjh5a5DciRFcUdbHndewokM3J5hp3mbhmM5wQC8,1211
15
15
  gllm_inference/em_invoker/azure_openai_em_invoker.pyi,sha256=TXC5Kgf1eZqK2FHKAyeG3LB1SEsSEStnbk9bI1mjC5k,5049
16
16
  gllm_inference/em_invoker/bedrock_em_invoker.pyi,sha256=kQETh2r-WR_H3APtt4QavmfwGOR3KB4k6USNYvFateY,5831
17
+ gllm_inference/em_invoker/cohere_em_invoker.pyi,sha256=4eLqeKLoK8vJB61bGdttfWUUvNDBToBqNA6KQYBMT8s,6793
17
18
  gllm_inference/em_invoker/em_invoker.pyi,sha256=YDYJ8TGScsz5Gg-OBnEENN1tI1RYvwoddypxUr6SAWw,5191
18
19
  gllm_inference/em_invoker/google_em_invoker.pyi,sha256=zZYjeLp9ncwIVM4UHqDJSVOFn1eXiaz9Ba24-_fCF2c,6953
19
20
  gllm_inference/em_invoker/jina_em_invoker.pyi,sha256=wrivFiPFRWBSw-TEAkaQKBvBRhlzN6CBaZkc0HOslRw,5754
@@ -26,6 +27,7 @@ gllm_inference/em_invoker/langchain/__init__.pyi,sha256=aOTlRvS9aG1tBErjsmhe75s4
26
27
  gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi,sha256=BBSDazMOckO9Aw17tC3LGUTPqLb01my1xUZLtKZlwJY,3388
27
28
  gllm_inference/em_invoker/schema/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
29
  gllm_inference/em_invoker/schema/bedrock.pyi,sha256=HoNgVi0T21aFd1JrCnSLu4yryv8k8RnYdR3-tIdHFgA,498
30
+ gllm_inference/em_invoker/schema/cohere.pyi,sha256=Wio6h0sbY93GygqETtflRaaucFzYSeLZRg7jyxMDK0s,567
29
31
  gllm_inference/em_invoker/schema/google.pyi,sha256=bzdtu4DFH2kATLybIeNl_Lznj99H-6u2Fvx3Zx52oZg,190
30
32
  gllm_inference/em_invoker/schema/jina.pyi,sha256=EFo4d8HuzPEZDV5F0PwUIkYPrCTEiCqHq17ICzYxKeg,739
31
33
  gllm_inference/em_invoker/schema/langchain.pyi,sha256=SZ13HDcvAOGmDTi2b72H6Y1J5GePR21JdnM6gYrwcGs,117
@@ -36,7 +38,7 @@ gllm_inference/em_invoker/schema/voyage.pyi,sha256=Aqvu6mhFkNb01aXAI5mChLKIgEnFn
36
38
  gllm_inference/exceptions/__init__.pyi,sha256=nXOqwsuwUgsnBcJEANVuxbZ1nDfcJ6-pKUfKeZwltkk,1218
37
39
  gllm_inference/exceptions/error_parser.pyi,sha256=4aiJZhBzBOqlhdmpvaCvildGy7_XxlJzQpe3PzGt8eE,2040
38
40
  gllm_inference/exceptions/exceptions.pyi,sha256=6y3ECgHAStqMGgQv8Dv-Ui-5PDD07mSj6qaRZeSWea4,5857
39
- gllm_inference/exceptions/provider_error_map.pyi,sha256=4AsAgbXAh91mxEW2YiomEuhBoeSNeAIo9WbT9WK8gQk,1233
41
+ gllm_inference/exceptions/provider_error_map.pyi,sha256=vWa4ZIHn7qIghECGvO-dS2KzOmf3c10GRWKZ4YDPnSQ,1267
40
42
  gllm_inference/lm_invoker/__init__.pyi,sha256=jG1xc5fTOeIgeKKVYSnsMzQThKk9kTW38yO_MYtv540,1387
41
43
  gllm_inference/lm_invoker/anthropic_lm_invoker.pyi,sha256=JSgKUk9d1ZHlitv_ZjHlAk2hIW-J7u6yslVHflIeUro,16726
42
44
  gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi,sha256=FYfRNPG-oD4wIfitjTHnGib1uMZL7Pid0gbrRsymAHU,14601
@@ -45,7 +47,7 @@ gllm_inference/lm_invoker/datasaur_lm_invoker.pyi,sha256=LR0EM4vTfufq9OWk8JVIwLy
45
47
  gllm_inference/lm_invoker/google_lm_invoker.pyi,sha256=aSmEgoYj_V72Nb6erDResphw9RaHfbE5C6PhqpMfEeQ,17674
46
48
  gllm_inference/lm_invoker/langchain_lm_invoker.pyi,sha256=tJIxkFUKjLF-yz0niaDjN3L0QNCbn4sT8hmPKtERpog,12742
47
49
  gllm_inference/lm_invoker/litellm_lm_invoker.pyi,sha256=IJxRUkmgXY8oQwS7tJoskO8fiESB7M4pyvpE64pyXDo,12648
48
- gllm_inference/lm_invoker/lm_invoker.pyi,sha256=vUmMNEl7F__PavQJ42scoYGyWdEvZOw2Bwxhoqv_gKE,8659
50
+ gllm_inference/lm_invoker/lm_invoker.pyi,sha256=PS4cJ5VLNfHqeTgCerY-c1Xaa7ktdWAiT-f3Lnc0wvE,8665
49
51
  gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi,sha256=uYJFgi4tJGab77232IC1gdoU9h9AqoClIUj6tM6O47s,15177
50
52
  gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi,sha256=T9sShA_9fgEuaaAuT2gJZq_EYNbEhf3IkWwMCwfszY8,4244
51
53
  gllm_inference/lm_invoker/openai_lm_invoker.pyi,sha256=10iKCyleqHNbJc8M1rj3ogRcNlNxcVgyk0v6TcS6gf4,23452
@@ -97,18 +99,18 @@ gllm_inference/realtime_chat/output_streamer/output_streamer.pyi,sha256=5P9NQ0aJ
97
99
  gllm_inference/request_processor/__init__.pyi,sha256=giEme2WFQhgyKiBZHhSet0_nKSCHwGy-_2p6NRzg0Zc,231
98
100
  gllm_inference/request_processor/lm_request_processor.pyi,sha256=0fy1HyILCVDw6y46E-7tLnQTRYx4ppeRMe0QP6t9Jyw,5990
99
101
  gllm_inference/request_processor/uses_lm_mixin.pyi,sha256=LYHq-zLoXEMel1LfVdYv7W3BZ8WtBLo_WWFjRf10Yto,6512
100
- gllm_inference/schema/__init__.pyi,sha256=Cu626ItICSPEArngfqm78RFz6xq2_Z4YXdyFxQHb-V4,2134
101
- gllm_inference/schema/activity.pyi,sha256=JsM2EwvaDicM6OOmVMBSPSdizbQgq-IEoD881w0RMyg,2036
102
+ gllm_inference/schema/__init__.pyi,sha256=cGEeGc5xDyfepbCi5r_c61VmS6VnWyvoRjjK7K13lLg,2177
103
+ gllm_inference/schema/activity.pyi,sha256=atrU4OwLesA9FEt1H7K3gsUWYNdOqpI5i2VdWkmo6cs,2367
102
104
  gllm_inference/schema/attachment.pyi,sha256=9zgAjGXBjLfzPGaKi68FMW6b5mXdEA352nDe-ynOSvY,3385
103
105
  gllm_inference/schema/code_exec_result.pyi,sha256=WQ-ARoGM9r6nyRX-A0Ro1XKiqrc9R3jRYXZpu_xo5S4,573
104
106
  gllm_inference/schema/config.pyi,sha256=NVmjQK6HipIE0dKSfx12hgIC0O-S1HEcAc-TWlXAF5A,689
105
- gllm_inference/schema/enums.pyi,sha256=U30RGvNFcNNJxTZZPt8vK7SFp3W4KSPVFxTZaiF1eLU,1375
106
- gllm_inference/schema/events.pyi,sha256=HMkGU1XoLDR6h9-L13LEn_27Z9jkmKk-kBTD-0qKzJY,4029
107
+ gllm_inference/schema/enums.pyi,sha256=zuKgBxcm0GXvyEZag3FAETFTG-uikgjGJ5QRoXluSZg,1675
108
+ gllm_inference/schema/events.pyi,sha256=iG3sFAhvek-fSJgmUE6nJ5M0XzSpRKKpJJiXyuB4Wq0,5058
107
109
  gllm_inference/schema/lm_input.pyi,sha256=HxQiZgY7zcXh_Dw8nK8LSeBTZEHMPZVwmPmnfgSsAbs,197
108
110
  gllm_inference/schema/lm_output.pyi,sha256=DIV8BiIOPaSnMKxzKzH_Mp7j7-MScWCvmllegJDLqFg,2479
109
111
  gllm_inference/schema/mcp.pyi,sha256=4SgQ83pEowfWm2p-w9lupV4NayqqVBOy7SuYxIFeWRs,1045
110
112
  gllm_inference/schema/message.pyi,sha256=jJV6A0ihEcun2OhzyMtNkiHnf7d6v5R-GdpTBGfJ0AQ,2272
111
- gllm_inference/schema/model_id.pyi,sha256=eFNCNAmDSk0M6SqjDq8JRs0I1UcVzx2JhYWaHSFDGTQ,5667
113
+ gllm_inference/schema/model_id.pyi,sha256=3PeAHrCyMAZJPCa7CfaArmOHdh2oDdUu6lkyx9mKG9g,5819
112
114
  gllm_inference/schema/reasoning.pyi,sha256=jbPxkDRHt0Vt-zdcc8lTT1l2hIE1Jm3HIHeNd0hfXGo,577
113
115
  gllm_inference/schema/token_usage.pyi,sha256=WJiGQyz5qatzBK2b-sABLCyTRLCBbAvxCRcqSJOzu-8,3025
114
116
  gllm_inference/schema/tool_call.pyi,sha256=OWT9LUqs_xfUcOkPG0aokAAqzLYYDkfnjTa0zOWvugk,403
@@ -119,7 +121,7 @@ gllm_inference/utils/io_utils.pyi,sha256=Eg7dvHWdXslTKdjh1j3dG50i7r35XG2zTmJ9XXv
119
121
  gllm_inference/utils/langchain.pyi,sha256=4AwFiVAO0ZpdgmqeC4Pb5NJwBt8vVr0MSUqLeCdTscc,1194
120
122
  gllm_inference/utils/validation.pyi,sha256=-RdMmb8afH7F7q4Ao7x6FbwaDfxUHn3hA3WiOgzB-3s,397
121
123
  gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
122
- gllm_inference_binary-0.5.42.dist-info/METADATA,sha256=tpuAFFqRUaKa8IeR8xqcX5b0j4e_BkVO9xA7AnIfNGY,5770
123
- gllm_inference_binary-0.5.42.dist-info/WHEEL,sha256=O_u6PJIQ2pIcyIInxVQ9r-yArMuUZbBIaF1kpYVkYxA,96
124
- gllm_inference_binary-0.5.42.dist-info/top_level.txt,sha256=FpOjtN80F-qVNgbScXSEyqa0w09FYn6301iq6qt69IQ,15
125
- gllm_inference_binary-0.5.42.dist-info/RECORD,,
124
+ gllm_inference_binary-0.5.44.dist-info/METADATA,sha256=k03CIyjygon71qyD5--ATKsmuR5bi1IZyMotR-Gyqes,5852
125
+ gllm_inference_binary-0.5.44.dist-info/WHEEL,sha256=O_u6PJIQ2pIcyIInxVQ9r-yArMuUZbBIaF1kpYVkYxA,96
126
+ gllm_inference_binary-0.5.44.dist-info/top_level.txt,sha256=FpOjtN80F-qVNgbScXSEyqa0w09FYn6301iq6qt69IQ,15
127
+ gllm_inference_binary-0.5.44.dist-info/RECORD,,