mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 05:38:25 +02:00
aissist: nicer unit names
This commit is contained in:
parent
7fa47dc222
commit
f84357df08
@ -90,7 +90,7 @@ Type
|
||||
function CreatePromptRequest(const aModel,aPrompt : string; aMaxResponseLength : Cardinal) : TJSONData; virtual; abstract;
|
||||
// All URLS are relative to the base URL, they MUST NOT start with /
|
||||
function GetAIURL(aURL : TAiUrl) : String; virtual; abstract;
|
||||
class function protocolname : string; virtual;
|
||||
class function ProtocolName : string; virtual;
|
||||
class function DefaultURL : String; virtual;
|
||||
property Client : TCustomAIClient Read FClient;
|
||||
end;
|
||||
@ -217,7 +217,7 @@ begin
|
||||
FClient:=aClient;
|
||||
end;
|
||||
|
||||
class function TAIProtocol.protocolname: string;
|
||||
class function TAIProtocol.ProtocolName: string;
|
||||
begin
|
||||
Result:=ClassName;
|
||||
end;
|
||||
@ -487,7 +487,7 @@ begin
|
||||
CheckServerURL;
|
||||
json:=Nil;
|
||||
try
|
||||
// Writeln('Response: ',aResponse.Response.GetContentAsString);
|
||||
//Writeln('Response: ',aResponse.Response.GetContentAsString);
|
||||
JSON:=GetJSON(aResponse.Response.GetContentAsString);
|
||||
if Protocol.ResponseToPromptResponses(JSON,lResponses) then
|
||||
begin
|
||||
|
@ -12,7 +12,7 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
unit janai_v1;
|
||||
unit JanAI_V1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
@ -20,10 +20,8 @@ interface
|
||||
|
||||
uses SysUtils, Classes, fpJSON;
|
||||
|
||||
|
||||
Type
|
||||
|
||||
|
||||
{ -----------------------------------------------------------------------
|
||||
TMessageItem
|
||||
-----------------------------------------------------------------------}
|
||||
|
@ -19,12 +19,10 @@ unit JanAIProtocol;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, aiclient, fpjson;
|
||||
Classes, SysUtils, fpjson, AIClient, JanAI_V1;
|
||||
|
||||
type
|
||||
|
||||
{ TJanAIServer }
|
||||
|
||||
{ TJanAIServerProtocol }
|
||||
|
||||
TJanAIServerProtocol = Class(TAIProtocol)
|
||||
@ -33,18 +31,15 @@ type
|
||||
function ResponseToPromptResponses(aResponse: TJSONData; out Responses: TPromptResponseArray): boolean; override;
|
||||
function ResponseToModels(aResponse: TJSONData; out Models: TModelDataArray): boolean; override;
|
||||
function GetAIURL(aURL: TAIURL): String; override;
|
||||
class function protocolname : string; override;
|
||||
class function ProtocolName : string; override;
|
||||
class function DefaultURL : String; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses janai_v1;
|
||||
|
||||
{ TJanAIServerProtocol }
|
||||
|
||||
|
||||
class function TJanAIServerProtocol.protocolname: string;
|
||||
class function TJanAIServerProtocol.ProtocolName: string;
|
||||
begin
|
||||
Result:='JanAI';
|
||||
end;
|
||||
@ -54,7 +49,6 @@ begin
|
||||
Result:='http://localhost:1337/v1/';
|
||||
end;
|
||||
|
||||
|
||||
function TJanAIServerProtocol.ResponseToModels(aResponse: TJSONData; out Models: TModelDataArray): boolean;
|
||||
|
||||
var
|
||||
|
@ -18,8 +18,8 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Math, Forms, Dialogs,
|
||||
// ide
|
||||
SrcEditorIntf, IDEOptionsIntf, IDEOptEditorIntf, BaseIDEIntf, LazIDEintf, IDEHelpIntf, IDEDialogs,
|
||||
LazConfigStorage, LazLoggerBase, CodeCache, CodeTree, CodeToolManager, PascalParserTool,
|
||||
SrcEditorIntf, IDEOptEditorIntf, BaseIDEIntf, LazIDEintf, IDEHelpIntf, IDEDialogs,
|
||||
LazConfigStorage, LazLoggerBase, CodeTree, CodeToolManager, PascalParserTool,
|
||||
PascalReaderTool,
|
||||
// aissist
|
||||
AIClient, JanAIProtocol,
|
||||
@ -206,7 +206,7 @@ begin
|
||||
if Node<>nil then
|
||||
ProcNode:=Node;
|
||||
|
||||
Src:=Tool.ExtractNode(ProcNode,[]);
|
||||
Src:=copy(Tool.Src,ProcNode.StartPos,ProcNode.EndPos-ProcNode.StartPos);
|
||||
debugln(['TAIssistController.FPDocEditorInsertTextClick ProcNode: Start=',Tool.CleanPosToStr(ProcNode.StartPos),' [',NodePathAsString(ProcNode),'] Src={',Src,'}']);
|
||||
|
||||
aForm:=TAissistFPDocEditDlg.Create(nil);
|
||||
|
@ -7,7 +7,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
// aissist
|
||||
AIClient, StrAIssist, FrmAixplain;
|
||||
AIClient, FrmAixplain, LazLoggerBase;
|
||||
|
||||
const
|
||||
SDescribeProcPrompt = 'Explain the following function in one sentence:';
|
||||
@ -17,7 +17,7 @@ type
|
||||
{ TAIssistFPDocEditDlg }
|
||||
|
||||
TAIssistFPDocEditDlg = class(TAIxplainForm)
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); override;
|
||||
procedure FormCreate(Sender: TObject); override;
|
||||
procedure OKButtonClick(Sender: TObject);
|
||||
protected
|
||||
@ -77,6 +77,7 @@ begin
|
||||
Description:=''
|
||||
else
|
||||
Description:=aResponses[0].Response;
|
||||
DebugLn(['TAIssistFPDocEditDlg.HandleAIResponse Description="',Description,'"']);
|
||||
end;
|
||||
|
||||
function TAIssistFPDocEditDlg.Describe(aAIClient: TAIClient; const Src: string; out
|
||||
|
Loading…
Reference in New Issue
Block a user