@ -14,7 +14,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 4 ,
"execution_count": 1 ,
"id": "6bb221b3",
"id": "6bb221b3",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
@ -56,17 +56,17 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 5 ,
"execution_count": 2 ,
"id": "5488ec85",
"id": "5488ec85",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"AIMessage(content='3 + 9 equals 12.', additional_kwargs={}, example=False )"
"AIMessage(content='3 + 9 equals 12.')"
]
]
},
},
"execution_count": 5 ,
"execution_count": 2 ,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
@ -87,7 +87,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 9 ,
"execution_count": 3 ,
"id": "80b3b5f6-5d58-44b9-807e-cce9a46bf49f",
"id": "80b3b5f6-5d58-44b9-807e-cce9a46bf49f",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
@ -98,7 +98,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 10 ,
"execution_count": 4 ,
"id": "ff0daf0c-49dd-4d21-9772-e5fa133c5f36",
"id": "ff0daf0c-49dd-4d21-9772-e5fa133c5f36",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
@ -125,7 +125,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 12 ,
"execution_count": 5 ,
"id": "1a5e709e-9d75-48c7-bb9c-503251990505",
"id": "1a5e709e-9d75-48c7-bb9c-503251990505",
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
@ -133,6 +133,7 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"{'foo': 'bar'}\n",
"Tokens Used: 65\n",
"Tokens Used: 65\n",
"\tPrompt Tokens: 56\n",
"\tPrompt Tokens: 56\n",
"\tCompletion Tokens: 9\n",
"\tCompletion Tokens: 9\n",
@ -145,9 +146,10 @@
"from langchain.callbacks import get_openai_callback\n",
"from langchain.callbacks import get_openai_callback\n",
"\n",
"\n",
"with get_openai_callback() as cb:\n",
"with get_openai_callback() as cb:\n",
" RunnableLambda(parse_or_fix).invoke(\n",
" output = RunnableLambda(parse_or_fix).invoke(\n",
" \"{foo: bar}\", {\"tags\": [\"my-tag\"], \"callbacks\": [cb]}\n",
" \"{foo: bar}\", {\"tags\": [\"my-tag\"], \"callbacks\": [cb]}\n",
" )\n",
" )\n",
" print(output)\n",
" print(cb)"
" print(cb)"
]
]
},
},
@ -176,7 +178,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.9.1 "
"version": "3.11.5 "
}
}
},
},
"nbformat": 4,
"nbformat": 4,