Skip to content

Missing 'tool_call_id' value in function TChatParams.Messages #54

Open
@teraui91

Description

@teraui91

Thank you for your great component.
Following is an error message wehn I using function call in Azure ChatGPT 4o recently.

Missing parameter 'tool_call_id': messages with role 'tool' must have a 'tool_call_id'

Here my suggestion to resolve the issue and kindly help to resolve it.

unit OpenAI.Chat;

function TChatParams.Messages(const Value: TArray<TChatMessageBuild>): TChatParams;
begin
  Items := TJSONArray.Create;
  try
    for Item in Value do
    begin
      JSON := TJSONObject.Create;
      JSON.AddPair('role', Item.Role.ToString);
     .
     .
     //add "tool_call_id" values
     if not Item.ToolCallId.IsEmpty then
        JSON.AddPair('tool_call_id', Item.ToolCallId);
     .
     .
  finally
  end;
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions