Skip to content

Commit

Permalink
fix: bumped package versions and improved error handling in notebooks (
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Sep 2, 2024
1 parent 5ca953c commit bf87eb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
21 changes: 10 additions & 11 deletions dial-cookbook/examples/how_to_call_image_to_text_applications.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"\n",
"From this notebook, you will learn how to call image-to-text DIAL applications via [DIAL API chat/completions](https://epam-rail.com/dial_api#/paths/~1openai~1deployments~1%7BDeployment%20Name%7D~1chat~1completions/post) call.\n",
"\n",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_image_to_text_applications.ipynb",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_image_to_text_applications.ipynb\n",
"\n",
"\n",
"**DIAL application** is a general term, which encompasses model adapters and application with any custom logic.\n",
Expand All @@ -36,9 +36,9 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install requests==2.31.0\n",
"!pip install openai==1.9.0\n",
"!pip install langchain-openai==0.0.3"
"!pip install requests==2.32.3\n",
"!pip install openai==1.43.0\n",
"!pip install langchain-openai==0.1.23"
]
},
{
Expand Down Expand Up @@ -579,7 +579,7 @@
"source": [
"## Using LangChain\n",
"\n",
"The [LangChain](https://pypi.org/project/langchain-openai/) library **is not suitable** as a client of image-to-text applications, since `langchain-openai<=0.0.2` ignores the additional fields in the request."
"The [LangChain](https://pypi.org/project/langchain-openai/) library **is not suitable** as a client for image-to-text applications, since `langchain-openai` ignores additional fields attached to chat messages in the request."
]
},
{
Expand Down Expand Up @@ -617,8 +617,8 @@
" llm.generate(messages=[[HumanMessage(content=\"\", additional_kwargs=extra_fields)]])\n",
"\n",
" raise Exception(\"Generation didn't fail\")\n",
"except Exception as e:\n",
" assert str(e) == \"Error code: 422 - {'error': {'message': 'No image attachment was found in the last message', 'type': 'runtime_error'}}\", \"Unexpected error\""
"except openai.UnprocessableEntityError as e:\n",
" assert e.body[\"message\"] == \"No image attachment was found in the last message\""
]
},
{
Expand All @@ -634,15 +634,14 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"try:\n",
" output = llm.stream(input=[HumanMessage(content=\"\", additional_kwargs=extra_fields)])\n",
" for chunk in output:\n",
" print(chunk.dict())\n",
"\n",
" raise Exception(\"Generation didn't fail\")\n",
"except Exception as e:\n",
" assert str(e) == \"Error code: 422 - {'error': {'message': 'No image attachment was found in the last message', 'type': 'runtime_error'}}\", \"Unexpected error\"\n"
"except openai.UnprocessableEntityError as e:\n",
" assert e.body[\"message\"] == \"No image attachment was found in the last message\""
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"\n",
"From this notebook, you will learn how to call text-to-image applications via [DIAL API chat/completions](https://epam-rail.com/dial_api#/paths/~1openai~1deployments~1%7BDeployment%20Name%7D~1chat~1completions/post) call.\n",
"\n",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_text_to_image_applications.ipynb",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_text_to_image_applications.ipynb\n",
"\n",
"\n",
"**DIAL application** is a general term, which encompasses model adapters and applications with any custom logic.\n",
Expand Down Expand Up @@ -43,9 +43,9 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install requests==2.31.0\n",
"!pip install openai==1.9.0\n",
"!pip install langchain-openai==0.0.3"
"!pip install requests==2.32.3\n",
"!pip install openai==1.43.0\n",
"!pip install langchain-openai==0.1.23"
]
},
{
Expand Down Expand Up @@ -709,7 +709,7 @@
"source": [
"## Using LangChain\n",
"\n",
"The [LangChain](https://pypi.org/project/langchain-openai/) library **is not suitable** as a client of text-to-image applications, since `langchain-openai<=0.0.2` ignores the additional fields attached to the response message.\n",
"The [LangChain](https://pypi.org/project/langchain-openai/) library **is not suitable** as a client of text-to-image applications, since `langchain-openai` ignores additional fields attached to the response message.\n",
"\n",
"Meaning that the response won't contain any image attachments.\n",
"It's still possible to use the application completion if an application returns image that way:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"\n",
"From this notebook, you can learn how to call text-to-text DIAL applications via [DIAL API chat/completions](https://epam-rail.com/dial_api#/paths/~1openai~1deployments~1%7BDeployment%20Name%7D~1chat~1completions/post) call.\n",
"\n",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_text_to_text_applications.ipynb",
"\n",
"https://github.com/epam/ai-dial/blob/main/dial-cookbook/examples/how_to_call_text_to_text_applications.ipynb\n",
"\n",
"\n",
"For this example, we use a sample text-to-text application called **Echo**, which returns the content of the last user message.\n",
Expand All @@ -25,9 +25,9 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install requests==2.31.0\n",
"!pip install openai==1.9.0\n",
"!pip install langchain-openai==0.0.3"
"!pip install requests==2.32.3\n",
"!pip install openai==1.43.0\n",
"!pip install langchain-openai==0.1.23"
]
},
{
Expand Down

0 comments on commit bf87eb7

Please sign in to comment.