metergraph 0.1.0__tar.gz → 0.2.0__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.
@@ -1,8 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Fire-and-forget LLM spend capture for Metergraph
5
+ Author: Pioneer Square Labs
5
6
  License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://www.metergraph.dev/
8
+ Project-URL: Repository, https://github.com/PioneerSquareLabs/metergraphsdk
9
+ Project-URL: Issues, https://github.com/PioneerSquareLabs/metergraphsdk/issues
10
+ Keywords: llm,observability,openai,anthropic,gemini,cost-tracking
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Typing :: Typed
6
14
  Requires-Python: >=3.10
7
15
  Description-Content-Type: text/markdown
8
16
  Provides-Extra: dev
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "metergraph"
3
+ version = "0.2.0"
4
+ description = "Fire-and-forget LLM spend capture for Metergraph"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ authors = [{ name = "Pioneer Square Labs" }]
9
+ keywords = ["llm", "observability", "openai", "anthropic", "gemini", "cost-tracking"]
10
+ classifiers = [
11
+ "Intended Audience :: Developers",
12
+ "Topic :: Software Development :: Libraries :: Python Modules",
13
+ "Typing :: Typed",
14
+ ]
15
+ dependencies = []
16
+
17
+ [project.urls]
18
+ Homepage = "https://www.metergraph.dev/"
19
+ Repository = "https://github.com/PioneerSquareLabs/metergraphsdk"
20
+ Issues = "https://github.com/PioneerSquareLabs/metergraphsdk/issues"
21
+
22
+ [project.optional-dependencies]
23
+ dev = ["pytest>=8"]
24
+
25
+ [build-system]
26
+ requires = ["setuptools>=68"]
27
+ build-backend = "setuptools.build_meta"
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.pytest.ini_options]
33
+ testpaths = ["tests"]
@@ -1111,6 +1111,10 @@ def wrap(client: Any, *, provider: str | None = None) -> Any:
1111
1111
  chat = getattr(getattr(client, "chat", None), "completions", None)
1112
1112
  if chat is not None:
1113
1113
  seams.append((chat, "create", "chat.completions"))
1114
+ seams.append((chat, "parse", "chat.completions.parse"))
1115
+ beta_chat = getattr(getattr(getattr(client, "beta", None), "chat", None), "completions", None)
1116
+ if beta_chat is not None:
1117
+ seams.append((beta_chat, "parse", "chat.completions.parse"))
1114
1118
  responses = getattr(client, "responses", None)
1115
1119
  if responses is not None:
1116
1120
  seams.extend(
@@ -8,4 +8,4 @@ import importlib.metadata
8
8
  try:
9
9
  SDK_VERSION = importlib.metadata.version("metergraph")
10
10
  except Exception:
11
- SDK_VERSION = "0.1.0"
11
+ SDK_VERSION = "0.2.0"
@@ -1,8 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metergraph
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Fire-and-forget LLM spend capture for Metergraph
5
+ Author: Pioneer Square Labs
5
6
  License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://www.metergraph.dev/
8
+ Project-URL: Repository, https://github.com/PioneerSquareLabs/metergraphsdk
9
+ Project-URL: Issues, https://github.com/PioneerSquareLabs/metergraphsdk/issues
10
+ Keywords: llm,observability,openai,anthropic,gemini,cost-tracking
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Typing :: Typed
6
14
  Requires-Python: >=3.10
7
15
  Description-Content-Type: text/markdown
8
16
  Provides-Extra: dev
@@ -112,6 +112,38 @@ def test_wrap_sync_records_usage_context_and_preserves_response(tmp_path):
112
112
  _capture.set_runtime(None)
113
113
 
114
114
 
115
+ def test_wrap_patches_create_and_parse_on_both_chat_and_beta_chat(tmp_path):
116
+ rows = Rows()
117
+ _capture.set_runtime(
118
+ Runtime(rows, Options(app_root=str(Path(__file__).parents[1])))
119
+ )
120
+
121
+ class Completions:
122
+ def create(self, **kwargs):
123
+ return response()
124
+
125
+ def parse(self, **kwargs):
126
+ return response()
127
+
128
+ client = SimpleNamespace(
129
+ chat=SimpleNamespace(completions=Completions()),
130
+ beta=SimpleNamespace(chat=SimpleNamespace(completions=Completions())),
131
+ responses=None,
132
+ )
133
+ metergraph.wrap(client, provider="openai")
134
+
135
+ client.chat.completions.create(model="gpt-test", messages=[])
136
+ client.chat.completions.parse(model="gpt-test", messages=[])
137
+ client.beta.chat.completions.parse(model="gpt-test", messages=[])
138
+
139
+ assert [row["endpoint"] for row in rows.rows] == [
140
+ "chat.completions",
141
+ "chat.completions.parse",
142
+ "chat.completions.parse",
143
+ ]
144
+ _capture.set_runtime(None)
145
+
146
+
115
147
  def gemini_response(text="gemini done"):
116
148
  return SimpleNamespace(
117
149
  text=text,
@@ -1,21 +0,0 @@
1
- [project]
2
- name = "metergraph"
3
- version = "0.1.0"
4
- description = "Fire-and-forget LLM spend capture for Metergraph"
5
- readme = "README.md"
6
- requires-python = ">=3.10"
7
- license = "Apache-2.0"
8
- dependencies = []
9
-
10
- [project.optional-dependencies]
11
- dev = ["pytest>=8"]
12
-
13
- [build-system]
14
- requires = ["setuptools>=68"]
15
- build-backend = "setuptools.build_meta"
16
-
17
- [tool.setuptools.packages.find]
18
- where = ["src"]
19
-
20
- [tool.pytest.ini_options]
21
- testpaths = ["tests"]
File without changes
File without changes