Quick monkey-patching fix for OpenAI's hallucinated multi_tool_use.parallel
Project description
Patching multi_tool_use.parallel in OpenAI
Quick monkey-patching fix for OpenAI's hallucinated multi_tool_use.parallel issue.
This is a simple workaround for this issue where the GPT ChatCompletions API sometimes hallucinates a strange alternative way of calling multiple tools at once. In my experience, these calls at least always follow a predictable structure and can be hotfixed to look like normal, legal tool calls. This patch does that, and also rewrites the message accordingly (which, in my experience, makes the model perform calls work in the normal expected way.)
This fix will be redundant soon, but it looks like I am not the only one who occasionally runs into this error, so I thought I would share this workaround.
Installation and usage
pip install openai-multi-tool-use-parallel-patch
In your code:
import openai_multi_tool_use_parallel_patch # import applies the patch
import openai
client = openai.AsyncOpenAI(...) # sync client will be patched too
...
response = await client.chat.completions.create(...) # no changes to the call signature or response vs vanilla OpenAI client
That's it - theoretically this should work even if you import openai first, but at the least you will need to make sure not to create your openai.OpenAI or openai.AsyncOpenAI instances before importing this patch.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openai_multi_tool_use_parallel_patch-0.2.0.tar.gz.
File metadata
- Download URL: openai_multi_tool_use_parallel_patch-0.2.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.7.17 Darwin/23.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7ceb1150df00ddb21b11556520cd94b8b151d6199245e1d6aabc1c85ed442cc
|
|
| MD5 |
769022c805488b28eb74eeb9d082afc1
|
|
| BLAKE2b-256 |
33e5af197f1dc70aa32cf978587f55e25ce11c20df022c2690eb2b416b16680a
|
File details
Details for the file openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl.
File metadata
- Download URL: openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.7.17 Darwin/23.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
850382c7e7559458caf075d7c0fa5e838b0037de894cd0a5be147e519415d618
|
|
| MD5 |
782e08919364b802c4d82f086a8bc26b
|
|
| BLAKE2b-256 |
25a2ed1fe194d823577f8cabd7e68b2b4550508620d0268caa6d55df3b4d6f5b
|