This means that you can use the AI engine that http://www.phind.com provides without having to register and free.
This is the first working version. Next we will implement it as a dialogbox. This is great news as we want FWH to provide
a powerfull autoGPT functionality from your apps...
phind.prg
- Code: Select all Expand view
- #include "FiveWin.ch"
function Main()
local oHttp := CreateObject( "MSXML2.ServerXMLHTTP.6.0")
local cUrl := "https://www.phind.com/api/infer/creative"
local cQuestion := "tell me a zen advice"
local cLine, cAnswer := ""
local hData := { ;
"question" => cQuestion,;
"codeContext" => "",;
"options" => { ;
"skill" => "intermediate",;
"date" => "14/04/2023",;
"language" => "en-GB",;
"detailed" => 'False',;
"creative" => 'True';
} }
oHttp:SetTimeouts( 30000, 30000, 30000, 30000 )
oHttp:Open( "POST" , cUrl , .F. )
oHttp:SetRequestHeader( "Content-Type", "application/json" )
oHttp:SetRequestHeader( "Accept","*/*" )
oHttp:SetRequestHeader( "Accept-Language", "en-GB,en-US;q=0.9,en;q=0.8" )
oHttp:SetRequestHeader( "Origin", "https://www.phind.com" )
oHttp:SetRequestHeader( "Referer", "https://www.phind.com/search?q=Go+vs+Rust+vs+C%2B%2B&c=&source=searchbox&init=true" )
oHttp:SetRequestHeader( "sec-ch-ua", '"Chromium";v="112", "Google Chrome";v="112",";Not A Brand";v="99"' )
oHttp:SetRequestHeader( "sec-ch-ua-mobile", "?0" )
oHttp:SetRequestHeader( "Connection", "keep-alive" )
oHttp:SetRequestHeader( "sec-ch-ua-platform", "macOS" )
oHttp:SetRequestHeader( "sec-fetch-dest", "empty" )
oHttp:SetRequestHeader( "sec-fetch-mode", "cors" )
oHttp:SetRequestHeader( "sec-fetch-site", "same-site" )
oHttp:SetRequestHeader( "Cookie", "__cf_bm = " )
oHttp:SetRequestHeader( "Cookie", "mp__mixpanel = " )
oHttp:Send( hb_jsonEncode( hData, .T. ) )
for each cLine in oHttp:responseText
cAnswer += StrTran( cLine, Chr( 10 ), "" )
next
cAnswer = StrTran( cAnswer, "data: ", "" )
cAnswer = StrTran( cAnswer, " ", " " )
FW_memoEdit( cAnswer )
return nil