Aller au contenu

Fallback Tools

AI generated translation.

An image in retro 8-bit style showing a digital workspace. On the left, there are icons with lines connecting them, symbolizing the idea of "fallback tools." On the right, geometrical shapes represent binary code processing related to tool-enabled LLMs. The background consists of basic geometric shapes that give a corporate and tech-focused feel, using a consistent 5-color scheme without any human figures or text.
Generated by 🤖 AI

Outils est une fonctionnalité puissante des modèles LLM qui permet d’augmenter le raisonnement des LLM avec des outils externes.

De nos jours, de nombreux modèles LLM intègrent un support intégré pour les outils. Cependant, certains ne le font pas… comme o1-preview et o1-mini d’OpenAI.

Avec GenAIScript 1.72.0, nous introduisons le concept des outils de secours. En gros, cela consiste en un script système qui “enseigne” au modèle LLM les outils disponibles et comment les utiliser.

$`## Tool support
You can call external tools to help generating the answer of the user questions.
- The list of tools is defined in TOOLS. Use the description to help you choose the best tools.
- Each tool has an id, description, and a JSON schema for the arguments.
...
\`\`\`tool_calls
<tool_id>: { <JSON_serialized_tool_call_arguments> }
<tool_id_2>: { <JSON_serialized_tool_call_arguments_2> }
...
\`\`\`

Voici un exemple d’un outil qui génère un nombre aléatoire compris entre 0 et 1.

defTool("random", "Generate a random number", {}, () =>
Math.random(),
);
$`Generate a random number between 0 and 1.`;
  • trace o1-mini (utilisant les modèles GitHub)
prompting github:openai/o1-mini (~490 tokens)
```tool_calls
random: {}
```
prompting github:openai/o1-mini (~532 tokens)
Your random number between 0 and 1 is **0.7792901036554349**.
  • modèle gemma2 (utilisant Ollama)
prompting ollama:gemma2 (~716 tokens)
```tool_calls
random: {}
```
prompting ollama:gemma2 (~758 tokens)
The random number is 0.9552638470626966.
Let me know if you'd like to generate another random number!

Le mode outil de secours est automatiquement activé pour les modèles LLM connus qui ne prennent pas en charge les outils nativement. La liste n’est pas complète, alors ouvrez une issue si vous tombez sur un modèle qui devrait avoir les outils de secours activés.

Il peut être activé manuellement en réglant l’option fallbackTools sur true dans la configuration du script.

script({
fallbackTools: true,
});

ou en définissant l’option --fallback-tools dans la CLI.

Fenêtre de terminal
genaiscript run --fallback-tools ...