Problem with TMSFNCCloudAI on Mac, cannot find hostname?

I am attempting to run the FMXFNCCloudAIDemo deployed to a macOS, but for any of the AI services I keep getting the same error message:

HTTP eddor code: 0
A server with the specified hostname could not be found

I have created and entered API keys for Gemini, Claude, Grok, OpenAI, Mistral and DeepSeek, but all of them produce the same error on a Mac

but, it works fine when deployed on a Windows.

I have tried stepping through the debugger, but cannot seem to find the issue. I have also tried deploying out to a mac with version 15.5 OS and still getting this issue.

I have the latest FNC cloud pack installed, version 3.5.0.0. and the lastest core installed.

has anyone got the TTMSFNCCloudAI component working on a Mac?

I have a feeling it has something to do with SSL dylib files or something, but I can't seem to figure it out.

Dave

Hi,

We have been able to reproduce this and applied a patch.
Next version of the TMS FNC Cloud Pack will address this. It was related to incorrect defined paths.

In the mean time, you can fix the code yourself:

  cHostClaude = 'https://api.anthropic.com';
  cPathClaude = '/v1/messages';
  cHostGrok = 'https://api.x.ai';
  cPathGrok = '/v1/chat/completions';
  cHostGemini = 'https://generativelanguage.googleapis.com';
  cPathGemini = '/v1beta/models/';
  cHostOpenAI_EU = 'https://eu.api.openai.com';
  cHostOpenAI_Default = 'https://api.openai.com';
  cPathOpenAI = '/v1/responses';
  cHostPerplexity = 'https://api.perplexity.ai';
  cPathPerplexity = '/chat/completions';
  cPathOllama = '/api/chat';
  cHostMistral = 'https://api.mistral.ai';
  cPathMistral = '/v1/chat/completions';
  cHostDeepSeek = 'https://api.deepseek.com';
  cPathDeepSeek = '/chat/completions';

Yes, I thought the same thing. I also tried adding the extra slashes in the paths, but that still doesn't fix the issue on a Mac. I am still getting the same error message that the hostname is not found?

I even tried this:

case Service of
    aiOpenAI:
      begin
        //if Settings.OpenAIServers = oaDefault then
          //ARequest.Host := cHostOpenAI_Default
        //else
          //ARequest.Host := cHostOpenAI_EU;

        //ARequest.Path := cPathOpenAI;
        

        ARequest.Host := 'https://api.openai.com';
        ARequest.Path := '/v1/responses';
        ARequest.AddHeader(cHeaderAuthorization, cHeaderAuthorizationValue + GetAPIKey);
      end;
    aiGemini:

what is even more strange, I created a very simple app with a memo and 2 buttons .. one button uses the TMSFNCCloudAI component like this:

procedure TForm1.Button3Click(Sender: TObject);
begin
  TMSFNCCloudAI1.Context.Text := Memo2.Lines.Text;
  TMSFNCCloudAI1.Execute();
end;

procedure TForm1.TMSFNCCloudAI1Executed(Sender: TObject;
  AResponse: TTMSFNCCloudAIResponse; AHttpStatusCode: Integer;
  AHttpResult: string);
begin
  Memo1.Lines.Text := AHttpResult;
end;

and I keep getting the same error when deploying the app to MacOS

but, the following procedure works fine on a Mac , and its also using the TTMSFNCCloudBase to get data from the endpoint:

procedure TForm1.Button4Click(Sender: TObject);
var
  FCloudBase: TTMSFNCCloudBase;
  json, apiKey: string;
begin
  apiKey := 'OPEN_API_KEY_HERE';
  Memo1.Lines.Clear;

  FCloudBase := TTMSFNCCloudBase.Create(nil);
  try
    with FCloudBase.Request do
    begin
      Host := 'https://api.openai.com';
      Path := '/v1/responses';
      AddHeader('Content-Type','application/json');
      AddHeader('Authorization','Bearer '+apiKey);
      PostData := '{"model":"gpt-4o","input":[{"role":"user","content":"What do you know about Delphi Firemonkey?"}],"tools":[],"temperature":0,"max_output_tokens":null}';
      Method := rmPOST;
    end;

    FCloudBase.ExecuteRequest(
      procedure(const ARequestResult: TTMSFNCCloudBaseRequestResult)
      begin
        Memo1.Lines.Text := ARequestResult.ResultString;
      end,
      nil,
      False
    );
  finally
    FCloudBase.Free;
  end;
end;

Why would the second procedure work, but the TMSFNCCloudAI still doesn't even when adding the extra slash to the path?

We've tested the cloud ai component here, and couldn't see an issue after fixing the paths. We'll release an update this week, maybe you can try again after the update.

I wish I could get it working on a Mac. i tried uninstalling/re-installing the cloud components, applying the simple patch. I tried Delphi 11, and Delphi 12.3, I tried deploying to 2 different Mac computers, one is version 11.7.10 and the other version 15.5. no matter what I do, I always get that same message "A server with the specified hostname could not be found"

but it works fine on windows

is there anything else you can think of? I've already gone down the ChatGPT rabbit hole for 2 days with no luck lol, tried endless things

Ok, I was able to get your patch to finally work .. here is what I did, just in case someone else runs into this issue:

step 1: close Delphi 12.3
step 2: delete the "OSX64" folder from my project folder
step 3: made a copy of the FMX.TMSFNCCloudAI.pas file, applied the patch, and pasted that file into my project folder
step 4: start delphi, and deploy to mac .. and it now works

so .. things should be good once the new updates are released so I don't have to put the file in my project folder.

thanks for the help

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.