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.
Metadata
Release files for openai-multi-tool-use-parallel-patch 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openai_multi_tool_use_parallel_patch-0.2.0.tar.gz | 3.0 kB | Without provenance | Details for openai_multi_tool_use_parallel_patch-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl |
Total release size: 6.9 kB
Release files / openai_multi_tool_use_parallel_patch-0.2.0.tar.gz
| Download URL | openai_multi_tool_use_parallel_patch-0.2.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7ceb1150df00ddb21b11556520cd94b8b151d6199245e1d6aabc1c85ed442cc
|
|
BLAKE2b-256 checksum How to use checksums |
33e5af197f1dc70aa32cf978587f55e25ce11c20df022c2690eb2b416b16680a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Darwin/23.1.0
|
Release files / openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl
| Download URL | openai_multi_tool_use_parallel_patch-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
850382c7e7559458caf075d7c0fa5e838b0037de894cd0a5be147e519415d618
|
|
BLAKE2b-256 checksum How to use checksums |
25a2ed1fe194d823577f8cabd7e68b2b4550508620d0268caa6d55df3b4d6f5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Darwin/23.1.0
|
Security for openai-multi-tool-use-parallel-patch 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.