Tool Call

0 views
Skip to first unread message

Albertina Drybread

unread,
Aug 5, 2024, 7:59:07 AM8/5/24
to quiwarlalins
LargeLanguage Models (LLMs) can interact with external data sources via tool calling functionality. Tool calling is a powerful technique that allows developers to build sophisticated applications that can leverage LLMs to access, interact and manipulate external resources like databases, files and APIs.

ChatModel.bind_tools provides a standard interface implemented by all tool-calling models that lets you specify which tools are available to the model. You can pass in not just a raw tool definition (a dict), but also objects from which a tool definition can be derived: namely Pydantic classes, LangChain tools, and arbitrary functions. This makes it easy to create generic tool definitions that you can use with any tool-calling model:


We recently released the ChatModel.with_structured_output() interface for getting structured outputs from a model, which is very related. While the exact implementation varies by model provider, with_structured_output is built on top of tool-calling for most models that support it. Under the hood, with_structured_output uses bind_tools to pass the given structured output schema to the model.


with_structured_output always returns a structured output in the schema that you specified. This is useful when you want to force the LLM to output information that matches a specific schema. This is useful for information extraction tasks.


bind_tools is more general and can select a specific tool - or no tool, or multiple tools! This is useful when you want to allow the LLM to have more flexibility in how it should respond - for example, in agent applications where you need to choose which tools to invoke but also respond to the user.


We expect that the trend to introduce native tool calling capabilities into LLMs will continue in the future. We hope that the standardized tool calling interface can help save LangChain users time and effort and allow them to switch between different LLM providers more easily.


Smarter campaigns lead to more successful engagements. Simply dialing through a list as quickly as possible will not yield the best engagement on calls. CallTools offers a variety of options to help manage your campaigns for better connections with your customers and prospects. From the start of the first call to your final interaction, the CallTools Power Contact Center was designed to nurture your contacts throughout the process.


Everything starts with the agent experience. Simple enough to get started right away, yet advanced enough to handle all aspects of client interaction. Your agents will provide data that can elevate your campaigns and improve engagement.


Maximize agent productivity at your call center with a solution that manages your calls for success from beginning to end. Better campaigns start with improved contact management, smarter calling lists, redundant redial rules and abundant automations.


Lower the chance of blocked calls with suppression rules designed to alleviate disruptive calling behaviors automatically. Protect your reputation with caller ID auditing, allowing you to swap out bad caller IDs quickly.


However, since function calls are now deprecated, I was wondering if anyone had a solution to get something like this working with the new GPT-4-1106-preview model with streaming and handling multiple tool calls?


@Cristhiandcl8 : If you have a workaround, please post it. The original poster had no luck with curl and I had no luck with the new Python SDK, built from the OpenAPI spec with Stainless. With curl, I thought there could be a problem with buffering the server-sent events (possibly mitigated by --no-buffer), but that seems to not be the case.


Discovered what was happening in my case (OpenAI Python SDK 1.3). With the previous streaming implementation for function or content, you were always able to determine the type of response in the first chunk. With tool calls, the first chunk actually can have content, function, and tool_calls all set to None and so you have to sniff multiple chunks from the response before you can determine what kind of response you are accumulating.


Any solution for this error: An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_7iGLlP788Y3p6A1fPP27Vy0L


That indicates that you did not pass the required pairing of prior assistant output and the tool response properly. They both must be appended consecutively after the most recent user input with the matching tool IDs.


+1 on this, I have a use case where I want to call the same tool multiple times, but I want to limit the number of times it can be called, otherwise it can exceed max_tokens and cause a 500 server error!


The large language model needs to know the tool results before it can continue generating text.This requires sending the tool results back to the model.You can enable this feature by setting the maxToolRoundtrips setting to a number greater than 0.


Note that when you have tool_choice as any or tool, we will prefill the assistant message to force a tool to be used. This means that the models will not emit a chain-of-thought text content block before tool_use content blocks, even if explicitly asked to do so.


