pixeltable 0.2.16__py3-none-any.whl → 0.2.17__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/__version__.py +2 -2
- pixeltable/env.py +1 -0
- pixeltable/functions/__init__.py +1 -1
- pixeltable/functions/anthropic.py +97 -0
- pixeltable/functions/fireworks.py +1 -1
- pixeltable/functions/together.py +1 -1
- {pixeltable-0.2.16.dist-info → pixeltable-0.2.17.dist-info}/METADATA +1 -1
- {pixeltable-0.2.16.dist-info → pixeltable-0.2.17.dist-info}/RECORD +11 -10
- {pixeltable-0.2.16.dist-info → pixeltable-0.2.17.dist-info}/LICENSE +0 -0
- {pixeltable-0.2.16.dist-info → pixeltable-0.2.17.dist-info}/WHEEL +0 -0
- {pixeltable-0.2.16.dist-info → pixeltable-0.2.17.dist-info}/entry_points.txt +0 -0
pixeltable/__version__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# These version placeholders will be replaced during build.
|
|
2
|
-
__version__ = "0.2.
|
|
3
|
-
__version_tuple__ = (0, 2,
|
|
2
|
+
__version__ = "0.2.17"
|
|
3
|
+
__version_tuple__ = (0, 2, 17)
|
pixeltable/env.py
CHANGED
pixeltable/functions/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from . import audio, fireworks, huggingface, image, json, openai, string, timestamp, together, video, vision
|
|
1
|
+
from . import anthropic, audio, fireworks, huggingface, image, json, openai, string, timestamp, together, video, vision
|
|
2
2
|
from .globals import *
|
|
3
3
|
from pixeltable.utils.code import local_public_names
|
|
4
4
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pixeltable [UDFs](https://pixeltable.readme.io/docs/user-defined-functions-udfs)
|
|
3
|
+
that wrap various endpoints from the Anthropic API. In order to use them, you must
|
|
4
|
+
first `pip install anthropic` and configure your Anthropic credentials, as described in
|
|
5
|
+
the [Working with Anthropic](https://pixeltable.readme.io/docs/working-with-anthropic) tutorial.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union
|
|
9
|
+
|
|
10
|
+
import pixeltable as pxt
|
|
11
|
+
from pixeltable import env
|
|
12
|
+
from pixeltable.utils.code import local_public_names
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
import anthropic
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@env.register_client('anthropic')
|
|
19
|
+
def _(api_key: str) -> 'anthropic.Anthropic':
|
|
20
|
+
import anthropic
|
|
21
|
+
|
|
22
|
+
return anthropic.Anthropic(api_key=api_key)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _anthropic_client() -> 'anthropic.Anthropic':
|
|
26
|
+
return env.Env.get().get_client('anthropic')
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pxt.udf
|
|
30
|
+
def messages(
|
|
31
|
+
messages: list[dict[str, str]],
|
|
32
|
+
*,
|
|
33
|
+
model: str,
|
|
34
|
+
max_tokens: int = 1024,
|
|
35
|
+
metadata: Optional[dict[str, Any]] = None,
|
|
36
|
+
stop_sequences: Optional[list[str]] = None,
|
|
37
|
+
system: Optional[str] = None,
|
|
38
|
+
temperature: Optional[float] = None,
|
|
39
|
+
tool_choice: Optional[list[dict]] = None,
|
|
40
|
+
tools: Optional[dict] = None,
|
|
41
|
+
top_k: Optional[int] = None,
|
|
42
|
+
top_p: Optional[float] = None,
|
|
43
|
+
) -> dict:
|
|
44
|
+
"""
|
|
45
|
+
Create a Message.
|
|
46
|
+
|
|
47
|
+
Equivalent to the Anthropic `messages` API endpoint.
|
|
48
|
+
For additional details, see: <https://docs.anthropic.com/en/api/messages>
|
|
49
|
+
|
|
50
|
+
__Requirements:__
|
|
51
|
+
|
|
52
|
+
- `pip install anthropic`
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
messages: Input messages.
|
|
56
|
+
model: The model that will complete your prompt.
|
|
57
|
+
|
|
58
|
+
For details on the other parameters, see: <https://docs.anthropic.com/en/api/messages>
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
A dictionary containing the response and other metadata.
|
|
62
|
+
|
|
63
|
+
Examples:
|
|
64
|
+
Add a computed column that applies the model `claude-3-haiku-20240307`
|
|
65
|
+
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
|
|
66
|
+
|
|
67
|
+
>>> msgs = [{'role': 'user', 'content': tbl.prompt}]
|
|
68
|
+
... tbl['response'] = messages(msgs, model='claude-3-haiku-20240307')
|
|
69
|
+
"""
|
|
70
|
+
return _anthropic_client().messages.create(
|
|
71
|
+
messages=messages,
|
|
72
|
+
model=model,
|
|
73
|
+
max_tokens=max_tokens,
|
|
74
|
+
metadata=_opt(metadata),
|
|
75
|
+
stop_sequences=_opt(stop_sequences),
|
|
76
|
+
system=_opt(system),
|
|
77
|
+
temperature=_opt(temperature),
|
|
78
|
+
tool_choice=_opt(tool_choice),
|
|
79
|
+
tools=_opt(tools),
|
|
80
|
+
top_k=_opt(top_k),
|
|
81
|
+
top_p=_opt(top_p),
|
|
82
|
+
).dict()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
_T = TypeVar('_T')
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _opt(arg: _T) -> Union[_T, 'anthropic.NotGiven']:
|
|
89
|
+
from anthropic import NOT_GIVEN
|
|
90
|
+
return arg if arg is not None else NOT_GIVEN
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
__all__ = local_public_names(__name__)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def __dir__():
|
|
97
|
+
return __all__
|
|
@@ -60,7 +60,7 @@ def chat_completions(
|
|
|
60
60
|
to an existing Pixeltable column `tbl.prompt` of the table `tbl`:
|
|
61
61
|
|
|
62
62
|
>>> messages = [{'role': 'user', 'content': tbl.prompt}]
|
|
63
|
-
... tbl['response'] = chat_completions(
|
|
63
|
+
... tbl['response'] = chat_completions(messages, model='accounts/fireworks/models/mixtral-8x22b-instruct')
|
|
64
64
|
"""
|
|
65
65
|
kwargs = {'max_tokens': max_tokens, 'top_k': top_k, 'top_p': top_p, 'temperature': temperature}
|
|
66
66
|
kwargs_not_none = {k: v for k, v in kwargs.items() if v is not None}
|
pixeltable/functions/together.py
CHANGED
|
@@ -136,7 +136,7 @@ def chat_completions(
|
|
|
136
136
|
of the table `tbl`:
|
|
137
137
|
|
|
138
138
|
>>> messages = [{'role': 'user', 'content': tbl.prompt}]
|
|
139
|
-
... tbl['response'] = chat_completions(
|
|
139
|
+
... tbl['response'] = chat_completions(messages, model='mistralai/Mixtral-8x7B-v0.1')
|
|
140
140
|
"""
|
|
141
141
|
return (
|
|
142
142
|
_together_client()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
pixeltable/__init__.py,sha256=ISVoeqNCvSJonD0EXJ32Mer84m29YQDyLhhUydyCV_o,1272
|
|
2
|
-
pixeltable/__version__.py,sha256=
|
|
2
|
+
pixeltable/__version__.py,sha256=trDVbtw9jdTT0ICXbanwd2shP4jvU1zFX_mKVo08BXQ,114
|
|
3
3
|
pixeltable/catalog/__init__.py,sha256=E41bxaPeQIcgRYzTWc2vkDOboQhRymrJf4IcHQO7o_8,453
|
|
4
4
|
pixeltable/catalog/catalog.py,sha256=8gsFWm6o9Qg4_BEO6oejdpmP4MAOlhmuKRaJP0o2UPU,7906
|
|
5
5
|
pixeltable/catalog/column.py,sha256=_LnuEsHpopccIgh_Uq0BEHUB5Bk_WsvYaiYscmZZVHk,9628
|
|
@@ -15,7 +15,7 @@ pixeltable/catalog/table_version.py,sha256=T78HuBg-gph1WauElDzvqenu7ipeK3DaViObW
|
|
|
15
15
|
pixeltable/catalog/table_version_path.py,sha256=eyQ07VQYQEbl2_AzaLPVLVe9hQ6c1njiIpDjzWhW5Ic,6398
|
|
16
16
|
pixeltable/catalog/view.py,sha256=ZsEblhWsAotLOoPg1Q_Ts3UNnn4I-SVOTh5bJMDnY20,10599
|
|
17
17
|
pixeltable/dataframe.py,sha256=rmKgmAeJrOmD3ELCnbh-jS3VYwt5rMMUpF5pTWvSSaw,34383
|
|
18
|
-
pixeltable/env.py,sha256=
|
|
18
|
+
pixeltable/env.py,sha256=7TVo0WpFjtALyct7SEHwKqZf0nuyQ3-smgyJUQ8JbgE,21818
|
|
19
19
|
pixeltable/exceptions.py,sha256=MSP9zeL0AmXT93XqjdvgGN4rzno1_KRrGriq6hpemnw,376
|
|
20
20
|
pixeltable/exec/__init__.py,sha256=VRENEONsAv3PPoBV0r7h-7nAB7SWM4Uglmu1FVQE5uQ,507
|
|
21
21
|
pixeltable/exec/aggregation_node.py,sha256=NtN71QrMmzqnAaWcdTuhovr6FCxSuTpvI3S5a0ZZZYA,3341
|
|
@@ -69,9 +69,10 @@ pixeltable/func/globals.py,sha256=sEwn6lGgHMp6VQORb_P5qRd_-Q2_bUSqvqM9-XPN_ec,14
|
|
|
69
69
|
pixeltable/func/query_template_function.py,sha256=BUU0KZYkqVPjIFg6g6msU4PzVGf2fkEKveDaEMGXhzI,3680
|
|
70
70
|
pixeltable/func/signature.py,sha256=6Lwf32auSnmhYGrN4NkHk07BmG2a73TNICbWnelkH1s,8638
|
|
71
71
|
pixeltable/func/udf.py,sha256=xrfCuYFF7Qqx-I_vE11WT9AoY6UbbzIIZ2DBGzYGzDE,7772
|
|
72
|
-
pixeltable/functions/__init__.py,sha256=
|
|
72
|
+
pixeltable/functions/__init__.py,sha256=An9rxP0uG38UYF5kF-wEt9RVioGAjbR9he24rqp7ehc,332
|
|
73
|
+
pixeltable/functions/anthropic.py,sha256=vXiZVIdF3GIKPYLow7_N7m5WC199ZBtAw3q9BUkXnJs,2716
|
|
73
74
|
pixeltable/functions/audio.py,sha256=Z94EB2iJgrXxWYMOGjxJ2KWSDhcEO61Jgs4YoFLYH78,797
|
|
74
|
-
pixeltable/functions/fireworks.py,sha256=
|
|
75
|
+
pixeltable/functions/fireworks.py,sha256=2D4TR4RCUHpDcmHEvidMU4gNyLUa8l9wyduaYnekJ9s,2573
|
|
75
76
|
pixeltable/functions/globals.py,sha256=9yz5XzhGhh4kuvHJ8eiFvy9SCPYaZrF5ltwscMH9xEg,2692
|
|
76
77
|
pixeltable/functions/huggingface.py,sha256=KW2OrRZyzqzpN4PekG5wMCWQsPOA61qvZmJzKURUqlk,12790
|
|
77
78
|
pixeltable/functions/image.py,sha256=DQ95DyddxeMAIryBJb-U-y1ck7kvoNYyo-0PLDBaoyk,13313
|
|
@@ -79,7 +80,7 @@ pixeltable/functions/json.py,sha256=mJ8oEJMJ2aqt5jCrPSN7vf7oSeQOsMN8Wn1H3PSLoKs,
|
|
|
79
80
|
pixeltable/functions/openai.py,sha256=4FyL60mQUPcqb19DkFMBbBHf6utV3xsOs6SPWZrfXp8,15981
|
|
80
81
|
pixeltable/functions/string.py,sha256=JEng3jwYZUSYSfjWjto7tLxlIvQLW1JvQ7OmncIgd5M,20085
|
|
81
82
|
pixeltable/functions/timestamp.py,sha256=pfP28wErdjWOMLgJaxqXPMMScf4_LGUFja7oYb_cNBg,6620
|
|
82
|
-
pixeltable/functions/together.py,sha256=
|
|
83
|
+
pixeltable/functions/together.py,sha256=M_eIUPiZE5nxFVoUPGTPvkYuBZMgoKlcuIp2ywC1Tus,8585
|
|
83
84
|
pixeltable/functions/util.py,sha256=F2iiIL7UfhYdCVzdCa3efYqWbaeLKFrbycKnuPkG57M,650
|
|
84
85
|
pixeltable/functions/video.py,sha256=7_PF4QBlsH0IvOb_JGxARlyOqhtesBykTRcOUIOyqhI,7148
|
|
85
86
|
pixeltable/functions/vision.py,sha256=ONOpkj426ytWCVtuJn8lmSuPJlqXC38ugcUebHVEFL4,13690
|
|
@@ -136,8 +137,8 @@ pixeltable/utils/pytorch.py,sha256=VWczSB_FT_aOU5Xqv4T5ONTsnQN6KDlZmMkuoBuji08,3
|
|
|
136
137
|
pixeltable/utils/s3.py,sha256=DBfXp0SYubhiKckdAD7PsiVBX_YfVP8Rcu6DCG_3SaQ,433
|
|
137
138
|
pixeltable/utils/sql.py,sha256=5n5_OmXAGtqFdL6z5XvgnU-vlx6Ba6f1WJrO1ZwUle8,765
|
|
138
139
|
pixeltable/utils/transactional_directory.py,sha256=UGzCrGtLR3hEEf8sYGuWBzLVFAEQml3vdIavigWeTBM,1349
|
|
139
|
-
pixeltable-0.2.
|
|
140
|
-
pixeltable-0.2.
|
|
141
|
-
pixeltable-0.2.
|
|
142
|
-
pixeltable-0.2.
|
|
143
|
-
pixeltable-0.2.
|
|
140
|
+
pixeltable-0.2.17.dist-info/LICENSE,sha256=0UNMmwuqWPC0xDY1NWMm4uNJ2_MyA1pnTNRgQTvuBiQ,746
|
|
141
|
+
pixeltable-0.2.17.dist-info/METADATA,sha256=s_D-zWxRad72KJyyn9lLatWdaoiWVkMEp72pcN-Vft8,11252
|
|
142
|
+
pixeltable-0.2.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
143
|
+
pixeltable-0.2.17.dist-info/entry_points.txt,sha256=TNI1Gb5vPwFrTdw6TimSYjO8FeK8c_HuPr28vcf7o_I,108
|
|
144
|
+
pixeltable-0.2.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|