FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Habla con tu database usando lenguaje natural
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Habla con tu database usando lenguaje natural
Posted: Sun Jan 12, 2025 06:53 AM
Recientemente hemos usado una herramienta que permite hablarle a vuestra base de datos usando lenguaje natural gracias a la IA.

Asi que vamos a implementar la misma funcionalidad usando FWH y las clases de IA en FWH.

Esto es un Agente IA auténtico y es un gran ejemplo de lo que permite hacer el poder de la IA :)

Estad atentos... :wink:
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Habla con tu database usando lenguaje natural
Posted: Sun Jan 12, 2025 09:28 AM
Ejemplo funcionando:

Usando esta simple técnica podemos hablar con cualquier base de datos usando lenguaje natural! :D

agentdb.prg
#include "FiveWin.ch"

function Main()

   local oChat := TDeepSeek():New()
   local dummy := FW_SetUnicode( .T. )
   local cDatabase := "foros_antiguos"
   local oCn   := maria_Connect( "localhost," + cDatabase + ",fivetec1_antonio,1234", .T. )
   local aTables, cTable
   local hDatabase := { => }, cJson

   if oCn == nil
      MsgAlert( "Error connecting to database" )
      return nil 
   endif   

   aTables = oCn:ListBaseTables()

   for each cTable in aTables
      hDatabase[ cTable ] = oCn:ListColumns( cTable ) 
   next   

   oChat:Send( "tell me the SQL sentence to list the 10 more active users in the forums using this info," + ;
               " give me the SQL sentence, no explanations. Remove the '''SQL from the beginning and the ''' from the end: " + ;
               hb_jsonEncode( hDatabase ) )
   XBrowser( oCn:Execute( oChat:GetValue() ) )

   oChat:End()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Habla con tu database usando lenguaje natural
Posted: Sun Jan 12, 2025 06:31 PM

Master:

Wow

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero

Continue the discussion