Jump to content

OpenAI GPT 4.0 API (or 3.5) - base code


KillaH229
 Share

Go to solution Solved by KillaH229,

Recommended Posts

Hello

I'm excited to share a piece of code with you that I've been working on. This code uses the GPT-4 api language model from OpenAI to correct German translations based on Dutch (nl-be) source texts. It can be especially helpful for those who are translating content between these languages or need to ensure the accuracy of translations.

 

Here's an overview of what the code does:

  • It uses the GPT-4 model from the OpenAI API to process the input text.
  • The input consists of a Dutch source text, its German translation, and a prompt to correct the translation.
  • It sends an HTTP POST request to the OpenAI API with the required headers and data.
  • The code receives a JSON response from the API, which includes the corrected German translation.

 

#include <InetConstants.au3>
#include <Date.au3>
#include <File.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>
#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <WinHttp.au3>
#include <WinHttpConstants.au3>
#include <Json.au3>
#include <WinAPISys.au3>
#include <WinAPIConv.au3>
#include <WinAPILocale.au3>
#include <Array.au3>
#include <String.au3>
#include <WinAPIConv.au3>
#include <XMLWrapperEx.au3>

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

;~  You can use this when the function ProcessWithGPT would have a loop in it. This way if the api fails, it tries again after 60 seconds.
;~  if $Go = 1 then
;~      If TimerDiff($iTimer) >= 60000 Then
;~          $iTimer = TimerInit()
;~          If Not $bFunctieActief Then
;~              $bFunctieActief = True
;~              ConsoleWrite(@CRLF & "Restart!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" & @CRLF)
;~              sleep(60000)
;~              ProcessWithGPT()
;~          EndIf
;~      EndIf
;~  EndIf
WEnd

Func ProcessWithGPT()
    $bFunctieActief = True

    $bron = "Zelf chape leggen met Staenis"
    $taal = "de"
    $vertaling = "Estrich selbst verlegen mit Staenis"

    Local $sPrompt = "Source text (Dutch, nl-be): " & $bron & " (" & $taal & "): " & $vertaling
    $sPrompt = EncodeAnchorTags($sPrompt)

    $opdracht = "Correct the German translation based on the Dutch (nl-be) source text, just make sure that the corrected translation is displayed."

    Local $iLength = StringLen($opdracht & $sPrompt)
    If $iLength > 4096 Then
        MsgBox(0, "error", "Te lang", 1)
        Return
    EndIf

    ; Store your API key and OpenAI organization key in a variable
    Local $api_key = ""
    Local $OpenAIOrganization = ""

    ; Create the WinHttpRequest object
    Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")

    ; Open a POST request to the OpenAI API
    $oHTTP.Open("POST", "https://api.openai.com/v1/chat/completions", False)

    ; Set the headers for the request
    $oHTTP.SetRequestHeader("Content-Type", "application/json; charset=UTF-8")
;~  $oHTTP.SetRequestHeader("Content-Type", "application/json")
    $oHTTP.SetRequestHeader("Authorization", "Bearer " & $api_key)
    $oHTTP.SetRequestHeader("OpenAI-Organization", $OpenAIOrganization)

;~  ConsoleWrite('{"model": "gpt-4", "temperature": 0, "messages":[{"role": "system", "content": "' & $opdracht & '"}, {"role": "user","content": "' & $sPrompt & '"}]}')
    ConsoleWrite("{""model"": ""gpt-4"", ""temperature"": 0, ""messages"":[{""role"": ""system"", ""content"": " & Chr(34) & StringReplace($opdracht, Chr(34), "\" & Chr(34)) & Chr(34) & "}, {""role"": ""user"", ""content" & Chr(34) & ": " & Chr(34) & StringReplace($sPrompt, Chr(34), "\" & Chr(34)) & Chr(34) & "}]}")

    $oHTTP.SetTimeouts("130000", "130000", "130000", "130000")

    ; Try sending the HTTP request
;~  $oHTTP.Send('{"model": "gpt-4", "temperature": 0, "messages":[{"role": "system", "content": "' & $opdracht & '"}, {"role": "user","content": "' & $sPrompt & '"}]}')
    $oHTTP.Send("{""model"": ""gpt-4"", ""temperature"": 0, ""messages"":[{""role"": ""system"", ""content"": " & Chr(34) & StringReplace($opdracht, Chr(34), "\" & Chr(34)) & Chr(34) & "}, {""role"": ""user"", ""content" & Chr(34) & ": " & Chr(34) & StringReplace($sPrompt, Chr(34), "\" & Chr(34)) & Chr(34) & "}]}")

    If (@error) Then
        ConsoleWrite("Error: An error occurred while sending the HTTP request." & @CRLF)
        $bFunctieActief = False
        Return SetError(2, 0, 0)
    EndIf

    ; Waiting for a response from the server
    $oHTTP.WaitForResponse("130000")

    ; Check the status code of the HTTP request
    If ($oHttp.Status <> $HTTP_STATUS_OK) Then
        ConsoleWrite("Error: The HTTP request failed with status code " & $oHttp.Status & "." & @CRLF)
    EndIf

    ; Get the response text
    Local $sResponse = $oHTTP.ResponseText

    $sResponse = BinaryToString($oHTTP.ResponseBody, 4)

    ; Decode the JSON response to an AutoIt variable
    Local $oJsonResponse = Json_Decode($sResponse)

    ConsoleWrite("JSON-respons: " & $sResponse)

    ; Verify that JSON decoding has been done correctly
    If Not Json_IsObject($oJsonResponse) Then
        ConsoleWrite(@CRLF & "Error: JSON response cannot be decoded." & @CRLF)
        $bFunctieActief = False
        Return
    EndIf

    ; Remove the "choices" property from the JSON response
    Local $aChoices = Json_ObjGet($oJsonResponse, "choices")

    ; Check that the property was retrieved correctly
    If @error Then
        ConsoleWrite(@CRLF & "Error: Cannot extract the choices from the JSON response." & @CRLF)
        ConsoleWrite("JSON-respons: " & $sResponse & @CRLF)
        If StringInStr($sResponse, "That model is currently overloaded with other requests.") Then
            $retry += 1
            ConsoleWrite("Server error detected, retry in 1 minute...." & @CRLF)
        Else
            $bFunctieActief = False
            Return
        EndIf
    EndIf

    ; Check for choices
    If UBound($aChoices) = 0 Then
        ConsoleWrite("Error: No choices are present in the JSON response." & @CRLF)
        ConsoleWrite("JSON-respons: " & $sResponse & @CRLF)
        $bFunctieActief = False
        Return
    EndIf

    ; Get the text from the "message" object of the first choice
    Local $oFirstChoiceMessage = Json_ObjGet($aChoices[0], "message")
    Global $sText = Json_ObjGet($oFirstChoiceMessage, "content")

    $sText = DecodeAnchorTags($sText)

    ; Get the response text
    ConsoleWrite(@CRLF & "Generated response: " & $sResponse & @CRLF)
    ConsoleWrite(@CRLF & "Generated text: " & $sText & @CRLF)

    $bFunctieActief = False
EndFunc

Func EncodeAnchorTags($sText)
    ; This is something i need to keep links alive in the resource files
    $sText = StringReplace($sText, "} '", "}'")
    $sText = StringReplace($sText, "' {", "'{")
    For $i = 0 To 9
        $sText = StringReplace($sText, "<a href='{" & $i & "}'>", "(" & $i & $i & $i & ")")
        $sText = StringReplace($sText, "</a>", "(" & $i & $i & ")")
    Next
    Return $sText
EndFunc

Func DecodeAnchorTags($sEncodedText)
    ; This is something i need to keep links alive in the resource files
    For $i = 0 To 9
        $sEncodedText = StringReplace($sEncodedText, "(" & $i & $i & $i & ")", "<a href='{" & $i & "}'>")
        $sEncodedText = StringReplace($sEncodedText, "(" & $i & $i & ")", "</a>")
    Next
    Return $sEncodedText
EndFunc

Func ReplaceSpecialChars($sText)
    $sText = StringReplace($sText, "'", "\'")
    $sText = StringReplace($sText, '"', '\"')
    $sText = StringReplace($sText, '„', '\"')
    $sText = StringReplace($sText, '‘', "\'")
    $sText = StringReplace($sText, '’', "\'")
    $sText = StringReplace($sText, '“', '\"')
    Return $sText
EndFunc

 

Please note that you will need to obtain an API key and an OpenAI organization key to use this code. Replace the empty strings in the following lines with your keys:

Local $api_key = ""
Local $OpenAIOrganization = ""

 

You may also need to install some necessary AutoIt libraries (such as Json.au3) to use the code successfully.

 

Feel free to use, modify, or share this code as needed. If you have any questions or suggestions, please don't hesitate to reply to this thread. I hope you find this code helpful!

 

Best regards,

KillaH229

Edited by KillaH229
Link to comment
Share on other sites

  • KillaH229 changed the title to OpenAI GPT 4.0 API (or 3.5) - base code
  • Solution

Update using _WinHttp UDF (#include <WinHttp.au3> and #include <WinHttpConstants.au3> from 2020):  
 

Func VerwerkOutput1()
    $hOpen = _WinHttpOpen()
    If Not $hOpen Then ConsoleWriteError("Error when calling _WinHttpOpen. Error code: " & @error & @CRLF)

    For $i = 0 To _GUICtrlListView_GetItemCount($ListView1)
        $IDthread = _GUICtrlListView_GetItemText($ListView1, $i, 0)
        $Input = _GUICtrlListView_GetItemText($ListView1, $i, 1)
        $Output1 = _GUICtrlListView_GetItemText($ListView1, $i, 2)
        $Output2 = _GUICtrlListView_GetItemText($ListView1, $i, 3)

        If $IDthread <> "" and $Output2 = "" Then
            ProcessWithGPT($IDthread, $Input, $Output1, $i)
        EndIf
    Next
EndFunc

Func ProcessWithGPT($IDthread, $Input, $Output1, $i)
    $Lengte2 = " Oké "

    Local $sSelectQuery = "SELECT COUNT(*) FROM gegevens WHERE IDthread = " & _SQLite_FastEscape($IDthread) & ";"

    Local $aResult, $iRows, $iColumns
    _SQLite_GetTable2D($hDb, $sSelectQuery, $aResult, $iRows, $iColumns)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!3")
    EndIf

    $sPromptx = StringreplacePrompt($Output1)

    $sPrompt = Json_Encode($sPromptx)

    $opdracht = "Combine all customer question emails into 1 single, overarching question and provide a comprehensive response. Avoid printing customers' personal information or contact information. Use Question: and Answer: as labels."

    Local $iLength = StringLen($opdracht & $sPrompt)
    If $iLength < 8000 Then
    Else
        MsgBox(0, "GPT error", "Te lang", 1)
        $Lengte2 = " Te lang "
        Return
    EndIf

    $GPTversion = "GPT"
    $sReturned = WinHttpApi($opdracht, $sPrompt, $Lengte2, $GPTversion)

    if $sReturned <> "" then
        ; Get the response text
        $Smalleretekst = StringStripWS($sReturned, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
        ConsoleWrite("GPT Response2: " & $Smalleretekst & @CRLF)

        _GUICtrlListView_BeginUpdate($ListView1)

        _GUICtrlListView_AddSubItem($ListView1, $i, $sReturned, 3)

        _GUICtrlListView_EndUpdate($ListView1)

        ; Save the data to the SQLite database
        UpdateListViewDataInSQLite($IDthread, $Input, $Output1, $sReturned)

        $iTokensUsed += $iTokens ; Add the number of tokens to the total
        WinSetTitle($Form1, "", "Database v2 - Tokens used: " & $iTokensUsed)

        _GUICtrlListView_SetItemSelected ( $ListView1, $i, True)
        ToonRijTekstInEditBox()

        ConsoleWrite(@CRLF & "Sleep 5 sec - Database v2 - Tokens used: " & $iTokensUsed & @CRLF )
        sleep(5000)
        $sReturned = ""
    EndIf
EndFunc


Func WinHttpApi($opdracht, $sPrompt, $Lengte, $GPTversion)
    $sPrompt = StringReplace($sPrompt, "\/", "/")
    $sPrompt = StringReplace($sPrompt, "\n", " ")
    $sPrompt = StringReplace($sPrompt, "\u200c", "")
    $sPrompt = StringStripWS($sPrompt, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)

    $sData = ("{""model"": ""gpt-4"", ""temperature"": 0, ""messages"":[{""role"": ""system"", ""content"": " & Chr(34) & StringReplace($opdracht, Chr(34), "") & Chr(34) & "}, {""role"": ""user"", ""content" & Chr(34) & ": " & $sPrompt & "}]}")

    $iTokens = StringLen($sData)
    $iTimePassed = TimerDiff($iTimerStart) / 1000

    ; Check whether the number of tokens exceeds the limit
    If $iTokensUsed + $iTokens > $iTokenLimit Then
        Local $iWaitTime = ($iTokensUsed + $iTokens - $iTokenLimit) * 60 / $iTokenLimit
        ConsoleWrite("Sleep: " & $iWaitTime * 1000)
        Sleep($iWaitTime * 1000)
        $iTokensUsed = 0
        $iTimerStart = TimerInit()
    Else
        Sleep(5000)
    EndIf

    ConsoleWrite(@CRLF & $GPTversion & $Lengte & $sData & @CRLF)

    Local $sURL = "https://api.openai.com/v1/chat/completions"
    Local $api_key = ""
    
    _WinHttpSetTimeouts($hOpen, 900000, 900000, 900000, 900000)

    Local $hConnect = _WinHttpConnect($hOpen, $sURL)
    If Not $hConnect Then ConsoleWriteError("Error when calling _WinHttpConnect. Error code: " & @error & @CRLF)

    Local $hRequest = _WinHttpOpenRequest($hConnect, "POST", "/v1/chat/completions", Default, Default, Default, $WINHTTP_FLAG_SECURE)
    If Not $hRequest Then ConsoleWriteError("Error when calling _WinHttpOpenRequest. Error code: " & @error & @CRLF)


    ; Add headers
    _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/json")
    _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $api_key)
    
    If Not _WinHttpSendRequest($hRequest, -1, $sData) Then
        ConsoleWriteError("Error when calling _WinHttpSendRequest. Error code: " & @error & @CRLF)
        _WinHttpCloseHandle($hRequest)
        _WinHttpCloseHandle($hConnect)
        _WinHttpCloseHandle($hOpen)
        sleep(5000)
        $hOpen = _WinHttpOpen()
        If Not $hOpen Then ConsoleWriteError("2 Fout bij het aanroepen van _WinHttpOpen. Foutcode: " & @error & @CRLF)
        return
    EndIf

    If Not _WinHttpReceiveResponse($hRequest) Then
        ConsoleWriteError("Error when calling _WinHttpReceiveResponse. Error code: " & @error & @CRLF)
        return
    EndIf

;~  ; Get the raw headers
;~  Local $sRawHeaders = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_RAW_HEADERS_CRLF)
;~  ConsoleWrite("Ruwe headers: " & @CRLF & $sRawHeaders & @CRLF)

