mirror of https://github.com/aliasrobotics/cai.git
fix: Conditionally apply Gemini tool_call.id workaround
The workaround for Google Gemini's OpenAI-compatible API, which generates a `tool_call.id` when it's empty, is now applied conditionally. This logic is now executed only when `"openai/gemini"` is present in the `CAI_MODEL` environment variable. This change ensures that the specific fix for Gemini's `tool_call.id` behavior is only active when interacting with Gemini models, preventing potential unintended side effects or unnecessary processing when using other OpenAI-compatible providers.
This commit is contained in:
commit
651968ca04
|
|
@ -516,7 +516,7 @@ result = await Runner.run(agent, message)
|
|||
```
|
||||
|
||||
|
||||
You may find different [tools](cai/tools). They are grouped in 6 major categories inspired by the security kill chain [^2]:
|
||||
You may find different [tools](tools). They are grouped in 6 major categories inspired by the security kill chain [^2]:
|
||||
|
||||
1. Reconnaissance and weaponization - *reconnaissance* (crypto, listing, etc)
|
||||
2. Exploitation - *exploitation*
|
||||
|
|
@ -1044,7 +1044,12 @@ CAI itself is not a profit-seeking initiative. Our goal is to build a sustainabl
|
|||
|
||||
</details>
|
||||
|
||||
<details><summary>I get a `Unable to locate package python3.12-venv` when installing the prerequisites on my debian based system!</summary>
|
||||
|
||||
The easiest way to get around this is to simply install [`python3.12`](https://www.python.org/downloads/release/python-3120/) from source.
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
## Citation
|
||||
If you want to cite our work, please use the following:
|
||||
|
|
|
|||
|
|
@ -974,9 +974,10 @@ class OpenAIChatCompletionsModel(Model):
|
|||
# Fix Google Gemini OpenAI compatibility issues.
|
||||
# When using the OpenAI-compatible API to call tools with Google Gemini
|
||||
# tool_call.id is returned as an empty string.
|
||||
for tool_call in assistant_msg.tool_calls:
|
||||
if tool_call.id is None or tool_call.id == "":
|
||||
tool_call.id = uuid.uuid4().hex[:16]
|
||||
if "openai/gemini" in os.getenv("CAI_MODEL"):
|
||||
for tool_call in assistant_msg.tool_calls:
|
||||
if tool_call.id is None or tool_call.id == "":
|
||||
tool_call.id = uuid.uuid4().hex[:16]
|
||||
|
||||
for tool_call in assistant_msg.tool_calls:
|
||||
# Handle empty arguments before storing
|
||||
|
|
|
|||
Loading…
Reference in New Issue