mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
notebook for tokens (#2086)
This commit is contained in:
parent
33ebb05251
commit
4cd5cf2e95
@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 3,
|
||||||
"id": "d1c55cc9",
|
"id": "d1c55cc9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 5,
|
||||||
"id": "31667d54",
|
"id": "31667d54",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -43,14 +43,18 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"42\n"
|
"Total Tokens: 42\n",
|
||||||
|
"Prompt Tokens: 4\n",
|
||||||
|
"Completion Tokens: 38\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"with get_openai_callback() as cb:\n",
|
"with get_openai_callback() as cb:\n",
|
||||||
" result = llm(\"Tell me a joke\")\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}\")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user