;~  ; Extraheer de statuscode uit de ruwe headers
;~  Local $iStatusCode = StringRegExpReplace($sRawHeaders, "^HTTP/\d\.\d\s(\d+).*$", "$1")
;~  ConsoleWrite("Status code: " & $iStatusCode & @CRLF)

    Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE)
    If @error Then
        ConsoleWriteError("Error retrieving status code. Error code: " & @error & @CRLF)
        return
    Else
;~      ConsoleWrite("Status code: " & $iStatusCode & @CRLF)
    EndIf

    ; Check for an answer
    Global $sHeader, $sReturned
    Local $iDataAvailable = _WinHttpQueryDataAvailable($hRequest)
    If $iDataAvailable Then
;~      ConsoleWrite("Number of bytes available: " & @extended & @CRLF)
        $sHeader = _WinHttpQueryHeaders($hRequest)
        Do
            $sReturned &= _WinHttpReadData($hRequest)
        Until @error
    Else
        ConsoleWriteError("!No data available. Error code: " & @error & @CRLF)
        MsgBox(48, "Failed," "No data available.",1)
        Return
    EndIf

    ; Clearing
    _WinHttpCloseHandle($hRequest)
    _WinHttpCloseHandle($hConnect)

    $sReturned = BinaryToString($sReturned, 4)

    ; Decode the JSON response to an AutoIt variable
    Local $oJsonResponse = Json_Decode($sReturned)

