|
ONLINE REPOSITORYFOR WINDEV, WEBDEV AND WINDEV MOBILE
  |
| |
| | |
Exemplo WINDEV consumindo Api do ChatGpt com Wlanguage, pode ser usado no WEBDEV e no mobile o mesmo código |
|
|
Exemplo WINDEV consumindo Api do ChatGpt com Wlanguage, pode ser usado no WEBDEV e no mobile o mesmo código
CODIGO EXEMPLO ************************
// Summary: <specify the procedure action> // Syntax: //[ <Result> = ] EnviarMensagem (<Questao> is string) // // Parameters: // // Questao (ANSI string): // // MyRequest..Header[array_Header[1].nome_parametro] = array_Header[1].valor_parametro // // MyRequest..Header[array_Header[2].nome_parametro] = array_Header[2].valor_parametro
// Example: // <Specify a usage example> // PROCEDURE EnviarMensagem(Questao is ANSI string)
HourGlass(True)
IF Questao = "" THEN Info("Importante informar uma pergunta?") RESULT False ELSE MyRequest is httpRequest url is string = "https://api.openai.com/v1/completions" sua_chave_de_api is string = "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" Pergunta is string = [ { "model": "text-davinci-003", "prompt": "[%Questao%]", "max_tokens": 3000, "temperature": 0.5 } ] MyRequest..URL = url MyRequest..Content = Pergunta MyRequest..Timeout = 280s MyRequest.ContentType = "application/json" MyRequest..Header["Authorization"] = "Bearer "+sua_chave_de_api MyRequest..Method = httpPost MyRequest..IgnoreError = httpIgnoreInvalidCertificate MyResponse is httpResponse = HTTPSend(MyRequest) IF MyResponse..StatusCode = 200 THEN vRetorno is Variant vRetorno = JSONToVariant(MyResponse..Content) resultado is string resultado = Replace(vRetorno.choices[1].text,".",".<br><br>") resultado = [ <H3><FONT FACE=Arial COLOR="#00AA00"> [%resultado%] </FONT></H3> ]
HourGlass(False) //LOG t001_chatgpt.t001_data_hora = DateSys()+TimeSys() t001_chatgpt.t001_pergunta = EDT_Questão t001_chatgpt.t001_resposta = resultado HAdd(t001_chatgpt) RESULT resultado ELSE HourGlass(False) RESULT ErrorInfo() +" - "+ HErrorInfo() END END
|
| |
| |
| Illustrations, screen shots |
|
| |
(To evaluate this resource, click 'Write a review') |
| | | |
No review or comment? Be the first one! |
CÓDIGO AJUSTADO POR MARCILON |
| OUTROS ASSUNTOS
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/4064-exemplo-windev-consumindo-api-chatgpt-com-wlanguage-pode/read.awp |
| | |
|
WINDEV, WEBDEV, WINDEV Mobile |
| | | | | | | |
| |
|
|
|