pixeltable 0.4.0rc2__py3-none-any.whl → 0.4.1__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.
Potentially problematic release.
This version of pixeltable might be problematic. Click here for more details.
- pixeltable/__init__.py +1 -1
- pixeltable/__version__.py +2 -2
- pixeltable/catalog/__init__.py +9 -1
- pixeltable/catalog/catalog.py +333 -99
- pixeltable/catalog/column.py +28 -26
- pixeltable/catalog/globals.py +12 -0
- pixeltable/catalog/insertable_table.py +8 -8
- pixeltable/catalog/schema_object.py +6 -0
- pixeltable/catalog/table.py +111 -116
- pixeltable/catalog/table_version.py +36 -50
- pixeltable/catalog/table_version_handle.py +4 -1
- pixeltable/catalog/table_version_path.py +28 -4
- pixeltable/catalog/view.py +10 -18
- pixeltable/config.py +4 -0
- pixeltable/dataframe.py +10 -9
- pixeltable/env.py +5 -11
- pixeltable/exceptions.py +6 -0
- pixeltable/exec/exec_node.py +2 -0
- pixeltable/exec/expr_eval/expr_eval_node.py +4 -4
- pixeltable/exec/sql_node.py +47 -30
- pixeltable/exprs/column_property_ref.py +2 -1
- pixeltable/exprs/column_ref.py +7 -6
- pixeltable/exprs/expr.py +4 -4
- pixeltable/func/__init__.py +1 -0
- pixeltable/func/mcp.py +74 -0
- pixeltable/func/query_template_function.py +4 -2
- pixeltable/func/tools.py +12 -2
- pixeltable/func/udf.py +2 -2
- pixeltable/functions/__init__.py +1 -0
- pixeltable/functions/anthropic.py +19 -45
- pixeltable/functions/deepseek.py +19 -38
- pixeltable/functions/fireworks.py +9 -18
- pixeltable/functions/gemini.py +2 -2
- pixeltable/functions/groq.py +108 -0
- pixeltable/functions/huggingface.py +8 -6
- pixeltable/functions/llama_cpp.py +6 -6
- pixeltable/functions/mistralai.py +16 -53
- pixeltable/functions/ollama.py +1 -1
- pixeltable/functions/openai.py +82 -170
- pixeltable/functions/replicate.py +2 -2
- pixeltable/functions/together.py +22 -80
- pixeltable/functions/util.py +6 -1
- pixeltable/globals.py +0 -2
- pixeltable/io/external_store.py +2 -2
- pixeltable/io/label_studio.py +4 -4
- pixeltable/io/table_data_conduit.py +1 -1
- pixeltable/metadata/__init__.py +1 -1
- pixeltable/metadata/converters/convert_37.py +15 -0
- pixeltable/metadata/notes.py +1 -0
- pixeltable/metadata/schema.py +5 -0
- pixeltable/plan.py +37 -121
- pixeltable/share/packager.py +2 -2
- pixeltable/type_system.py +30 -0
- {pixeltable-0.4.0rc2.dist-info → pixeltable-0.4.1.dist-info}/METADATA +1 -1
- {pixeltable-0.4.0rc2.dist-info → pixeltable-0.4.1.dist-info}/RECORD +58 -56
- pixeltable/utils/sample.py +0 -25
- {pixeltable-0.4.0rc2.dist-info → pixeltable-0.4.1.dist-info}/LICENSE +0 -0
- {pixeltable-0.4.0rc2.dist-info → pixeltable-0.4.1.dist-info}/WHEEL +0 -0
- {pixeltable-0.4.0rc2.dist-info → pixeltable-0.4.1.dist-info}/entry_points.txt +0 -0
|
@@ -51,7 +51,7 @@ def sentence_transformer(
|
|
|
51
51
|
"""
|
|
52
52
|
env.Env.get().require_package('sentence_transformers')
|
|
53
53
|
device = resolve_torch_device('auto')
|
|
54
|
-
from sentence_transformers import SentenceTransformer
|
|
54
|
+
from sentence_transformers import SentenceTransformer
|
|
55
55
|
|
|
56
56
|
# specifying the device, moves the model to device (gpu:cuda/mps, cpu)
|
|
57
57
|
model = _lookup_model(model_id, SentenceTransformer, device=device, pass_device_to_create=True)
|
|
@@ -170,7 +170,7 @@ def clip(text: Batch[str], *, model_id: str) -> Batch[pxt.Array[(None,), pxt.Flo
|
|
|
170
170
|
env.Env.get().require_package('transformers')
|
|
171
171
|
device = resolve_torch_device('auto')
|
|
172
172
|
import torch
|
|
173
|
-
from transformers import CLIPModel, CLIPProcessor
|
|
173
|
+
from transformers import CLIPModel, CLIPProcessor
|
|
174
174
|
|
|
175
175
|
model = _lookup_model(model_id, CLIPModel.from_pretrained, device=device)
|
|
176
176
|
processor = _lookup_processor(model_id, CLIPProcessor.from_pretrained)
|
|
@@ -395,19 +395,21 @@ def speech2text_for_conditional_generation(audio: pxt.Audio, *, model_id: str, l
|
|
|
395
395
|
device = resolve_torch_device('auto', allow_mps=False) # Doesn't seem to work on 'mps'; use 'cpu' instead
|
|
396
396
|
import torch
|
|
397
397
|
import torchaudio # type: ignore[import-untyped]
|
|
398
|
-
from transformers import Speech2TextForConditionalGeneration, Speech2TextProcessor
|
|
398
|
+
from transformers import Speech2TextForConditionalGeneration, Speech2TextProcessor, Speech2TextTokenizer
|
|
399
399
|
|
|
400
400
|
model = _lookup_model(model_id, Speech2TextForConditionalGeneration.from_pretrained, device=device)
|
|
401
401
|
processor = _lookup_processor(model_id, Speech2TextProcessor.from_pretrained)
|
|
402
|
+
tokenizer = processor.tokenizer
|
|
402
403
|
assert isinstance(processor, Speech2TextProcessor)
|
|
404
|
+
assert isinstance(tokenizer, Speech2TextTokenizer)
|
|
403
405
|
|
|
404
|
-
if language is not None and language not in
|
|
406
|
+
if language is not None and language not in tokenizer.lang_code_to_id:
|
|
405
407
|
raise excs.Error(
|
|
406
408
|
f"Language code '{language}' is not supported by the model '{model_id}'. "
|
|
407
|
-
f'Supported languages are: {list(
|
|
409
|
+
f'Supported languages are: {list(tokenizer.lang_code_to_id.keys())}'
|
|
408
410
|
)
|
|
409
411
|
|
|
410
|
-
forced_bos_token_id: Optional[int] = None if language is None else
|
|
412
|
+
forced_bos_token_id: Optional[int] = None if language is None else tokenizer.lang_code_to_id[language]
|
|
411
413
|
|
|
412
414
|
# Get the model's sampling rate. Default to 16 kHz (the standard) if not in config
|
|
413
415
|
model_sampling_rate = getattr(model.config, 'sampling_rate', 16_000)
|
|
@@ -17,7 +17,7 @@ def create_chat_completion(
|
|
|
17
17
|
model_path: Optional[str] = None,
|
|
18
18
|
repo_id: Optional[str] = None,
|
|
19
19
|
repo_filename: Optional[str] = None,
|
|
20
|
-
|
|
20
|
+
model_kwargs: Optional[dict[str, Any]] = None,
|
|
21
21
|
) -> dict:
|
|
22
22
|
"""
|
|
23
23
|
Generate a chat completion from a list of messages.
|
|
@@ -35,14 +35,14 @@ def create_chat_completion(
|
|
|
35
35
|
repo_id: The Hugging Face model repo id (if using a pretrained model).
|
|
36
36
|
repo_filename: A filename or glob pattern to match the model file in the repo (optional, if using a
|
|
37
37
|
pretrained model).
|
|
38
|
-
|
|
39
|
-
`top_p`, and `top_k`. For details, see the
|
|
38
|
+
model_kwargs: Additional keyword args for the llama_cpp `create_chat_completions` API, such as `max_tokens`,
|
|
39
|
+
`temperature`, `top_p`, and `top_k`. For details, see the
|
|
40
40
|
[llama_cpp create_chat_completions documentation](https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama.create_chat_completion).
|
|
41
41
|
"""
|
|
42
42
|
Env.get().require_package('llama_cpp', min_version=[0, 3, 1])
|
|
43
43
|
|
|
44
|
-
if
|
|
45
|
-
|
|
44
|
+
if model_kwargs is None:
|
|
45
|
+
model_kwargs = {}
|
|
46
46
|
|
|
47
47
|
if (model_path is None) == (repo_id is None):
|
|
48
48
|
raise excs.Error('Exactly one of `model_path` or `repo_id` must be provided.')
|
|
@@ -56,7 +56,7 @@ def create_chat_completion(
|
|
|
56
56
|
else:
|
|
57
57
|
Env.get().require_package('huggingface_hub')
|
|
58
58
|
llm = _lookup_pretrained_model(repo_id, repo_filename, n_gpu_layers)
|
|
59
|
-
return llm.create_chat_completion(messages, **
|
|
59
|
+
return llm.create_chat_completion(messages, **model_kwargs) # type: ignore
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def _is_gpu_available() -> bool:
|
|
@@ -5,7 +5,7 @@ first `pip install mistralai` and configure your Mistral AI credentials, as desc
|
|
|
5
5
|
the [Working with Mistral AI](https://pixeltable.readme.io/docs/working-with-mistralai) tutorial.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import TYPE_CHECKING,
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Optional
|
|
9
9
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ from pixeltable.func.signature import Batch
|
|
|
16
16
|
from pixeltable.utils.code import local_public_names
|
|
17
17
|
|
|
18
18
|
if TYPE_CHECKING:
|
|
19
|
-
import mistralai
|
|
19
|
+
import mistralai
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@register_client('mistral')
|
|
@@ -32,16 +32,7 @@ def _mistralai_client() -> 'mistralai.Mistral':
|
|
|
32
32
|
|
|
33
33
|
@pxt.udf(resource_pool='request-rate:mistral')
|
|
34
34
|
async def chat_completions(
|
|
35
|
-
messages: list[dict[str, str]],
|
|
36
|
-
*,
|
|
37
|
-
model: str,
|
|
38
|
-
temperature: Optional[float] = 0.7,
|
|
39
|
-
top_p: Optional[float] = 1.0,
|
|
40
|
-
max_tokens: Optional[int] = None,
|
|
41
|
-
stop: Optional[list[str]] = None,
|
|
42
|
-
random_seed: Optional[int] = None,
|
|
43
|
-
response_format: Optional[dict] = None,
|
|
44
|
-
safe_prompt: Optional[bool] = False,
|
|
35
|
+
messages: list[dict[str, str]], *, model: str, model_kwargs: Optional[dict[str, Any]] = None
|
|
45
36
|
) -> dict:
|
|
46
37
|
"""
|
|
47
38
|
Chat Completion API.
|
|
@@ -60,8 +51,8 @@ async def chat_completions(
|
|
|
60
51
|
Args:
|
|
61
52
|
messages: The prompt(s) to generate completions for.
|
|
62
53
|
model: ID of the model to use. (See overview here: <https://docs.mistral.ai/getting-started/models/>)
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
model_kwargs: Additional keyword args for the Mistral `chat/completions` API.
|
|
55
|
+
For details on the available parameters, see: <https://docs.mistral.ai/api/#tag/chat>
|
|
65
56
|
|
|
66
57
|
Returns:
|
|
67
58
|
A dictionary containing the response and other metadata.
|
|
@@ -73,34 +64,20 @@ async def chat_completions(
|
|
|
73
64
|
>>> messages = [{'role': 'user', 'content': tbl.prompt}]
|
|
74
65
|
... tbl.add_computed_column(response=completions(messages, model='mistral-latest-small'))
|
|
75
66
|
"""
|
|
67
|
+
if model_kwargs is None:
|
|
68
|
+
model_kwargs = {}
|
|
69
|
+
|
|
76
70
|
Env.get().require_package('mistralai')
|
|
77
71
|
result = await _mistralai_client().chat.complete_async(
|
|
78
72
|
messages=messages, # type: ignore[arg-type]
|
|
79
73
|
model=model,
|
|
80
|
-
|
|
81
|
-
top_p=top_p,
|
|
82
|
-
max_tokens=_opt(max_tokens),
|
|
83
|
-
stop=stop,
|
|
84
|
-
random_seed=_opt(random_seed),
|
|
85
|
-
response_format=response_format, # type: ignore[arg-type]
|
|
86
|
-
safe_prompt=safe_prompt,
|
|
74
|
+
**model_kwargs,
|
|
87
75
|
)
|
|
88
76
|
return result.dict()
|
|
89
77
|
|
|
90
78
|
|
|
91
79
|
@pxt.udf(resource_pool='request-rate:mistral')
|
|
92
|
-
async def fim_completions(
|
|
93
|
-
prompt: str,
|
|
94
|
-
*,
|
|
95
|
-
model: str,
|
|
96
|
-
temperature: Optional[float] = 0.7,
|
|
97
|
-
top_p: Optional[float] = 1.0,
|
|
98
|
-
max_tokens: Optional[int] = None,
|
|
99
|
-
min_tokens: Optional[int] = None,
|
|
100
|
-
stop: Optional[list[str]] = None,
|
|
101
|
-
random_seed: Optional[int] = None,
|
|
102
|
-
suffix: Optional[str] = None,
|
|
103
|
-
) -> dict:
|
|
80
|
+
async def fim_completions(prompt: str, *, model: str, model_kwargs: Optional[dict[str, Any]] = None) -> dict:
|
|
104
81
|
"""
|
|
105
82
|
Fill-in-the-middle Completion API.
|
|
106
83
|
|
|
@@ -118,6 +95,8 @@ async def fim_completions(
|
|
|
118
95
|
Args:
|
|
119
96
|
prompt: The text/code to complete.
|
|
120
97
|
model: ID of the model to use. (See overview here: <https://docs.mistral.ai/getting-started/models/>)
|
|
98
|
+
model_kwargs: Additional keyword args for the Mistral `fim/completions` API.
|
|
99
|
+
For details on the available parameters, see: <https://docs.mistral.ai/api/#tag/fim>
|
|
121
100
|
|
|
122
101
|
For details on the other parameters, see: <https://docs.mistral.ai/api/#tag/fim>
|
|
123
102
|
|
|
@@ -130,18 +109,11 @@ async def fim_completions(
|
|
|
130
109
|
|
|
131
110
|
>>> tbl.add_computed_column(response=completions(tbl.prompt, model='codestral-latest'))
|
|
132
111
|
"""
|
|
112
|
+
if model_kwargs is None:
|
|
113
|
+
model_kwargs = {}
|
|
114
|
+
|
|
133
115
|
Env.get().require_package('mistralai')
|
|
134
|
-
result = await _mistralai_client().fim.complete_async(
|
|
135
|
-
prompt=prompt,
|
|
136
|
-
model=model,
|
|
137
|
-
temperature=temperature,
|
|
138
|
-
top_p=top_p,
|
|
139
|
-
max_tokens=_opt(max_tokens),
|
|
140
|
-
min_tokens=_opt(min_tokens),
|
|
141
|
-
stop=stop,
|
|
142
|
-
random_seed=_opt(random_seed),
|
|
143
|
-
suffix=_opt(suffix),
|
|
144
|
-
)
|
|
116
|
+
result = await _mistralai_client().fim.complete_async(prompt=prompt, model=model, **model_kwargs)
|
|
145
117
|
return result.dict()
|
|
146
118
|
|
|
147
119
|
|
|
@@ -182,15 +154,6 @@ def _(model: str) -> ts.ArrayType:
|
|
|
182
154
|
return ts.ArrayType((dimensions,), dtype=ts.FloatType())
|
|
183
155
|
|
|
184
156
|
|
|
185
|
-
_T = TypeVar('_T')
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
def _opt(arg: Optional[_T]) -> Union[_T, 'mistralai.types.basemodel.Unset']:
|
|
189
|
-
from mistralai.types import UNSET
|
|
190
|
-
|
|
191
|
-
return arg if arg is not None else UNSET
|
|
192
|
-
|
|
193
|
-
|
|
194
157
|
__all__ = local_public_names(__name__)
|
|
195
158
|
|
|
196
159
|
|
pixeltable/functions/ollama.py
CHANGED
|
@@ -50,7 +50,7 @@ def generate(
|
|
|
50
50
|
template: Prompt template to use.
|
|
51
51
|
context: The context parameter returned from a previous call to `generate()`.
|
|
52
52
|
raw: If `True`, no formatting will be applied to the prompt.
|
|
53
|
-
options: Additional options
|
|
53
|
+
options: Additional options for the Ollama `chat` call, such as `max_tokens`, `temperature`, `top_p`, and
|
|
54
54
|
`top_k`. For details, see the
|
|
55
55
|
[Valid Parameters and Values](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)
|
|
56
56
|
section of the Ollama documentation.
|