notebook for tokens (#2086)

This commit is contained in:
Harrison Chase 2023-03-28 07:59:40 -07:00 committed by GitHub
parent 33ebb05251
commit 4cd5cf2e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "d1c55cc9",
"metadata": {},
"outputs": [],
@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "31667d54",
"metadata": {},
"outputs": [
@ -43,14 +43,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"42\n"
"Total Tokens: 42\n",
"Prompt Tokens: 4\n",
"Completion Tokens: 38\n"
]
}
],
"source": [
"with get_openai_callback() as cb:\n",
" result = llm(\"Tell me a joke\")\n",
" print(cb.total_tokens)"
" print(f\"Total Tokens: {cb.total_tokens}\")\n",
" print(f\"Prompt Tokens: {cb.prompt_tokens}\")\n",
" print(f\"Completion Tokens: {cb.completion_tokens}\")"
]
},
{