blaxel 0.1.9rc35__py3-none-any.whl → 0.1.9rc36__py3-none-any.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.
- blaxel/agents/__init__.py +1 -1
- blaxel/authentication/__init__.py +3 -4
- blaxel/client/api/compute/__init__.py +0 -0
- blaxel/client/api/compute/create_sandbox.py +166 -0
- blaxel/client/api/compute/delete_sandbox.py +154 -0
- blaxel/client/api/compute/get_sandbox.py +154 -0
- blaxel/client/api/compute/list_sandboxes.py +135 -0
- blaxel/client/api/compute/start_sandbox.py +157 -0
- blaxel/client/api/compute/stop_sandbox.py +157 -0
- blaxel/client/api/compute/update_sandbox.py +179 -0
- blaxel/client/api/default/list_sandbox_hub_definitions.py +123 -0
- blaxel/client/api/functions/list_function_revisions.py +16 -11
- blaxel/client/api/knowledgebases/list_knowledgebase_revisions.py +16 -11
- blaxel/client/api/models/list_model_revisions.py +16 -11
- blaxel/client/api/templates/list_templates.py +16 -11
- blaxel/client/models/__init__.py +32 -2
- blaxel/client/models/agent_spec.py +25 -69
- blaxel/client/models/core_spec.py +1 -45
- blaxel/client/models/function_spec.py +1 -45
- blaxel/client/models/last_n_requests_metric.py +18 -0
- blaxel/client/models/metrics.py +20 -0
- blaxel/client/models/model_spec.py +1 -45
- blaxel/client/models/{agent_chain.py → port.py} +23 -32
- blaxel/client/models/request_total_metric.py +12 -1
- blaxel/client/models/request_total_response_data.py +97 -0
- blaxel/client/models/resource_log.py +9 -0
- blaxel/client/models/resource_metrics.py +144 -0
- blaxel/client/models/resource_metrics_request_total_per_code_previous.py +45 -0
- blaxel/client/models/resource_metrics_rps_per_code_previous.py +45 -0
- blaxel/client/models/runtime.py +83 -7
- blaxel/client/models/runtime_configuration.py +45 -0
- blaxel/client/models/sandbox.py +129 -0
- blaxel/client/models/sandbox_definition.py +181 -0
- blaxel/client/models/sandbox_spec.py +208 -0
- blaxel/client/models/sandboxes.py +129 -0
- blaxel/client/models/serverless_config.py +29 -1
- blaxel/client/models/serverless_config_configuration.py +45 -0
- blaxel/client/models/start_sandbox.py +94 -0
- blaxel/client/models/stop_sandbox.py +94 -0
- blaxel/client/models/trigger.py +98 -0
- blaxel/client/models/trigger_configuration.py +45 -0
- blaxel/client/models/workspace.py +20 -0
- blaxel/client/models/workspace_runtime.py +61 -0
- blaxel/common/autoload.py +0 -1
- blaxel/instrumentation/exporters.py +3 -6
- blaxel/instrumentation/manager.py +5 -3
- blaxel/mcp/client.py +1 -3
- blaxel/mcp/server.py +2 -3
- blaxel/models/__init__.py +2 -1
- blaxel/models/custom/langchain/gemini.py +41 -18
- blaxel/models/custom/llamaindex/cohere.py +25 -16
- blaxel/models/custom/pydantic/gemini.py +0 -1
- blaxel/models/livekit.py +1 -1
- blaxel/tools/__init__.py +1 -1
- blaxel/tools/langchain.py +1 -2
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/METADATA +1 -4
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/RECORD +59 -36
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/WHEEL +0 -0
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc36.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from ..models.trigger_configuration import TriggerConfiguration
|
10
|
+
|
11
|
+
|
12
|
+
T = TypeVar("T", bound="Trigger")
|
13
|
+
|
14
|
+
|
15
|
+
@_attrs_define
|
16
|
+
class Trigger:
|
17
|
+
"""Trigger configuration
|
18
|
+
|
19
|
+
Attributes:
|
20
|
+
configuration (Union[Unset, TriggerConfiguration]): The configuration of the trigger
|
21
|
+
id (Union[Unset, str]): The id of the trigger
|
22
|
+
type_ (Union[Unset, str]): The type of trigger, can be http or http-async
|
23
|
+
"""
|
24
|
+
|
25
|
+
configuration: Union[Unset, "TriggerConfiguration"] = UNSET
|
26
|
+
id: Union[Unset, str] = UNSET
|
27
|
+
type_: Union[Unset, str] = UNSET
|
28
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
29
|
+
|
30
|
+
def to_dict(self) -> dict[str, Any]:
|
31
|
+
configuration: Union[Unset, dict[str, Any]] = UNSET
|
32
|
+
if (
|
33
|
+
self.configuration
|
34
|
+
and not isinstance(self.configuration, Unset)
|
35
|
+
and not isinstance(self.configuration, dict)
|
36
|
+
):
|
37
|
+
configuration = self.configuration.to_dict()
|
38
|
+
elif self.configuration and isinstance(self.configuration, dict):
|
39
|
+
configuration = self.configuration
|
40
|
+
|
41
|
+
id = self.id
|
42
|
+
|
43
|
+
type_ = self.type_
|
44
|
+
|
45
|
+
field_dict: dict[str, Any] = {}
|
46
|
+
field_dict.update(self.additional_properties)
|
47
|
+
field_dict.update({})
|
48
|
+
if configuration is not UNSET:
|
49
|
+
field_dict["configuration"] = configuration
|
50
|
+
if id is not UNSET:
|
51
|
+
field_dict["id"] = id
|
52
|
+
if type_ is not UNSET:
|
53
|
+
field_dict["type"] = type_
|
54
|
+
|
55
|
+
return field_dict
|
56
|
+
|
57
|
+
@classmethod
|
58
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
59
|
+
from ..models.trigger_configuration import TriggerConfiguration
|
60
|
+
|
61
|
+
if not src_dict:
|
62
|
+
return None
|
63
|
+
d = src_dict.copy()
|
64
|
+
_configuration = d.pop("configuration", UNSET)
|
65
|
+
configuration: Union[Unset, TriggerConfiguration]
|
66
|
+
if isinstance(_configuration, Unset):
|
67
|
+
configuration = UNSET
|
68
|
+
else:
|
69
|
+
configuration = TriggerConfiguration.from_dict(_configuration)
|
70
|
+
|
71
|
+
id = d.pop("id", UNSET)
|
72
|
+
|
73
|
+
type_ = d.pop("type", UNSET)
|
74
|
+
|
75
|
+
trigger = cls(
|
76
|
+
configuration=configuration,
|
77
|
+
id=id,
|
78
|
+
type_=type_,
|
79
|
+
)
|
80
|
+
|
81
|
+
trigger.additional_properties = d
|
82
|
+
return trigger
|
83
|
+
|
84
|
+
@property
|
85
|
+
def additional_keys(self) -> list[str]:
|
86
|
+
return list(self.additional_properties.keys())
|
87
|
+
|
88
|
+
def __getitem__(self, key: str) -> Any:
|
89
|
+
return self.additional_properties[key]
|
90
|
+
|
91
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
92
|
+
self.additional_properties[key] = value
|
93
|
+
|
94
|
+
def __delitem__(self, key: str) -> None:
|
95
|
+
del self.additional_properties[key]
|
96
|
+
|
97
|
+
def __contains__(self, key: str) -> bool:
|
98
|
+
return key in self.additional_properties
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from typing import Any, TypeVar
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
T = TypeVar("T", bound="TriggerConfiguration")
|
7
|
+
|
8
|
+
|
9
|
+
@_attrs_define
|
10
|
+
class TriggerConfiguration:
|
11
|
+
"""The configuration of the trigger"""
|
12
|
+
|
13
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
14
|
+
|
15
|
+
def to_dict(self) -> dict[str, Any]:
|
16
|
+
field_dict: dict[str, Any] = {}
|
17
|
+
field_dict.update(self.additional_properties)
|
18
|
+
|
19
|
+
return field_dict
|
20
|
+
|
21
|
+
@classmethod
|
22
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
23
|
+
if not src_dict:
|
24
|
+
return None
|
25
|
+
d = src_dict.copy()
|
26
|
+
trigger_configuration = cls()
|
27
|
+
|
28
|
+
trigger_configuration.additional_properties = d
|
29
|
+
return trigger_configuration
|
30
|
+
|
31
|
+
@property
|
32
|
+
def additional_keys(self) -> list[str]:
|
33
|
+
return list(self.additional_properties.keys())
|
34
|
+
|
35
|
+
def __getitem__(self, key: str) -> Any:
|
36
|
+
return self.additional_properties[key]
|
37
|
+
|
38
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
39
|
+
self.additional_properties[key] = value
|
40
|
+
|
41
|
+
def __delitem__(self, key: str) -> None:
|
42
|
+
del self.additional_properties[key]
|
43
|
+
|
44
|
+
def __contains__(self, key: str) -> bool:
|
45
|
+
return key in self.additional_properties
|
@@ -7,6 +7,7 @@ from ..types import UNSET, Unset
|
|
7
7
|
|
8
8
|
if TYPE_CHECKING:
|
9
9
|
from ..models.workspace_labels import WorkspaceLabels
|
10
|
+
from ..models.workspace_runtime import WorkspaceRuntime
|
10
11
|
|
11
12
|
|
12
13
|
T = TypeVar("T", bound="Workspace")
|
@@ -26,6 +27,7 @@ class Workspace:
|
|
26
27
|
labels (Union[Unset, WorkspaceLabels]): Workspace labels
|
27
28
|
name (Union[Unset, str]): Workspace name
|
28
29
|
region (Union[Unset, str]): Workspace write region
|
30
|
+
runtime (Union[Unset, WorkspaceRuntime]): Workspace runtime
|
29
31
|
"""
|
30
32
|
|
31
33
|
created_at: Union[Unset, str] = UNSET
|
@@ -37,6 +39,7 @@ class Workspace:
|
|
37
39
|
labels: Union[Unset, "WorkspaceLabels"] = UNSET
|
38
40
|
name: Union[Unset, str] = UNSET
|
39
41
|
region: Union[Unset, str] = UNSET
|
42
|
+
runtime: Union[Unset, "WorkspaceRuntime"] = UNSET
|
40
43
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
41
44
|
|
42
45
|
def to_dict(self) -> dict[str, Any]:
|
@@ -62,6 +65,12 @@ class Workspace:
|
|
62
65
|
|
63
66
|
region = self.region
|
64
67
|
|
68
|
+
runtime: Union[Unset, dict[str, Any]] = UNSET
|
69
|
+
if self.runtime and not isinstance(self.runtime, Unset) and not isinstance(self.runtime, dict):
|
70
|
+
runtime = self.runtime.to_dict()
|
71
|
+
elif self.runtime and isinstance(self.runtime, dict):
|
72
|
+
runtime = self.runtime
|
73
|
+
|
65
74
|
field_dict: dict[str, Any] = {}
|
66
75
|
field_dict.update(self.additional_properties)
|
67
76
|
field_dict.update({})
|
@@ -83,12 +92,15 @@ class Workspace:
|
|
83
92
|
field_dict["name"] = name
|
84
93
|
if region is not UNSET:
|
85
94
|
field_dict["region"] = region
|
95
|
+
if runtime is not UNSET:
|
96
|
+
field_dict["runtime"] = runtime
|
86
97
|
|
87
98
|
return field_dict
|
88
99
|
|
89
100
|
@classmethod
|
90
101
|
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
91
102
|
from ..models.workspace_labels import WorkspaceLabels
|
103
|
+
from ..models.workspace_runtime import WorkspaceRuntime
|
92
104
|
|
93
105
|
if not src_dict:
|
94
106
|
return None
|
@@ -116,6 +128,13 @@ class Workspace:
|
|
116
128
|
|
117
129
|
region = d.pop("region", UNSET)
|
118
130
|
|
131
|
+
_runtime = d.pop("runtime", UNSET)
|
132
|
+
runtime: Union[Unset, WorkspaceRuntime]
|
133
|
+
if isinstance(_runtime, Unset):
|
134
|
+
runtime = UNSET
|
135
|
+
else:
|
136
|
+
runtime = WorkspaceRuntime.from_dict(_runtime)
|
137
|
+
|
119
138
|
workspace = cls(
|
120
139
|
created_at=created_at,
|
121
140
|
updated_at=updated_at,
|
@@ -126,6 +145,7 @@ class Workspace:
|
|
126
145
|
labels=labels,
|
127
146
|
name=name,
|
128
147
|
region=region,
|
148
|
+
runtime=runtime,
|
129
149
|
)
|
130
150
|
|
131
151
|
workspace.additional_properties = d
|
@@ -0,0 +1,61 @@
|
|
1
|
+
from typing import Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
T = TypeVar("T", bound="WorkspaceRuntime")
|
9
|
+
|
10
|
+
|
11
|
+
@_attrs_define
|
12
|
+
class WorkspaceRuntime:
|
13
|
+
"""Workspace runtime
|
14
|
+
|
15
|
+
Attributes:
|
16
|
+
generation (Union[Unset, str]): Workspace generation
|
17
|
+
"""
|
18
|
+
|
19
|
+
generation: Union[Unset, str] = UNSET
|
20
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
21
|
+
|
22
|
+
def to_dict(self) -> dict[str, Any]:
|
23
|
+
generation = self.generation
|
24
|
+
|
25
|
+
field_dict: dict[str, Any] = {}
|
26
|
+
field_dict.update(self.additional_properties)
|
27
|
+
field_dict.update({})
|
28
|
+
if generation is not UNSET:
|
29
|
+
field_dict["generation"] = generation
|
30
|
+
|
31
|
+
return field_dict
|
32
|
+
|
33
|
+
@classmethod
|
34
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
35
|
+
if not src_dict:
|
36
|
+
return None
|
37
|
+
d = src_dict.copy()
|
38
|
+
generation = d.pop("generation", UNSET)
|
39
|
+
|
40
|
+
workspace_runtime = cls(
|
41
|
+
generation=generation,
|
42
|
+
)
|
43
|
+
|
44
|
+
workspace_runtime.additional_properties = d
|
45
|
+
return workspace_runtime
|
46
|
+
|
47
|
+
@property
|
48
|
+
def additional_keys(self) -> list[str]:
|
49
|
+
return list(self.additional_properties.keys())
|
50
|
+
|
51
|
+
def __getitem__(self, key: str) -> Any:
|
52
|
+
return self.additional_properties[key]
|
53
|
+
|
54
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
55
|
+
self.additional_properties[key] = value
|
56
|
+
|
57
|
+
def __delitem__(self, key: str) -> None:
|
58
|
+
del self.additional_properties[key]
|
59
|
+
|
60
|
+
def __contains__(self, key: str) -> bool:
|
61
|
+
return key in self.additional_properties
|
blaxel/common/autoload.py
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
from typing import Callable, Dict, Sequence
|
2
2
|
|
3
|
-
from opentelemetry.exporter.otlp.proto.http._log_exporter import
|
4
|
-
|
5
|
-
from opentelemetry.exporter.otlp.proto.http.
|
6
|
-
OTLPMetricExporter
|
7
|
-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import \
|
8
|
-
OTLPSpanExporter
|
3
|
+
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
|
4
|
+
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
|
5
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
9
6
|
from opentelemetry.sdk._logs import LogData
|
10
7
|
from opentelemetry.sdk.metrics.export import MetricExportResult, MetricsData
|
11
8
|
|
@@ -20,9 +20,11 @@ from opentelemetry.sdk.trace import TracerProvider
|
|
20
20
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
21
21
|
from opentelemetry.trace import NoOpTracerProvider
|
22
22
|
|
23
|
-
from blaxel.instrumentation.exporters import (
|
24
|
-
|
25
|
-
|
23
|
+
from blaxel.instrumentation.exporters import (
|
24
|
+
DynamicHeadersLogExporter,
|
25
|
+
DynamicHeadersMetricExporter,
|
26
|
+
DynamicHeadersSpanExporter,
|
27
|
+
)
|
26
28
|
from blaxel.instrumentation.span import DefaultAttributesSpanProcessor
|
27
29
|
|
28
30
|
from ..common.settings import Settings
|
blaxel/mcp/client.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import logging
|
2
|
-
import os
|
3
2
|
from contextlib import asynccontextmanager
|
4
3
|
from typing import Any
|
5
4
|
from urllib.parse import urljoin, urlparse
|
@@ -7,8 +6,7 @@ from urllib.parse import urljoin, urlparse
|
|
7
6
|
import anyio
|
8
7
|
import mcp.types as types
|
9
8
|
from anyio.abc import TaskStatus
|
10
|
-
from anyio.streams.memory import
|
11
|
-
MemoryObjectSendStream)
|
9
|
+
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
12
10
|
from websockets.client import WebSocketClientProtocol
|
13
11
|
from websockets.client import connect as ws_connect
|
14
12
|
|
blaxel/mcp/server.py
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
import logging
|
2
|
+
import traceback
|
2
3
|
import uuid
|
3
4
|
from contextlib import asynccontextmanager
|
4
5
|
from typing import Dict, Literal
|
5
6
|
|
6
7
|
import anyio
|
7
8
|
import mcp.types as types
|
8
|
-
from anyio.streams.memory import
|
9
|
-
MemoryObjectSendStream)
|
9
|
+
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
10
10
|
from mcp.server.fastmcp import FastMCP as FastMCPBase
|
11
11
|
from opentelemetry.trace import Span, StatusCode
|
12
12
|
from websockets.server import WebSocketServerProtocol, serve
|
13
13
|
|
14
14
|
from ..common.env import env
|
15
15
|
from ..instrumentation.span import SpanManager
|
16
|
-
import traceback
|
17
16
|
|
18
17
|
logger = logging.getLogger(__name__)
|
19
18
|
|
blaxel/models/__init__.py
CHANGED
@@ -4,6 +4,7 @@ from ..client import client
|
|
4
4
|
from ..client.api.models import get_model
|
5
5
|
from ..client.models import Model
|
6
6
|
from ..common.settings import settings
|
7
|
+
|
7
8
|
# This has to be here because livekit plugins must be registered on the main thread
|
8
9
|
from .livekit import get_livekit_model
|
9
10
|
|
@@ -94,7 +95,7 @@ class BLModel:
|
|
94
95
|
|
95
96
|
try:
|
96
97
|
return await get_model.asyncio(client=client, model_name=self.model_name)
|
97
|
-
except Exception
|
98
|
+
except Exception:
|
98
99
|
return None
|
99
100
|
|
100
101
|
def bl_model(model_name, **kwargs):
|
@@ -6,33 +6,56 @@ import logging
|
|
6
6
|
import uuid
|
7
7
|
import warnings
|
8
8
|
from operator import itemgetter
|
9
|
-
from typing import (
|
10
|
-
|
9
|
+
from typing import (
|
10
|
+
Any,
|
11
|
+
AsyncIterator,
|
12
|
+
Callable,
|
13
|
+
Dict,
|
14
|
+
Iterator,
|
15
|
+
List,
|
16
|
+
Mapping,
|
17
|
+
Optional,
|
18
|
+
Sequence,
|
19
|
+
Tuple,
|
20
|
+
Type,
|
21
|
+
Union,
|
22
|
+
cast,
|
23
|
+
)
|
11
24
|
|
12
25
|
import httpx
|
13
26
|
import requests
|
14
|
-
from langchain_core.callbacks.manager import
|
15
|
-
CallbackManagerForLLMRun)
|
27
|
+
from langchain_core.callbacks.manager import AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun
|
16
28
|
from langchain_core.language_models import LanguageModelInput
|
17
|
-
from langchain_core.language_models.chat_models import
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
29
|
+
from langchain_core.language_models.chat_models import BaseChatModel, LangSmithParams
|
30
|
+
from langchain_core.messages import (
|
31
|
+
AIMessage,
|
32
|
+
AIMessageChunk,
|
33
|
+
BaseMessage,
|
34
|
+
FunctionMessage,
|
35
|
+
HumanMessage,
|
36
|
+
SystemMessage,
|
37
|
+
ToolMessage,
|
38
|
+
)
|
22
39
|
from langchain_core.messages.ai import UsageMetadata
|
23
|
-
from langchain_core.messages.tool import
|
24
|
-
tool_call_chunk)
|
40
|
+
from langchain_core.messages.tool import invalid_tool_call, tool_call, tool_call_chunk
|
25
41
|
from langchain_core.output_parsers.openai_tools import (
|
26
|
-
JsonOutputKeyToolsParser,
|
27
|
-
|
28
|
-
|
42
|
+
JsonOutputKeyToolsParser,
|
43
|
+
PydanticToolsParser,
|
44
|
+
parse_tool_calls,
|
45
|
+
)
|
46
|
+
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
|
29
47
|
from langchain_core.runnables import Runnable, RunnablePassthrough
|
30
48
|
from langchain_core.tools import BaseTool
|
31
49
|
from langchain_core.utils.function_calling import convert_to_openai_tool
|
32
50
|
from PIL import Image
|
33
51
|
from pydantic import BaseModel, ConfigDict, Field, SecretStr, model_validator
|
34
|
-
from tenacity import (
|
35
|
-
|
52
|
+
from tenacity import (
|
53
|
+
before_sleep_log,
|
54
|
+
retry,
|
55
|
+
retry_if_exception_type,
|
56
|
+
stop_after_attempt,
|
57
|
+
wait_exponential,
|
58
|
+
)
|
36
59
|
from typing_extensions import Self, is_typeddict
|
37
60
|
|
38
61
|
WARNED_STRUCTURED_OUTPUT_JSON_MODE = False
|
@@ -189,7 +212,7 @@ def _chat_with_retry(generation_method: Callable, **kwargs: Any) -> Any:
|
|
189
212
|
try:
|
190
213
|
# Extract request parameters and other kwargs
|
191
214
|
request = kwargs.pop('request', {})
|
192
|
-
|
215
|
+
kwargs.pop('metadata', None)
|
193
216
|
|
194
217
|
# Unpack request parameters into kwargs
|
195
218
|
kwargs.update(request)
|
@@ -238,7 +261,7 @@ async def _achat_with_retry(generation_method: Callable, **kwargs: Any) -> Any:
|
|
238
261
|
try:
|
239
262
|
# Extract request parameters and other kwargs
|
240
263
|
request = kwargs.pop('request', {})
|
241
|
-
|
264
|
+
kwargs.pop('metadata', None)
|
242
265
|
|
243
266
|
# Unpack request parameters into kwargs
|
244
267
|
kwargs.update(request)
|
@@ -4,27 +4,36 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Union
|
|
4
4
|
|
5
5
|
import cohere
|
6
6
|
from cohere.types import ToolCall
|
7
|
-
from llama_index.core.base.llms.types import (
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
from llama_index.core.base.llms.types import (
|
8
|
+
ChatMessage,
|
9
|
+
ChatResponse,
|
10
|
+
ChatResponseAsyncGen,
|
11
|
+
ChatResponseGen,
|
12
|
+
CompletionResponse,
|
13
|
+
CompletionResponseAsyncGen,
|
14
|
+
CompletionResponseGen,
|
15
|
+
LLMMetadata,
|
16
|
+
MessageRole,
|
17
|
+
)
|
14
18
|
from llama_index.core.bridge.pydantic import Field, PrivateAttr
|
15
19
|
from llama_index.core.callbacks import CallbackManager
|
16
|
-
from llama_index.core.llms.callbacks import
|
17
|
-
llm_completion_callback)
|
20
|
+
from llama_index.core.llms.callbacks import llm_chat_callback, llm_completion_callback
|
18
21
|
from llama_index.core.llms.function_calling import FunctionCallingLLM
|
19
22
|
from llama_index.core.llms.llm import ToolSelection
|
20
23
|
from llama_index.core.tools.types import BaseTool
|
21
24
|
from llama_index.core.types import BaseOutputParser, PydanticProgramMode
|
22
25
|
from llama_index.llms.cohere.utils import (
|
23
|
-
CHAT_MODELS,
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
CHAT_MODELS,
|
27
|
+
_get_message_cohere_format,
|
28
|
+
_message_to_cohere_tool_results,
|
29
|
+
_messages_to_cohere_tool_results_curr_chat_turn,
|
30
|
+
acompletion_with_retry,
|
31
|
+
cohere_modelname_to_contextsize,
|
32
|
+
completion_with_retry,
|
33
|
+
format_to_cohere_tools,
|
34
|
+
is_cohere_function_calling_model,
|
35
|
+
remove_documents_from_messages,
|
36
|
+
)
|
28
37
|
|
29
38
|
|
30
39
|
class Cohere(FunctionCallingLLM):
|
@@ -200,9 +209,9 @@ class Cohere(FunctionCallingLLM):
|
|
200
209
|
The request for the Cohere chat API.
|
201
210
|
"""
|
202
211
|
additional_kwargs = messages[-1].additional_kwargs
|
203
|
-
|
212
|
+
documents = additional_kwargs.pop("documents", [])
|
204
213
|
# cohere SDK will fail loudly if both connectors and documents are provided
|
205
|
-
if
|
214
|
+
if documents and len(documents) > 0:
|
206
215
|
raise ValueError(
|
207
216
|
"Received documents both as a keyword argument and as an prompt additional keyword argument. Please choose only one option."
|
208
217
|
)
|
blaxel/models/livekit.py
CHANGED
blaxel/tools/__init__.py
CHANGED
@@ -126,7 +126,7 @@ def convert_mcp_tool_to_blaxel_tool(
|
|
126
126
|
"tool.server": url,
|
127
127
|
"tool.server_name": name,
|
128
128
|
}
|
129
|
-
with SpanManager("blaxel-tracer").create_active_span("blaxel-tool-call", span_attributes)
|
129
|
+
with SpanManager("blaxel-tracer").create_active_span("blaxel-tool-call", span_attributes):
|
130
130
|
logger.debug(f"Calling tool {tool.name} with arguments {arguments}")
|
131
131
|
call_tool_result = await websocket_client.call_tool(tool.name, arguments)
|
132
132
|
logger.debug(f"Tool {tool.name} returned {call_tool_result}")
|
blaxel/tools/langchain.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
from typing import Any
|
2
2
|
|
3
3
|
from langchain_core.tools import StructuredTool
|
4
|
-
from mcp.types import
|
5
|
-
TextContent)
|
4
|
+
from mcp.types import CallToolResult, EmbeddedResource, ImageContent, TextContent
|
6
5
|
|
7
6
|
from .types import Tool, ToolException
|
8
7
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: blaxel
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.9rc36
|
4
4
|
Summary: Add your description here
|
5
5
|
Author-email: cploujoux <cploujoux@blaxel.ai>
|
6
6
|
License-File: LICENSE
|
@@ -25,9 +25,6 @@ Requires-Dist: pyyaml<6.1.0,>=6.0.2
|
|
25
25
|
Requires-Dist: requests<2.33.0,>=2.32.3
|
26
26
|
Requires-Dist: tomli>=2.2.1
|
27
27
|
Requires-Dist: websockets<15.0.0
|
28
|
-
Provides-Extra: crewai
|
29
|
-
Requires-Dist: crewai>=0.102.0; extra == 'crewai'
|
30
|
-
Requires-Dist: opentelemetry-instrumentation-crewai>=0.39.0; extra == 'crewai'
|
31
28
|
Provides-Extra: google-adk
|
32
29
|
Requires-Dist: google-adk>=0.2.0; extra == 'google-adk'
|
33
30
|
Requires-Dist: litellm>=1.63.11; extra == 'google-adk'
|