Page 1 of 1

Agent AI to document code

Posted: Thu Jan 16, 2025 5:48 pm
by Antonio Linares
agentdoc.prg

Code: Select all | Expand

#include "FiveWin.ch"

REQUEST DBFCDX

function Main()

   local aFiles := Directory( "c:\fwh\source\classes\*.prg" )
   local oChat  := TDeepSeek():New(), aFile
   local cPrompt := "document this code, explaining what this Class is about," + ;
                    " listing all the DATAs and METHODs," + ;
                    " and providing a brief description of each of them. Code:"

   DbCreate( "classes.dbf", { { "name", "C", 15, 0 }, { "docs", "M", 10, 0 } }, "DBFCDX" )
   USE classes

   for each aFile in aFiles
      MsgRun( "documenting " + aFile[ 1 ],;
              "please wait...", { || oChat:Send( cPrompt + ;
              hb_memoRead( "c:\fwh\source\classes\" + aFile[ 1 ] ) ) } ) 

      DbAppend()
      classes->name := aFile[ 1 ]
      classes->docs := oChat:GetValue()
   next
   
   GO TOP
   XBrowse()

return nil

Re: Agent AI to document code

Posted: Thu Jan 16, 2025 7:35 pm
by Otto
Dear Antonio,
and the challenge afterward is to manage this information.

I have been working on a comprehensive DMS for a long time. That’s why I often contribute opinions suggesting that the filesystem serves as a database and some form of DBFs as content directories.
I cannot imagine that the data volumes generated by AI will work in the future by being imported into SQL and analyzed through SQL queries.

Best regards,
Otto

Re: Agent AI to document code

Posted: Fri Jan 17, 2025 3:03 am
by Lailton
Does it works?

:shock:
Antonio Linares wrote: Thu Jan 16, 2025 5:48 pm agentdoc.prg

Code: Select all | Expand

#include "FiveWin.ch"

REQUEST DBFCDX

function Main()

   local aFiles := Directory( "c:\fwh\source\classes\*.prg" )
   local oChat  := TDeepSeek():New(), aFile
   local cPrompt := "document this code, explaining what this Class is about," + ;
                    " listing all the DATAs and METHODs," + ;
                    " and providing a brief description of each of them. Code:"

   DbCreate( "classes.dbf", { { "name", "C", 15, 0 }, { "docs", "M", 10, 0 } }, "DBFCDX" )
   USE classes

   for each aFile in aFiles
      MsgRun( "documenting " + aFile[ 1 ],;
              "please wait...", { || oChat:Send( cPrompt + ;
              hb_memoRead( "c:\fwh\source\classes\" + aFile[ 1 ] ) ) } ) 

      DbAppend()
      classes->name := aFile[ 1 ]
      classes->docs := oChat:GetValue()
   next
   
   GO TOP
   XBrowse()

return nil

Re: Agent AI to document code

Posted: Fri Jan 17, 2025 8:24 am
by Antonio Linares
Yes! :D

Image

Re: Agent AI to document code

Posted: Fri Jan 17, 2025 11:15 pm
by Antonio Linares
Image

Re: Agent AI to document code

Posted: Fri Jan 17, 2025 11:16 pm
by Antonio Linares
agentdoc2.prg is a new example using AI included in next FWH build soon to be published :)