@ -107,7 +107,7 @@
"source": [
"messages = [\n",
" SystemMessage(content=\"You are a helpful assistant that translates English to French.\"),\n",
" HumanMessage(content=\"Translate this sentence from English to French. I love programming.\")\n",
" HumanMessage(content=\"I love programming.\")\n",
"]\n",
"chat(messages)"
]
@ -131,7 +131,7 @@
{
"data": {
"text/plain": [
"LLMResult(generations=[[ChatGeneration(text=\"J'aime programmer.\", generation_info=None, message=AIMessage(content=\"J'aime programmer.\", additional_kwargs={}))], [ChatGeneration(text=\"J'aime l'intelligence artificielle.\", generation_info=None, message=AIMessage(content=\"J'aime l'intelligence artificielle.\", additional_kwargs={}))]], llm_output={'token_usage': {'prompt_tokens': 71, 'completion_tokens': 18, 'total_tokens': 89 }})"
"LLMResult(generations=[[ChatGeneration(text=\"J'aime programmer.\", generation_info=None, message=AIMessage(content=\"J'aime programmer.\", additional_kwargs={}))], [ChatGeneration(text=\"J'aime l'intelligence artificielle.\", generation_info=None, message=AIMessage(content=\"J'aime l'intelligence artificielle.\", additional_kwargs={}))]], llm_output={'token_usage': {'prompt_tokens': 57, 'completion_tokens': 20, 'total_tokens': 77 }})"
]
},
"execution_count": 5,
@ -143,11 +143,11 @@
"batch_messages = [\n",
" [\n",
" SystemMessage(content=\"You are a helpful assistant that translates English to French.\"),\n",
" HumanMessage(content=\"Translate this sentence from English to French. I love programming.\")\n",
" HumanMessage(content=\"I love programming.\")\n",
" ],\n",
" [\n",
" SystemMessage(content=\"You are a helpful assistant that translates English to French.\"),\n",
" HumanMessage(content=\"Translate this sentence from English to French. I love artificial intelligence.\")\n",
" HumanMessage(content=\"I love artificial intelligence.\")\n",
" ],\n",
"]\n",
"result = chat.generate(batch_messages)\n",
@ -171,9 +171,9 @@
{
"data": {
"text/plain": [
"{'token_usage': {'prompt_tokens': 71 ,\n",
" 'completion_tokens': 18 ,\n",
" 'total_tokens': 89 }}"
"{'token_usage': {'prompt_tokens': 5 7,\n",
" 'completion_tokens': 20 ,\n",
" 'total_tokens': 77 }}"
]
},
"execution_count": 6,