;~  ConsoleWrite("JSON-Returned: " & $sReturned)

    ; Verify that JSON decoding has been done correctly
    If Not Json_IsObject($oJsonResponse) Then
        ConsoleWrite(@CRLF & "Error: JSON response cannot be decoded." & @CRLF)
        _WinHttpCloseHandle($hOpen)
        sleep(10000)
        $hOpen = _WinHttpOpen()
        If Not $hOpen Then ConsoleWriteError("Error when calling _WinHttpOpen. Error code: " & @error & @CRLF)
        $bFunctieActief = False
        Return
    EndIf

    ; Remove the "choices" property from the JSON response
    Local $aChoices = Json_ObjGet($oJsonResponse, "choices")

    If @error Then
        ConsoleWrite(@CRLF & "Error: Cannot extract the choices from the JSON response." & @CRLF)
    EndIf

    ; Check for choices
    If UBound($aChoices) = 0 Then
        ConsoleWrite(@CRLF & "Error: No choices are present in the JSON response." & @CRLF)
        ConsoleWrite(@CRLF & "JSON-respons: " & $sReturned & @CRLF)
        $bFunctieActief = False
        Return
    EndIf

    ; Get the text from the "message" object of the first choice
    Local $oFirstChoiceMessage = Json_ObjGet($aChoices[0], "message")
    Global $sReturned = Json_ObjGet($oFirstChoiceMessage, "content")

    ; Implementing the answer
    Return $sReturned
EndFunc

