dagster-openai 0.26.13__tar.gz → 0.26.14__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-openai
3
- Version: 0.26.13
3
+ Version: 0.26.14
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.14
16
16
  Requires-Dist: openai
17
17
  Dynamic: author
18
18
  Dynamic: author-email
@@ -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
 
@@ -0,0 +1 @@
1
+ __version__ = "0.26.14"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-openai
3
- Version: 0.26.13
3
+ Version: 0.26.14
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.14
16
16
  Requires-Dist: openai
17
17
  Dynamic: author
18
18
  Dynamic: author-email
@@ -0,0 +1,2 @@
1
+ dagster==1.10.14
2
+ openai
@@ -31,7 +31,7 @@ setup(
31
31
  ],
32
32
  packages=find_packages(exclude=["dagster_openai_tests*"]),
33
33
  install_requires=[
34
- "dagster==1.10.13",
34
+ "dagster==1.10.14",
35
35
  "openai",
36
36
  ],
37
37
  zip_safe=False,
@@ -1 +0,0 @@
1
- __version__ = "0.26.13"
@@ -1,2 +0,0 @@
1
- dagster==1.10.13
2
- openai