チャットを AI プロバイダーに接続します。
TsgcChatAIProvider_AIChat は TsgcChatAI バインディングを sgcWebSockets の TsgcAIChat に接続します。Provider を変更すると、Anthropic、Gemini、DeepSeek、Ollama、Grok、Mistral を使えます。
このコードには、All-Access に含まれる sgcWebSockets が必要です。チームチャットのリレーと C# 版
uses
SysUtils, Classes,
// sgcWebSockets
sgcAI, sgcAI_Chat,
// sgc
sgcChat_AI, sgcChatWS_AI;
procedure UseOpenAI(aAI: TsgcChatAI; const aApiKey: string);
var
oChat: TsgcAIChat;
oProvider: TsgcChatAIProvider_AIChat;
begin
oChat := TsgcAIChat.Create(aAI.Owner);
oChat.Provider := aicpOpenAI;
oChat.ChatOptions.ApiKey := aApiKey;
oChat.ChatOptions.Model := 'gpt-6-luna';
oProvider := TsgcChatAIProvider_AIChat.Create(aAI.Owner);
oProvider.Chat := oChat;
aAI.Model := oChat.ChatOptions.Model;
aAI.Provider := oProvider;
end;