Skip to content

Commit d41cbac

Browse files
committed
Return 0 token counts and cost for via_streaming for now
1 parent 7c973fe commit d41cbac

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

llms_wrapper/llms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,13 @@ def cleaned_args(args: dict):
796796
ret["response"] = response
797797
ret["answer"] = answer
798798
ret["n_chunks"] = n_chunks
799-
ret["cost"] = None
800799
ret["elapsed_time"] = time.time() - start
801800
ret["ok"] = True
802801
ret["error"] = ""
802+
# TODO: for now return 0, may perhaps be possible to do better?
803+
ret["cost"] = 0
804+
ret["n_prompt_tokens"] = 0
805+
ret["n_completion_tokens"] = 0
803806
return ret
804807
except Exception as e:
805808
tb = traceback.extract_tb(e.__traceback__)

llms_wrapper/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import importlib.metadata
2-
__version__ = "0.5.5"
2+
__version__ = "0.5.6"
33

notebooks/test-via-streaming.ipynb

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,51 @@
293293
},
294294
{
295295
"cell_type": "code",
296-
"execution_count": null,
296+
"execution_count": 10,
297297
"id": "491b0ddb",
298298
"metadata": {},
299-
"outputs": [],
299+
"outputs": [
300+
{
301+
"name": "stdout",
302+
"output_type": "stream",
303+
"text": [
304+
"PROCESSING OK, chunks: 1\n",
305+
"A **monoid** is a fundamental algebraic structure in mathematics and computer science that consists of:\n",
306+
"\n",
307+
"1. **A set** (e.g., numbers, strings, functions).\n",
308+
"2. **An associative binary operation** (e.g., addition, concatenation) that combines two elements of the set to produce another element of the same set.\n",
309+
"3. **An identity element** (e.g., 0 for addition, the empty string for concatenation) that leaves other elements unchanged when combined with them.\n",
310+
"\n",
311+
"### Simple Example: Strings with Concatenation\n",
312+
"- **Set**: All possible strings (e.g., `\"a\"`, `\"hello\"`, `\"\"`).\n",
313+
"- **Operation**: Concatenation (e.g., `\"a\" + \"b\" = \"ab\"`).\n",
314+
"- **Identity element**: The empty string `\"\"` (since `\"a\" + \"\" = \"a\"`).\n",
315+
"\n",
316+
"This forms a monoid because:\n",
317+
"- Concatenation is **associative**: `(x + y) + z = x + (y + z)`.\n",
318+
"- The empty string is the **identity**: `x + \"\" = x`.\n",
319+
"\n",
320+
"---\n",
321+
"\n",
322+
"### Why Monoids Are Useful\n",
323+
"1. **Abstraction**: Monoids generalize common operations (like addition, multiplication, or list appending) into a single framework, making it easier to reason about them.\n",
324+
"2. **Parallelism**: Associativity allows operations to be performed in any order, enabling efficient parallel computation (e.g., MapReduce uses monoids to combine results from distributed workers).\n",
325+
"3. **Functional Programming**: Monoids are key in functional programming for combining data (e.g., folding lists, merging data structures).\n",
326+
"4. **Category Theory**: Monoids appear in advanced math and CS as a building block for more complex structures (e.g., monads).\n",
327+
"\n",
328+
"### Another Example: Numbers with Addition\n",
329+
"- **Set**: Integers `{0, 1, -1, 2, ...}`.\n",
330+
"- **Operation**: Addition (`+`).\n",
331+
"- **Identity**: `0` (since `x + 0 = x`).\n",
332+
"\n",
333+
"This is also a monoid because addition is associative and `0` is the identity.\n",
334+
"\n",
335+
"---\n",
336+
"### Key Takeaway\n",
337+
"A monoid is a simple but powerful way to describe \"combinable things with a neutral element.\" Its properties enable efficient, predictable, and scalable computations in many areas.\n"
338+
]
339+
}
340+
],
300341
"source": [
301342
"# Standard/default way to do it .... \n",
302343
"logger.disable(\"llms_wrapper\")\n",

0 commit comments

Comments
 (0)