Func StringreplacePrompt($sPromptx)
    $sPromptx = StringReplace($sPromptx, "[", " ")
    $sPromptx = StringReplace($sPromptx, "]", " ")
    $sPromptx = StringReplace($sPromptx, "mailto:", " ")
    $sPromptx = StringReplace($sPromptx, "±", " ")
    $sPromptx = StringReplace($sPromptx, '"', " ")
    $sPromptx = StringReplace($sPromptx, "'", " ")
    $sPromptx = StringReplace($sPromptx, "<", " ")
    $sPromptx = StringReplace($sPromptx, ">", " ")
    $sPromptx = StringReplace($sPromptx, "³", "3")
    $sPromptx = StringReplace($sPromptx, "²", "2")
    $sPromptx = StringReplace($sPromptx, "º", " ")
    $sPromptx = StringReplace($sPromptx, "%", " ")
    $sPromptx = StringReplace($sPromptx, "#", " ")
    $sPromptx = StringReplace($sPromptx, "ë", "e")
    $sPromptx = StringReplace($sPromptx, "é", "e")
    $sPromptx = StringReplace($sPromptx, "&", " ")
    $sPromptx = StringReplace($sPromptx, "|", " ")
    $sPromptx = StringReplace($sPromptx, "*", " ")
    $sPromptx = StringReplace($sPromptx, "à", "a")
    $sPromptx = StringReplace($sPromptx, "ç", "c")
    $sPromptx = StringReplace($sPromptx, "è", "e")
    $sPromptx = StringReplace($sPromptx, "ü", "u")
    $sPromptx = StringReplace($sPromptx, "ö", "o")
    $sPromptx = StringReplace($sPromptx, "ê", "e")
    $sPromptx = StringReplace($sPromptx, "ï", "i")
    $sPromptx = StringReplace($sPromptx, "î", "i")
    $sPromptx = StringReplace($sPromptx, "â", "a")
    $sPromptx = StringReplace($sPromptx, "ä", "a")
    $sPromptx = StringReplace($sPromptx, "ß", "ss")
    $sPromptx = StringReplace($sPromptx, "û", "u")
    $sPromptx = StringReplace($sPromptx, "×", "x")
    $sPromptx = StringReplace($sPromptx, "ù", "u")
    $sPromptx = StringReplace($sPromptx, "ô", "o")
    $sPromptx = StringReplace($sPromptx, "ÿ", "y")
    $sPromptx = StringReplace($sPromptx, "ý", "y")
    $sPromptx = StringReplace($sPromptx, "ò", "o")
    $sPromptx = StringReplace($sPromptx, "í", "i")
    $sPromptx = StringReplace($sPromptx, "õ", "o")
    $sPromptx = StringReplace($sPromptx, "ñ", "n")
    $sPromptx = StringReplace($sPromptx, "þ", "th")
    $sPromptx = StringReplace($sPromptx, "Ð", "D")
    $sPromptx = StringReplace($sPromptx, "Æ", "AE")
    $sPromptx = StringReplace($sPromptx, "Œ", "OE")
    $sPromptx = StringReplace($sPromptx, "ø", "o")
    $sPromptx = StringReplace($sPromptx, "å", "a")
    $sPromptx = StringReplace($sPromptx, "µ", "u")
    $sPromptx = StringReplace($sPromptx, "¿", " ")
    $sPromptx = StringReplace($sPromptx, "¡", " ")
    $sPromptx = StringReplace($sPromptx, "£", " ")
    $sPromptx = StringReplace($sPromptx, "€", " ")
    $sPromptx = StringReplace($sPromptx, "¥", " ")
    $sPromptx = StringReplace($sPromptx, "¢", " ")
    $sPromptx = StringReplace($sPromptx, "©", " ")
    $sPromptx = StringReplace($sPromptx, "®", " ")
    $sPromptx = StringReplace($sPromptx, "™", " ")
    $sPromptx = StringReplace($sPromptx, "§", " ")
    $sPromptx = StringReplace($sPromptx, "¶", " ")
    $sPromptx = StringReplace($sPromptx, "«", " ")
    $sPromptx = StringReplace($sPromptx, "»", " ")
    $sPromptx = StringReplace($sPromptx, "°", "y")
    $sPromptx = StringReplace($sPromptx, "~", " ")
    $sPromptx = StringReplace($sPromptx, "À", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Á", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Â", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ã", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ä", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Å", "A", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Æ", "AE", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ç", "C", 0, 1)
    $sPromptx = StringReplace($sPromptx, "È", "E", 0, 1)
    $sPromptx = StringReplace($sPromptx, "É", "E", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ê", "E", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ë", "E", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ì", "I", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Í", "I", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Î", "I", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ï", "I", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ð", "D", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ñ", "N", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ò", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ó", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ô", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Õ", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ö", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "×", "x", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ø", "O", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ù", "U", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ú", "U", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Û", "U", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ü", "U", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Ý", "Y", 0, 1)
    $sPromptx = StringReplace($sPromptx, "Þ", " ", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ß", "B", 0, 1)
    $sPromptx = StringReplace($sPromptx, "à", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "á", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "â", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ã", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ä", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "å", "a", 0, 1)
    $sPromptx = StringReplace($sPromptx, "æ", "ae", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ç", "c", 0, 1)
    $sPromptx = StringReplace($sPromptx, "è", "e", 0, 1)
    $sPromptx = StringReplace($sPromptx, "é", "e", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ê", "e", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ë", "e", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ì", "i", 0, 1)
    $sPromptx = StringReplace($sPromptx, "í", "i", 0, 1)
    $sPromptx = StringReplace($sPromptx, "î", "i", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ï", "i", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ð", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ñ", "n", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ò", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ó", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ô", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "õ", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ö", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ø", "o", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ù", "u", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ú", "u", 0, 1)
    $sPromptx = StringReplace($sPromptx, "û", "u", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ü", "u", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ý", "y", 0, 1)
    $sPromptx = StringReplace($sPromptx, "þ", "", 0, 1)
    $sPromptx = StringReplace($sPromptx, "ÿ", "y", 0, 1)
    $sPromptx = StringReplace($sPromptx, Chr(0xA0), " ")
    Return $sPromptx
EndFunc

 

Edited by KillaH229
_WinHttpSetTimeouts fix + returns
Link to comment
Share on other sites

  • 10 months later...

 Why not to make a Devin in autoit. Kind of recursive read savescreens ->execute, fail/error.

Someone wants to start this project? or Is it too hard?

Have a look at this schema graph inside this video how the Ai fighter works: 

 

 

If someone want to know what I think about it then: read translate: 

2010 thoughts about AI             and Post about AI 2010

Edited by BasicOs
Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

Thanks

I put also a link here in other 3 related Gpts or openai. In case some of the (gpts) members want to chat about this Autoit Devin. 

I am more analyst then coder lately. More into shaping.

Enjoy coding!!

Edited by BasicOs
Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

  • Developers

You're just a BSer like you were in the past (see our last encounter) , so please simply go away or at least stop posting!
Next time you barf out these posts everywhere, I make you stop by simply banning you.... 

All other post from you today will be removed now!

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...