MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / wrapped_create

Function wrapped_create

experiments/token_cost/measure_day_token_usage.py:153–167  ·  view source on GitHub ↗
(*create_args, **create_kwargs)

Source from the content-addressed store, hash-verified

151 original_create = self.client.embeddings.create
152 if not getattr(original_create, "_paperflow_token_wrapped", False):
153 def wrapped_create(*create_args, **create_kwargs):
154 response = original_create(*create_args, **create_kwargs)
155 usage = _extract_usage_dict(getattr(response, "usage", None))
156 inputs = create_kwargs.get("input")
157 if isinstance(inputs, list):
158 input_count = len(inputs)
159 else:
160 input_count = 1
161 tracker.record_embedding(
162 model=str(create_kwargs.get("model") or getattr(self, "model", "")),
163 input_count=input_count,
164 usage=usage,
165 provider="openai",
166 )
167 return response
168
169 wrapped_create._paperflow_token_wrapped = True # type: ignore[attr-defined]
170 self.client.embeddings.create = wrapped_create

Callers

nothing calls this directly

Calls 3

getMethod · 0.80
record_embeddingMethod · 0.80
_extract_usage_dictFunction · 0.70

Tested by

no test coverage detected