dagster-openai 0.26.13__py3-none-any.whl → 0.26.15__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 dagster-openai might be problematic. Click here for more details.

@@ -38,7 +38,9 @@ context_to_counters = WeakKeyDictionary()
38
38
 
39
39
 
40
40
  def _add_to_asset_metadata(
41
- context: AssetExecutionContext, usage_metadata: dict, output_name: Optional[str]
41
+ context: AssetExecutionContext,
42
+ usage_metadata: dict[str, int],
43
+ output_name: Optional[str],
42
44
  ):
43
45
  if context not in context_to_counters:
44
46
  context_to_counters[context] = defaultdict(lambda: 0)
@@ -46,7 +48,11 @@ def _add_to_asset_metadata(
46
48
 
47
49
  for metadata_key, delta in usage_metadata.items():
48
50
  counters[metadata_key] += delta
49
- context.add_output_metadata(dict(counters), output_name)
51
+
52
+ context.add_output_metadata(
53
+ metadata=dict(counters),
54
+ output_name=output_name,
55
+ )
50
56
 
51
57
 
52
58
  @public
@@ -128,15 +134,24 @@ def with_usage_metadata(
128
134
  @wraps(func)
129
135
  def wrapper(*args, **kwargs):
130
136
  response = func(*args, **kwargs)
137
+ calls_key = f"openai.{response.model}.calls"
138
+ total_tokens_key = f"openai.{response.model}.total_tokens"
139
+ prompt_tokens_key = f"openai.{response.model}.prompt_tokens"
140
+ completion_tokens_key = f"openai.{response.model}.completion_tokens"
141
+
131
142
  usage = response.usage
132
143
  usage_metadata = {
133
- "openai.calls": 1,
134
- "openai.total_tokens": usage.total_tokens,
135
- "openai.prompt_tokens": usage.prompt_tokens,
144
+ calls_key: 1,
145
+ total_tokens_key: usage.total_tokens,
146
+ prompt_tokens_key: usage.prompt_tokens,
136
147
  }
137
148
  if hasattr(usage, "completion_tokens"):
138
- usage_metadata["openai.completion_tokens"] = usage.completion_tokens
139
- _add_to_asset_metadata(context, usage_metadata, output_name)
149
+ usage_metadata[completion_tokens_key] = usage.completion_tokens
150
+ _add_to_asset_metadata(
151
+ context=context,
152
+ usage_metadata=usage_metadata,
153
+ output_name=output_name,
154
+ )
140
155
 
141
156
  return response
142
157
 
dagster_openai/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.26.13"
1
+ __version__ = "0.26.15"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-openai
3
- Version: 0.26.13
3
+ Version: 0.26.15
4
4
  Summary: An OpenAI client resource for interacting with OpenAI API.
5
5
  Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-openai
6
6
  Author: Dagster Labs
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  License-File: LICENSE
15
- Requires-Dist: dagster==1.10.13
15
+ Requires-Dist: dagster==1.10.15
16
16
  Requires-Dist: openai
17
17
  Dynamic: author
18
18
  Dynamic: author-email
@@ -0,0 +1,9 @@
1
+ dagster_openai/__init__.py,sha256=7_AS1TCgl9chTzaFNTsCpt3G-aVQnzUAz-RpT9OC-Xk,299
2
+ dagster_openai/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
3
+ dagster_openai/resources.py,sha256=Z3sknKI37Ru72GuqHwmUuzzC51j4QBMNCG_57ro5t8g,15832
4
+ dagster_openai/version.py,sha256=IIhGitgHey00De1EI8U4OzQYe2QXMJMKhPNhRMkJeas,24
5
+ dagster_openai-0.26.15.dist-info/licenses/LICENSE,sha256=4lsMW-RCvfVD4_F57wrmpe3vX1xwUk_OAKKmV_XT7Z0,11348
6
+ dagster_openai-0.26.15.dist-info/METADATA,sha256=Y7OBoDVQ2Lcyk7-_7WuUy6memJPsInbtgD2Wp7YeUfQ,800
7
+ dagster_openai-0.26.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
8
+ dagster_openai-0.26.15.dist-info/top_level.txt,sha256=-66JR-jWfULrYSXUk2AfOdXl8cQyyldzBvBmEQdKn9o,15
9
+ dagster_openai-0.26.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2024 Dagster Labs, Inc".
189
+ Copyright 2025 Dagster Labs, Inc.
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,9 +0,0 @@
1
- dagster_openai/__init__.py,sha256=7_AS1TCgl9chTzaFNTsCpt3G-aVQnzUAz-RpT9OC-Xk,299
2
- dagster_openai/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
3
- dagster_openai/resources.py,sha256=lpvQeDKfNG9IPdYafoGTBPGwyjD_Kkf8A1EvC7qNxqw,15439
4
- dagster_openai/version.py,sha256=EDf5CcPxrnkRq2ViErwz2GB5gPrihrLuUdZnXlor9gM,24
5
- dagster_openai-0.26.13.dist-info/licenses/LICENSE,sha256=HTQpxmWIpPec-pUSMBAj0wR44OnVdRmrWygQ-GUuVzQ,11349
6
- dagster_openai-0.26.13.dist-info/METADATA,sha256=Plei-a5LK1VXDaSi4cEv7qiXc_6tktlOb1XkCwm4bb4,800
7
- dagster_openai-0.26.13.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
8
- dagster_openai-0.26.13.dist-info/top_level.txt,sha256=-66JR-jWfULrYSXUk2AfOdXl8cQyyldzBvBmEQdKn9o,15
9
- dagster_openai-0.26.13.dist-info/RECORD,,