Our testing has shown that this should not reduce performance. If you would like to keep chain-of-thought (particularly with Opus) while still requesting that the model use a specific tool, you can use "type": "auto" for tool_choice (the default) and add explicit instructions in a user message. For example: What's the weather like in London? Use the get_weather tool in your response.


With the Claude 3 Sonnet model, chain of thought is less common by default, but you can prompt Claude to show its reasoning by adding something like "Before answering, explain your reasoning step-by-step in tags." to the user message or system prompt.


Messages contain arrays of text, image, tool_use, and tool_result blocks. user messages include client-side content and tool_result, while assistant messages contain AI-generated content and tool_use.


Some tasks may require calling multiple tools in sequence, using the output of one tool as the input to another. In such a case, Claude will call one tool at a time. If prompted to call the tools all at once, Claude is likely to guess parameters for tools further downstream if they are dependent on tool results for tools further upstream.


By default, Claude 3 Opus is prompted to think before it answers a tool use query to best determine whether a tool is necessary, which tool to use, and the appropriate parameters. Claude 3 Sonnet and Claude 3 Haiku are prompted to try to use tools as much as possible and are more likely to call an unnecessary tool or infer missing parameters. To prompt Sonnet or Haiku to better assess the user query before making tool calls, the following prompt can be used:


Answer the user's request using relevant tools (if they are available). Before calling a tool, do some analysis within \\ tags. First, think about which of the provided tools is the relevant tool to answer the user's request. Second, go through each of the required parameters of the relevant tool and determine if the user has directly provided or given enough information to infer a value. When deciding if the parameter can be inferred, carefully consider all the context to see if it supports a specific value. If all of the required parameters are present or can be reasonably inferred, close the thinking tag and proceed with the tool call. BUT, if one of the values for a required parameter is missing, DO NOT invoke the function (not even with fillers for the missing params) and instead, ask the user to provide the missing parameters. DO NOT ask for more information on optional parameters if it is not provided.


When you use tools, we also automatically include a special system prompt for the model which enables tool use. The number of tool use tokens required for each model are listed below (excluding the additional tokens listed above):


For the safety assessment of food enzyme applications seeking authorisation in the EU, EFSA has been developing a tool to estimate the exposure to food enzymes when applied in one or more food manufacturing processes.


Food enzyme applicants will be the main users of the tool, which will enable them to calculate the dietary exposure to food enzymes autonomously, but it can also be used by other food business operators as well as risk managers and risk assessors.


Food enzymes are used for technical purposes in the production of foods. Dietary exposure is an integral part of the risk assessment of food enzymes, and it cannot be estimated by multiplying the enzyme use level directly with food consumption data. Therefore, tracing food enzymes through the food chain has been a major challenge.


To overcome this obstacle, in 2023, EFSA compiled a catalogue of food groups and technical factors that are specific to 40 food manufacturing processes in which food enzymes are used. This catalogue enables the estimation of food enzyme intake by gathering data from the European Food Consumption Database . Following the release of FEIM calculators for each food manufacturing process, EFSA has now developed an integrated Food Enzyme Intake Model (FEIM) web tool.


EFSA invites all interested parties to express their interest in taking part as beta users in the testing phase, as well as in the in-person focus group, by filling in the form below. The deadline to express interest in participation during the two engagement windows is 23 February 2024 (extended deadline).


os.system is not the best way to run another process, that's what the subprocess module is for. However, I wouldnt reccommend this for running python scripts, It's much easier and more flexible to turn your script into a module, i.e wrap your script in a function, import the module, then call the function. Can't go into detail as I'm typing this on my phone.


the issue with wrapping my 2nd script into a function is the execution of this 2nd script sends automated emails to a list of users. The library (SMTPlib) for some reason NEVER works inside AcMAP or PRO. It always fails. My only work around was to separate the email function into a standalone .py file outside of the tool and have it called from within the toolbox script.

3a8082e126
Reply all
Reply to author
Forward
0 new messages