ChatGPT GUI Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

ChatGPT GUI

Post by effel » 03 Mar 2023, 11:44

Hallo, ich habe einen funktionierenden Code für ChatGPT gefunden. Es funktioniert jedoch immer nur eine Anfrage. Jede weitere in der gleichen GUI wird nicht beantwortet. Wenn ich reloade, funktioniert wieder eine Anfrage an die API

Hat jemand eine Idee woran das liegen könnte?

Ich habe das Script nochmal neu zusammengestellt, das Ergebnis bleibt bei einer Anfrage.

Den Key gibt es hier:

Code: Select all

#singleinstance force

; Your OpenAI API key
; api_key := "INSERT_API_KEY_HERE"

Gui, new, +hwndhGUIA +Border +Caption +AlwaysOnTop +Owner +LastFound +E0x20 +Resize -DPIScale -ToolWindow
Gui, Add, Tab3,,Main|Json|Settings
Gui, Tab, 1
 	Gui, Font, 	s12
Gui, Add, Text,, Question:
Gui, Add, Edit, vSucheingabe w500 h25, 
Gui, Add, Text,, API Key
 	Gui, Font, 	s11
Gui, Add, Edit, vApi_key w500 h25 center Password,% api_key
 	Gui, Font, 	s12
Gui, Add, Button, gButtonClick w200 h30 default  Section, Ask
Gui, Add, Button, ys gNeuLaden w200 h30, Reload
Gui, Add, Button, ys  gEditScript w30 h30,% Chr(0xE115)
Gui, Add, Button, ys  w30 h30,% Chr(0xE116)
Gui, Add, Text,xs, Answer
Gui, Add, Edit, vAnswerEdit r15 w500, 
Gui, Add, Text,, Translate
Gui, Add, Edit, vAnswerEdit2 r15 w500, 
Gui, Tab, 2
Gui, Add, Text,, Json
Gui, Add, Edit, vJsonEdit r39 w500, 
Gui, Show,% "x100 y" (A_ScreenHeight/8),% hGUIA

Gui, Show
Return

EditScript:
try run, notepad.exe %A_ScriptName%
return

NeuLaden:
reload
return

ButtonClick:
Gui, Submit, NoHide
Prompt := "A patient who is " Age " years old is suffering from " Symptoms ". Give me " CoM " suitable classes of medicines with " NoA " alternatives each that are available Malta and the European Union as well as dosage instructions for each. Also provide me with " Advices " advices to give to the patient."
Prompt := Sucheingabe

;MsgBox, % Prompt

AttemptNo := 1

GoSub, AskGPT
Return


AskGPT:
Gui, PleaseWait: +LastFound +AlwaysOnTop +Disabled -Caption +ToolWindow
Gui, PleaseWait: Color, FFFFFF
Gui, PleaseWait: Add, Text, w200 Center, Please wait...
Gui, PleaseWait: Add, Text,, Contacting Chat GPT`n`nServer may be overloaded/slow.`n`nAttempt No. %AttemptNo%
Gui, PleaseWait: Show, Center, PleaseWait

Prompt := RegExReplace(Prompt, "\""", """""")
Prompt := RegExReplace(Prompt, "\n", "``n")

;MsgBox, % Prompt



; The endpoint URL for the GPT-3 API
api_url := "https://api.openai.com/v1/engines/text-davinci-003/completions"

; The prompt to use as the context for the text generation
;prompt := "What is the capital of France?"

; msgbox % api_key

Try{
; Set up the cURL session
curl := ComObjCreate("WinHttp.WinHttpRequest.5.1")
curl.Open("POST", api_url)
curl.SetRequestHeader("Content-Type", "application/json")
curl.SetRequestHeader("Authorization", "Bearer " api_key)



; Build the JSON payload
jsonY=
(
{
    "prompt": "%Prompt%",
    "max_tokens": 4000,
    "temperature": 0.1
}
)

; Send the request and get the response
curl.Send(jsonY)
result := curl.ResponseText

test := result
}

If test contains error
{
AttemptNo++
;  GuiControl, -Redraw, PleaseWait
Gui, PleaseWait: Destroy
GoTo, AskGPT
}

If test =
{
AttemptNo++
;  GuiControl, -Redraw, PleaseWait
Gui, PleaseWait: Destroy
GoTo, AskGPT
}

Array := []

Array := JSON.Load(test)

Number := 1
While (Number < 100){
Answer := Array["choices"][Number]["text"]

If Answer !=
Break

Number++
}


Answer := RegExReplace(Answer, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
;Answer := RegExReplace(Answer, "(?:\r\n|\r|\n)", " ")       ; replaces line breaks with space

Answer := StrReplace(Answer, "ܟ",  "ß")
Answer := StrReplace(Answer, "ܟ",  "ß")
Answer := StrReplace(Answer, "Ü",  "Ä")
Answer := StrReplace(Answer, "ä", "ä")
Answer := StrReplace(Answer, "ܖ", "Ö")
Answer := StrReplace(Answer, "ö", "ö")
Answer := StrReplace(Answer, "Ã",  "Ü")
Answer := StrReplace(Answer, "ܼ", "ü")
Answer := StrReplace(Answer, "â",  "-")

; https://www.autohotkey.com/boards/viewtopic.php?style=19&p=384889#p384889
	arr := {"ä":"ä","ü":"ü","�":"ü","ö":"ö","ß":"ß","Ãœ":"Ü","„":"„","“":"“"}
	for key, val in arr
		StrReplace(Answer,key,val)

GuiControl,, AnswerEdit, %Answer%
;  GuiControl, -Redraw, PleaseWait
try Answer2 := GoogleTranslate(Answer, "auto", "de")
if Answer2 
GuiControl,, AnswerEdit2, %Answer2%

Gui, PleaseWait: Destroy
Return


GuiClose:
ExitApp



/**
 * Lib: JSON.ahk
 *     JSON lib for AutoHotkey.
 * Version:
 *     v2.1.3 [updated 04/18/2016 (MM/DD/YYYY)]
 * License:
 *     WTFPL [http://wtfpl.net/]
 * Requirements:
 *     Latest version of AutoHotkey (v1.1+ or v2.0-a+)
 * Installation:
 *     Use #Include JSON.ahk or copy into a function library folder and then
 *     use #Include <JSON>
 * Links:
 *     GitHub:     - https://github.com/cocobelgica/AutoHotkey-JSON
 *     Forum Topic - http://goo.gl/r0zI8t
 *     Email:      - cocobelgica <at> gmail <dot> com
 */


/**
 * Class: JSON
 *     The JSON object contains methods for parsing JSON and converting values
 *     to JSON. Callable - NO; Instantiable - YES; Subclassable - YES;
 *     Nestable(via #Include) - NO.
 * Methods:
 *     Load() - see relevant documentation before method definition header
 *     Dump() - see relevant documentation before method definition header
 */
class JSON
{
	/**
	 * Method: Load
	 *     Parses a JSON string into an AHK value
	 * Syntax:
	 *     value := JSON.Load( text [, reviver ] )
	 * Parameter(s):
	 *     value      [retval] - parsed value
	 *     text    [in, ByRef] - JSON formatted string
	 *     reviver   [in, opt] - function object, similar to JavaScript's
	 *                           JSON.parse() 'reviver' parameter
	 */
	class Load extends JSON.Functor
	{
		Call(self, ByRef text, reviver:="")
		{
			this.rev := IsObject(reviver) ? reviver : false
		; Object keys(and array indices) are temporarily stored in arrays so that
		; we can enumerate them in the order they appear in the document/text instead
		; of alphabetically. Skip if no reviver function is specified.
			this.keys := this.rev ? {} : false

			static quot := Chr(34), bashq := "\" . quot
			     , json_value := quot . "{[01234567890-tfn"
			     , json_value_or_array_closing := quot . "{[]01234567890-tfn"
			     , object_key_or_object_closing := quot . "}"

			key := ""
			is_key := false
			root := {}
			stack := [root]
			next := json_value
			pos := 0

			while ((ch := SubStr(text, ++pos, 1)) != "") {
				if InStr(" `t`r`n", ch)
					continue
				if !InStr(next, ch, 1)
					this.ParseError(next, text, pos)

				holder := stack[1]
				is_array := holder.IsArray

				if InStr(",:", ch) {
					next := (is_key := !is_array && ch == ",") ? quot : json_value

				} else if InStr("}]", ch) {
					ObjRemoveAt(stack, 1)
					next := stack[1]==root ? "" : stack[1].IsArray ? ",]" : ",}"

				} else {
					if InStr("{[", ch) {
					; Check if Array() is overridden and if its return value has
					; the 'IsArray' property. If so, Array() will be called normally,
					; otherwise, use a custom base object for arrays
						static json_array := Func("Array").IsBuiltIn || ![].IsArray ? {IsArray: true} : 0
					
					; sacrifice readability for minor(actually negligible) performance gain
						(ch == "{")
							? ( is_key := true
							  , value := {}
							  , next := object_key_or_object_closing )
						; ch == "["
							: ( value := json_array ? new json_array : []
							  , next := json_value_or_array_closing )
						
						ObjInsertAt(stack, 1, value)

						if (this.keys)
							this.keys[value] := []
					
					} else {
						if (ch == quot) {
							i := pos
							while (i := InStr(text, quot,, i+1)) {
								value := StrReplace(SubStr(text, pos+1, i-pos-1), "\\", "\u005c")

								static tail := A_AhkVersion<"2" ? 0 : -1
								if (SubStr(value, tail) != "\")
									break
							}

							if (!i)
								this.ParseError("'", text, pos)

							  value := StrReplace(value,  "\/",  "/")
							, value := StrReplace(value, bashq, quot)
							, value := StrReplace(value,  "\b", "`b")
							, value := StrReplace(value,  "\f", "`f")
							, value := StrReplace(value,  "\n", "`n")
							, value := StrReplace(value,  "\r", "`r")
							, value := StrReplace(value,  "\t", "`t")

							pos := i ; update pos
							
							i := 0
							while (i := InStr(value, "\",, i+1)) {
								if !(SubStr(value, i+1, 1) == "u")
									this.ParseError("\", text, pos - StrLen(SubStr(value, i+1)))

								uffff := Abs("0x" . SubStr(value, i+2, 4))
								if (A_IsUnicode || uffff < 0x100)
									value := SubStr(value, 1, i-1) . Chr(uffff) . SubStr(value, i+6)
							}

							if (is_key) {
								key := value, next := ":"
								continue
							}
						
						} else {
							value := SubStr(text, pos, i := RegExMatch(text, "[\]\},\s]|$",, pos)-pos)

							static number := "number", integer :="integer"
							if value is %number%
							{
								if value is %integer%
									value += 0
							}
							else if (value == "true" || value == "false")
								value := %value% + 0
							else if (value == "null")
								value := ""
							else
							; we can do more here to pinpoint the actual culprit
							; but that's just too much extra work.
								this.ParseError(next, text, pos, i)

							pos += i-1
						}

						next := holder==root ? "" : is_array ? ",]" : ",}"
					} ; If InStr("{[", ch) { ... } else

					is_array? key := ObjPush(holder, value) : holder[key] := value

					if (this.keys && this.keys.HasKey(holder))
						this.keys[holder].Push(key)
				}
			
			} ; while ( ... )

			return this.rev ? this.Walk(root, "") : root[""]
		}

		ParseError(expect, ByRef text, pos, len:=1)
		{
			static quot := Chr(34), qurly := quot . "}"
			
			line := StrSplit(SubStr(text, 1, pos), "`n", "`r").Length()
			col := pos - InStr(text, "`n",, -(StrLen(text)-pos+1))
			msg := Format("{1}`n`nLine:`t{2}`nCol:`t{3}`nChar:`t{4}"
			,     (expect == "")     ? "Extra data"
			    : (expect == "'")    ? "Unterminated string starting at"
			    : (expect == "\")    ? "Invalid \escape"
			    : (expect == ":")    ? "Expecting ':' delimiter"
			    : (expect == quot)   ? "Expecting object key enclosed in double quotes"
			    : (expect == qurly)  ? "Expecting object key enclosed in double quotes or object closing '}'"
			    : (expect == ",}")   ? "Expecting ',' delimiter or object closing '}'"
			    : (expect == ",]")   ? "Expecting ',' delimiter or array closing ']'"
			    : InStr(expect, "]") ? "Expecting JSON value or array closing ']'"
			    :                      "Expecting JSON value(string, number, true, false, null, object or array)"
			, line, col, pos)

			static offset := A_AhkVersion<"2" ? -3 : -4
			throw Exception(msg, offset, SubStr(text, pos, len))
		}

		Walk(holder, key)
		{
			value := holder[key]
			if IsObject(value) {
				for i, k in this.keys[value] {
					; check if ObjHasKey(value, k) ??
					v := this.Walk(value, k)
					if (v != JSON.Undefined)
						value[k] := v
					else
						ObjDelete(value, k)
				}
			}
			
			return this.rev.Call(holder, key, value)
		}
	}

	/**
	 * Method: Dump
	 *     Converts an AHK value into a JSON string
	 * Syntax:
	 *     str := JSON.Dump( value [, replacer, space ] )
	 * Parameter(s):
	 *     str        [retval] - JSON representation of an AHK value
	 *     value          [in] - any value(object, string, number)
	 *     replacer  [in, opt] - function object, similar to JavaScript's
	 *                           JSON.stringify() 'replacer' parameter
	 *     space     [in, opt] - similar to JavaScript's JSON.stringify()
	 *                           'space' parameter
	 */
	class Dump extends JSON.Functor
	{
		Call(self, value, replacer:="", space:="")
		{
			this.rep := IsObject(replacer) ? replacer : ""

			this.gap := ""
			if (space) {
				static integer := "integer"
				if space is %integer%
					Loop, % ((n := Abs(space))>10 ? 10 : n)
						this.gap .= " "
				else
					this.gap := SubStr(space, 1, 10)

				this.indent := "`n"
			}

			return this.Str({"": value}, "")
		}

		Str(holder, key)
		{
			value := holder[key]

			if (this.rep)
				value := this.rep.Call(holder, key, ObjHasKey(holder, key) ? value : JSON.Undefined)

			if IsObject(value) {
			; Check object type, skip serialization for other object types such as
			; ComObject, Func, BoundFunc, FileObject, RegExMatchObject, Property, etc.
				static type := A_AhkVersion<"2" ? "" : Func("Type")
				if (type ? type.Call(value) == "Object" : ObjGetCapacity(value) != "") {
					if (this.gap) {
						stepback := this.indent
						this.indent .= this.gap
					}

					is_array := value.IsArray
				; Array() is not overridden, rollback to old method of
				; identifying array-like objects. Due to the use of a for-loop
				; sparse arrays such as '[1,,3]' are detected as objects({}). 
					if (!is_array) {
						for i in value
							is_array := i == A_Index
						until !is_array
					}

					str := ""
					if (is_array) {
						Loop, % value.Length() {
							if (this.gap)
								str .= this.indent
							
							v := this.Str(value, A_Index)
							str .= (v != "") ? v . "," : "null,"
						}
					} else {
						colon := this.gap ? ": " : ":"
						for k in value {
							v := this.Str(value, k)
							if (v != "") {
								if (this.gap)
									str .= this.indent

								str .= this.Quote(k) . colon . v . ","
							}
						}
					}

					if (str != "") {
						str := RTrim(str, ",")
						if (this.gap)
							str .= stepback
					}

					if (this.gap)
						this.indent := stepback

					return is_array ? "[" . str . "]" : "{" . str . "}"
				}
			
			} else ; is_number ? value : "value"
				return ObjGetCapacity([value], 1)=="" ? value : this.Quote(value)
		}

		Quote(string)
		{
			static quot := Chr(34), bashq := "\" . quot

			if (string != "") {
				  string := StrReplace(string,  "\",  "\\")
				; , string := StrReplace(string,  "/",  "\/") ; optional in ECMAScript
				, string := StrReplace(string, quot, bashq)
				, string := StrReplace(string, "`b",  "\b")
				, string := StrReplace(string, "`f",  "\f")
				, string := StrReplace(string, "`n",  "\n")
				, string := StrReplace(string, "`r",  "\r")
				, string := StrReplace(string, "`t",  "\t")

				static rx_escapable := A_AhkVersion<"2" ? "O)[^\x20-\x7e]" : "[^\x20-\x7e]"
				while RegExMatch(string, rx_escapable, m)
					string := StrReplace(string, m.Value, Format("\u{1:04x}", Ord(m.Value)))
			}

			return quot . string . quot
		}
	}

	/**
	 * Property: Undefined
	 *     Proxy for 'undefined' type
	 * Syntax:
	 *     undefined := JSON.Undefined
	 * Remarks:
	 *     For use with reviver and replacer functions since AutoHotkey does not
	 *     have an 'undefined' type. Returning blank("") or 0 won't work since these
	 *     can't be distnguished from actual JSON values. This leaves us with objects.
	 *     Replacer() - the caller may return a non-serializable AHK objects such as
	 *     ComObject, Func, BoundFunc, FileObject, RegExMatchObject, and Property to
	 *     mimic the behavior of returning 'undefined' in JavaScript but for the sake
	 *     of code readability and convenience, it's better to do 'return JSON.Undefined'.
	 *     Internally, the property returns a ComObject with the variant type of VT_EMPTY.
	 */
	Undefined[]
	{
		get {
			static empty := {}, vt_empty := ComObject(0, &empty, 1)
			return vt_empty
		}
	}

	class Functor
	{
		__Call(method, ByRef arg, args*)
		{
		; When casting to Call(), use a new instance of the "function object"
		; so as to avoid directly storing the properties(used across sub-methods)
		; into the "function object" itself.
			if IsObject(method)
				return (new this).Call(method, arg, args*)
			else if (method == "")
				return (new this).Call(arg, args*)
		}
	}
}

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ChatGPT GUI  Topic is solved

Post by just me » 04 Mar 2023, 07:17

Moin @effel,

ich habe von diesem HTTP-Geraffel nicht viel Ahnung, aber die GoTos innerhalb von AskGPT: gefallen mir schonmal nicht. Mit dem Rücksprung auf das Label erstellst Du jedesmal ein neues WinHttpRequest-Objekt, rufst erneut dessen Open-Methode, setzt die RequestHeader und rufst dann die Send-Methode auf. Ich bin nicht sicher, ob dabei nicht irgendwelche 'Reste' des Vorversuchs aktiv bleiben, die den neuen Versuch verhindern. Und weil Du den wesentlichen Teil in einen Try-Block ohne Catch gesteckt hast, bekommst Du von evtl. gemeldeten Fehlern nichts mit.

Ich würde zunächst einmal versuchen, das Ganze aufzugliedern. Für

Code: Select all

; The endpoint URL for the GPT-3 API
api_url := "https://api.openai.com/v1/engines/text-davinci-003/completions"

; Set up the cURL session
curl := ComObjCreate("WinHttp.WinHttpRequest.5.1")
curl.Open("POST", api_url)
curl.SetRequestHeader("Content-Type", "application/json")
curl.SetRequestHeader("Authorization", "Bearer " api_key)
könnte es reichen, wenn es einmal nach dem Start des Skripts ausgeführt wird.

Code: Select all

Prompt := RegExReplace(Prompt, "\""", """""")
Prompt := RegExReplace(Prompt, "\n", "``n")
; Build the JSON payload
jsonY=
(
{
    "prompt": "%Prompt%",
    "max_tokens": 4000,
    "temperature": 0.1
}
)
würde ich nach ButtonClick verschieben, weil es wahrscheinlich nur einmal pro neuem Prompt gebraucht wird.


In AskGPT: bleibt dann in Bezug auf das WinHttpRequest-Objekt nur noch der Aufruf

Code: Select all

; Send the request and get the response
curl.Send(jsonY)
result := curl.ResponseText
test := result
Vielleicht klappt es damit besser.

Grüße, just me

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 05 Mar 2023, 00:39

Danke Just Me, ich weiß nicht ob das jetzt besser aufgeräumt ist, aber so läuft es bei mir

Code: Select all

#singleinstance force
; Your OpenAI API key
; api_key := "INSERT_API_KEY_HERE"  ; https://platform.openai.com/account/api-keys
; The endpoint URL for the GPT-3 API
api_url := "https://api.openai.com/v1/engines/text-davinci-003/completions"

; Set up the cURL session
curl := ComObjCreate("WinHttp.WinHttpRequest.5.1")
curl.Open("POST", api_url)
curl.SetRequestHeader("Content-Type", "application/json")
curl.SetRequestHeader("Authorization", "Bearer " api_key)
; Build the JSON payload
jsonY=

Gui, PleaseWait: +LastFound +AlwaysOnTop +Disabled -Caption +ToolWindow +hwndhGUIPleaseWait
Gui, PleaseWait: Color, FFFF00
Gui, PleaseWait: Add, Text,xm vTextA w200 Center, Please wait...
Gui, PleaseWait: Add, Text,xs vTextB w200 Center, Loading...
Gui, PleaseWait: Show,% "x300 y" (A_ScreenHeight/2),% hGUIPleaseWait

Gui, New, +hwndhGUIA +Border +Caption +AlwaysOnTop +Owner +LastFound +E0x20 +Resize -DPIScale -ToolWindow, hGUIA
 	Gui, Font, 	s12
Gui, Add, Tab3,,Main|TranslateJson|ResultJson|Settings
Gui, Tab, 1
Gui, Add, Text,, Question:
Gui, Add, Edit, vSucheingabe w500 h25, 
Gui, Add, Text,, API Key
 	Gui, Font, 	s11
Gui, Add, Edit, vApi_key w500 h25 center Password,% api_key
 	Gui, Font, 	s12
Gui, Add, Button, gButtonClick w200 h30 default  Section, Ask
Gui, Add, Button, ys gNeuLaden w200 h30, Reload
Gui, Add, Button, ys  gEditScript w30 h30,% Chr(0xE115)
Gui, Add, Button, ys  w30 h30,% Chr(0xE116)
Gui, Add, Text,xs, Answer
Gui, Add, Edit, vAnswerEdit r15 w500, 
Gui, Add, Text,, Translate
Gui, Add, Edit, vAnswerEdit2 r15 w500, 
Gui, Tab, 2
Gui, Add, Text,, Json
Gui, Add, Edit, vJsonEdit r39 w500, 
Gui, Tab, 3
Gui, Add, Text,, Result
Gui, Add, Edit, vResultEdit r39 w500, 
Gui, Show,% "x100 y" (A_ScreenHeight/10),% hGUIA
Gui, PleaseWait: show, Hide
Return

EditScript:
try run, notepad.exe %A_ScriptName%
return

NeuLaden:
reload
return

ButtonClick:
Gui, Submit, NoHide
Gui, PleaseWait: Show,% "x300 y" (A_ScreenHeight/2),% hGUIPleaseWait
AttemptNo := 1
jsonY := thisJson(Sucheingabe)
; Send the request and get the response
curl.Send(jsonY)
result := curl.ResponseText
test := result
;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject",% isObject(result)
;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject result",% result

If test contains error
{
AttemptNo++
GuiControl,, TextB, %AttemptNo%
GoTo, ButtonClick
}

If test =
{
AttemptNo++
GuiControl,, TextB, %AttemptNo%
GoTo, ButtonClick
}


Array := []
;Array := JSON.Load(result)
Array := JsonToAHK(result)
;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject",% isObject[Array)
Number := 1


While (Number < 100){
Answer := Array["choices"][Number]["text"]
If Answer !=
Break
Number++
}

Result := RegExReplace(Result, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
Answer := RegExReplace(Answer, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
;Answer := RegExReplace(Answer, "(?:\r\n|\r|\n)", " ")       ; replaces line breaks with space
Answer := StrReplace(Answer, "ß",  "ß")
Answer := StrReplace(Answer, "Ü",  "Ä")
Answer := StrReplace(Answer, "ä", "ä")
Answer := StrReplace(Answer, "ܖ", "Ö")
Answer := StrReplace(Answer, "ö", "ö")
Answer := StrReplace(Answer, "Ã",  "Ü")
Answer := StrReplace(Answer, "ü", "ü")
Answer := StrReplace(Answer, "ܼ", "ü")
Answer := StrReplace(Answer, "â",  "-")
; Gemeinschaftsgefܼhl. 
; https://www.autohotkey.com/boards/viewtopic.php?style=19&p=384889#p384889
	         arr := {"ä":"ä"
			,"ü":"ü"
			,"�":"ü"
			,"ö":"ö"
			,"ß":"ß"
			,"Ãœ":"Ü"
			,"„":"„"
			,"“":"“"}
	for key, val in arr
		StrReplace(Answer,key,val)



if Answer
GuiControl,, AnswerEdit, %Answer%
else{
GuiControl,, AnswerEdit, %Result%
try Result2 := GoogleTranslate(Result, "auto", "de")
GuiControl,, AnswerEdit2, %Result2%
}
;  GuiControl, -Redraw, PleaseWait
try Answer2 := GoogleTranslate(Answer, "auto", "de")
if Answer2 
GuiControl,, AnswerEdit2, %Answer2%


try thisBeautifyJson := BeautifyJson(Result)
GuiControl,, ResultEdit, %thisBeautifyJson%

; GuiControl,, ResultEdit, %Result%

; Gui, PleaseWait: Destroy
Gui, PleaseWait: show, Hide
result =
Return


GuiClose:
ExitApp

;json = {"ItemN": 625, "Digital": ["", "", {"key": "value"}], "LocalDel": "Check"}
;ahkObj := JsonToAHK(json)
;MsgBox, % ahkObj["Digital", 3, "key"]

JsonToAHK(json, rec := false) {
   static doc := ComObjCreate("htmlfile")
         , __ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
         , JS := doc.parentWindow
   if !rec
      obj := %A_ThisFunc%(JS.eval("(" . json . ")"), true)
   else if !IsObject(json)
      obj := json
   else if JS.Object.prototype.toString.call(json) == "[object Array]" {
      obj := []
      Loop % json.length
         obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
   }
   else {
      obj := {}
      keys := JS.Object.keys(json)
      Loop % keys.length {
         k := keys[A_Index - 1]
         obj[k] := %A_ThisFunc%(json[k], true)
      }
   }
   Return obj
}

thisJson(ByRef Sucheingabe := "PROMPT") {
 ; Build the JSON payload
 		Sucheingabe := RegExReplace(Sucheingabe, "\""", """""")
 		Sucheingabe := RegExReplace(Sucheingabe, "\n", "``n")
 		jsonY=
		(
			{
			    "prompt": "%Sucheingabe%",
			    "max_tokens": 4000,
			    "temperature": 0.1
			}
		)
Return jsonY
}

BeautifyJson(json, indent := "    ") {
   static Doc, JS
   if !Doc {
      Doc := ComObjCreate("htmlfile")
      Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
      JS := Doc.parentWindow
   }
   Return JS.eval("JSON.stringify(" . json . ",'','" . indent . "')")
}



;################################################################################################################

;MsgBox, % GoogleTranslate("今日の天気はとても良いです")
;MsgBox, % GoogleTranslate("Hello, World!", "en", "ru")

GoogleTranslate(str, from := "auto", to := "de") {
   static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
   
   json := SendRequest(JS, str, to, from, proxy := "")
   oJSON := JS.("(" . json . ")")

ATickCount := A_TickCount
try thisBeautifyJson := BeautifyJson(json)
GuiControl,, JsonEdit, %thisBeautifyJson%

;try fileappend,% thisBeautifyJson,% a_ScriptDir "\" ATickCount "-Google Translate json_History ChatGTP.json.txt"
;try run,% a_ScriptDir "\" ATickCount "-Google Translate json_History ChatGTP.json.txt"

   if !IsObject(oJSON[1]) {
      Loop % oJSON[0].length
         trans .= oJSON[0][A_Index - 1][0]
   }
   else {
      MainTransText := oJSON[0][0][0]
      Loop % oJSON[1].length {
         trans .= "`n+"
         obj := oJSON[1][A_Index-1][1]
         Loop % obj.length {
            txt := obj[A_Index - 1]
            trans .= (MainTransText = txt ? "" : "`n" txt)
         }
      }
   }
   if !IsObject(oJSON[1])
      MainTransText := trans := Trim(trans, ",+`n ")
   else
      trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")

   from := oJSON[2]
   trans := Trim(trans, ",+`n ")

   Return trans
}

SendRequest(JS, str, tl, sl, proxy) {
   static http
   ComObjError(false)
   if !http
   {
      http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
      ( proxy && http.SetProxy(2, proxy) )
      http.open("GET", "https://translate.google.com", true)
      http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
      http.send()
      http.WaitForResponse(-1)
   }
   http.open("POST", "https://translate.googleapis.com/translate_a/single?client=gtx"
                ; or "https://clients5.google.com/translate_a/t?client=dict-chrome-ex"
      . "&sl=" . sl . "&tl=" . tl . "&hl=" . tl
      . "&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=0&ssel=0&tsel=0&pc=1&kc=1"
      . "&tk=" . JS.("tk").(str), true)

   http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
   http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
   http.send("q=" . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}

URIEncode(str, encoding := "UTF-8")  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)

   while code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}

GetJScript()
{
   script =
   (
      var TKK = ((function() {
        var a = 561666268;
        var b = 1526272306;
        return 406398 + '.' + (a + b);
      })());

      function b(a, b) {
        for (var d = 0; d < b.length - 2; d += 3) {
            var c = b.charAt(d + 2),
                c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
                c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
            a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
        }
        return a
      }

      function tk(a) {
          for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
              var c = a.charCodeAt(f);
              128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ?
              (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240,
              g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
          }
          a = h;
          for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
          a = b(a, "+-3^+b+-f");
          a ^= Number(e[1]) || 0;
          0 > a && (a = (a & 2147483647) + 2147483648);
          a `%= 1E6;
          return a.toString() + "." + (a ^ h)
      }
   )
   Return script
}

CreateScriptObj() {
   static doc, JS, _JS
   if !doc {
      doc := ComObjCreate("htmlfile")
      doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
      JS := doc.parentWindow
      if (doc.documentMode < 9)
         JS.execScript()
      _JS := ObjBindMethod(JS, "eval")
   }
   Return _JS
}
03_05_23 @5_50_31.PNG
03_05_23 @5_50_31.PNG (49.04 KiB) Viewed 3729 times

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ChatGPT GUI

Post by just me » 07 Mar 2023, 09:32

Moin @effel,

noch ein paar späte Anmerkungen zu Deinem letzten Skript bzw. dem Code in ButtonClick::
  • Anstelle der Gotos würde ich Folgendes vorschlagen:

    Code: Select all

    Loop {
    	; Send the request and get the response
    	curl.Send(jsonY)
    	result := curl.ResponseText
    	test := result
    	;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject",% isObject(result)
    	;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject result",% result
    	If test contains error
    	{
    		AttemptNo++
    		GuiControl,, TextB, %AttemptNo%
    		Continue
    	}
    	If (test = "")
    	{
    		AttemptNo++
    		GuiControl,, TextB, %AttemptNo%
    		Continue
    	}
    	Break ; anscheinend gibt es eine gültige Antwort
    }
    
  • =>

    Code: Select all

    Array := []
    Array ist der Name des originalen AHK Arrayobjekts. Wenn es keinen triftigen Grund gibt, sollte man diesen Namen für eigene Objekte nicht verwenden.
  • =>

    Code: Select all

    Result := RegExReplace(Result, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
    Dafür nimmt man heute eher die Trim() Funktion:

    Code: Select all

    Result := Trim(Result, " `n`r`t")  ; remove leading and trailing whitespaces
  • =>

    Code: Select all

    Answer := StrReplace(Answer, "ß",  "ß")
    ... und folgende ...
    Hier geht es wohl um die Konvertierung von UTF-8 kodiertem Text. Das geht relativ einfach mit einer Kombination von StrPut() und StrGet():

    Code: Select all

    Answer := FromUTF8(Answer)
    ...
    ...
    FromUTF8(ByRef Text) {
    	Size := StrPut(Text, "CP0")
    	VarSetCapacity(UTF8, Size, 0)
    	StrPut(Text, &Var, "CP0")
    	Return StrGet(&Var, "UTF-8")
    }

Vielleicht ist etwas für Dich Nützliches dabei.

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ChatGPT GUI

Post by garry » 14 Mar 2023, 09:17

effel / just me , danke für den script , dies in 'Skripte und Funktionen' speichern (?)



------------------
https://jonathanturley.org/2023/04/06/defamed-by-chatgpt-my-own-bizarre-experience-with-artificiality-of-artificial-intelligence/
-- Defamed by ChatGPT: My Own Bizarre Experience with Artificiality of “Artificial Intelligence” – JONATHAN TURLEY
------------------

-----------------------
Während das Unternehmen seinen Vorstoss in KI-Produkte beschleunigt, ist das Ethik- und Gesellschaftsteam verschwunden
Ethik und gesellschaftliche Folgeabschätzungen sind ja auch bloss im Weg für sich schnell bewegende Innovatoren wie Microsoft ...

Der Facebook- und Instagram-Mutterkonzern Meta will weitere 10'000 Beschäftigte entlassen.
Die Entlassungen sollen das mittlere Management betreffen, wie Konzernchef Mark Zuckerberg am Dienstag mitteilte.
Ausserdem sollen 5000 offene Stellen bei Meta nicht besetzt werden.
Erst im November hatte der Internetriese die Entlassung von 11'000 Mitarbeiterinnen und Mitarbeitern angekündigt.
In den vergangenen Monaten haben zahlreiche US-Technologiekonzerne massive Stellenstreichungen beschlossen.
Der Google-Mutterkonzern Alphabet hat angekündigt, weltweit rund 12'000 Arbeitsplätze zu streichen.
Der Softwareriese Microsoft will 10'000 Beschäftigte entlassen, der Onlineriese Amazon will mehr als 18'000 Jobs streichen.
------------------
https://www.platformer.news/p/microsoft-just-laid-off-one-of-its 2023-03-14
-- Microsoft just laid off one of its responsible AI teams
Microsoft laid off its entire ethics and society team within the artificial intelligence organization as part of recent layoffs that affected 10,000 employees across the company
---------------------
https://www.channelnewsasia.com/business/meta-facebook-layoffs-employees-job-cuts-second-round-3346136
-- Facebook-parent Meta to lay off 10,000 employees in second round of job cuts - CNA
Facebook-parent Meta Platforms said on Tuesday (Mar 14) it would cut 10,000 jobs, just four months after it let go 11,000 employees, the first Big Tech company to announce a second round of mass layoffs.
---------------------


---------------------
https://openai.com/research/gpt-4
-- GPT-4
We’ve created GPT-4, the latest milestone in OpenAI’s effort in scaling up deep learning.
GPT-4 is a large multimodal model (accepting image and text inputs, emitting text outputs) that,
while less capable than humans in many real-world scenarios, exhibits human-level performance on various professional and academic benchmarks.
----------------------
https://blog.fefe.de/?ts=9aee1dcb
GPT-4
So und jetzt guckt mal, was deren Metrik ist für das Training von dem Modell. Lauter Kompetenztests für Menschen!
Bar Exam ist sowas wie bei uns das Jura-Staatsexamen. LSAT ist der Eignungstest fürs Jurastudium.
SAT ist der Scholastic Aptitude Test, damit testen Unis ihre Bewerber. USABO ist ein Wettbewerb in der Biologie.
AP steht für Advanced Placement, das ist ein College-Level-Test. Dann haben sie da drei Schwierigkeitsstufen eines Sommelier-Tests (Weinexperten) und eines Coding-Tests.
Mit anderen Worten: Microsoft richtet ihr Sprachmodell absichtlich darauf aus, dass es möglich gut in Prüfungen beim Bescheißen helfen kann.
Ich fände das ja super, wenn sich jetzt die ganzen "ich habe mich mit GPT-4 durch die Prüfung gemogelt"-Flachpfeifen bei Microsoft bewerben.
Am besten sollten die nur noch solche Leute kriegen. Das wäre eine gerechte Strafe für so eine gesellschaftliche Sabotage.
-----------------


Blick Autotest > sehr schlau .. :)
---------------------
https://www.blick.ch/digital/chatbot-wird-schlauer-und-kostenpflichtig-neues-chatgpt-4-brilliert-im-blick-autoraetsel-test-id18399043.html
-- Schlauer, aber kostenpflichtig: OpenAI lanciert ChatGPT-4 / $20.--

-- Frage:
Ein Auto braucht von Zürich nach Bern 1,5 Stunden.
Wie lange brauchen zwei Autos?

-oder
1 Auto braucht von Zürich nach Bern 1,5 Stunden.
Wie lange brauchen 2 Autos?
Resultat vom script oben :
2 Autos brauchen 3 Stunden.


-- Antwort ChatGPT Version 3.5 (bisher):
Wenn ein Auto 1,5 Stunden braucht, um von Zürich nach Bern zu fahren, dann können wir die Zeit berechnen, die zwei Autos benötigen, indem wir die Zeit des einen Autos durch die Anzahl der Autos teilen.
Also:
Zeit für zwei Autos = Zeit für ein Auto / Anzahl der Autos.
Zeit für zwei Autos = 1,5 Stunden / 2 = 0,75 Stunden.
Daher brauchen zwei Autos 0,75 Stunden oder 45 Minuten, um von Zürich nach Bern zu fahren.
-------

-- Antwort ChatGPT Version 4 (neu):
Die Zeit, die zwei Autos für die Strecke von Zürich nach Bern benötigen, ist dieselbe wie für ein Auto,
solange sie dieselbe Geschwindigkeit beibehalten und es keine Verkehrsbehinderungen gibt.
Wenn ein Auto 1,5 Stunden für die Strecke benötigt, benötigen auch zwei Autos jeweils 1,5 Stunden.
Die Anzahl der Autos ändert die benötigte Zeit für die Fahrt nicht.
------------------------------------------------------------------------------------------------
https://www.dwdl.de/nachrichten/92181/bildhammer_springer_tauscht_komplette_chefredaktion_aus/ 2023-03-16
-- "Bild"-Hammer: Springer tauscht komplette Chefredaktion aus - DWDL.de

Ich schreibe einen Bericht > Frage an ChatGPT :
"Schreibe einen Artikel im Stil der BILD-Zeitung, 500 Zeichen, über die Risiken der Elektromobilitaet"

Die Elektromobilität ist ein heiss diskutiertes Thema.
Viele Menschen sehen sie als eine sauberere und umweltfreundlichere Alternative zu fossilen Brennstoffen.
Doch es gibt auch Risiken, die man nicht ignorieren sollte.
Eines der grössten Risiken ist die Abhängigkeit von der Stromversorgung. Wenn der Strom ausfällt, können Elektroautos nicht mehr fahren.
Es ist auch schwierig, schnell Ersatzteile zu bekommen, wenn etwas kaputt geht.
Ein weiteres Risiko ist die Kosten. Elektroautos sind im Vergleich zu herkömmlichen Autos teurer.
Es kann auch teuer sein, die Batterien zu ersetzen, wenn sie verschleissen.
Ein weiteres Risiko ist die Ladeinfrastruktur. Es gibt nicht genug Ladestationen, um alle Elektroautos aufzuladen.
Dies bedeutet, dass die Fahrer möglicherweise lange Wartezeiten haben, um ihr Auto aufzuladen.
Es ist wichtig, dass man sich bewusst ist, dass es Risiken gibt, wenn man sich für ein Elektroauto entscheidet.
Es ist wichtig, dass man sich über die Vor- und Nachteile informiert, bevor man eine Entscheidung trifft.
----------------------------------------------------------------------------------------------------------

;------ CALCULATION SHARP PC-1262 ---------------------------------------------------------
;e0:="Wie berechne ich die Gegenkathete ? Zeige mir den Formel wenn die Ankathete und Winkel bekannt ist ."
;- 20*tan(45)=20
;e0:="Wie berechne ich die Hypotenuse ? Zeige mir den Formel wenn die Ankathete und Winkel bekannt ist ."
;The formula for calculating the hypotenuse when the adjacent side and angle are known is:
;Hypotenuse = Adjacent Side / cos(Angle) 20/cos(45)=28.28427125
;e0:="Wie berechne ich den Winkel ? Zeige mir den Formel wenn die Ankathete und Gegenkathete bekannt ist ."
;The formula for calculating the angle is:
;angle = arctan(opposite/adjacent) ATN(30/30)=45
;where arctan is the inverse tangent function.
;-----------------------------------------------------------------------------------------------------

=================================================================
------------------ GPT-4 ------------------------------------------------------------
BING Microsoft :
https://blogs.bing.com/search/march_2023/Confirmed-the-new-Bing-runs-on-OpenAI%E2%80%99s-GPT-4
If you want to experience GPT-4, sign up for the new Bing preview. Once you’re in you’ll be able to use the new Bing to Search, Answer, Chat, and Create at Bing.com.
http://bing.com/new

----------------- GPT-4 -----------------------------------------------------------------

About GPT-4
GPT-4 can solve difficult problems with greater accuracy, thanks to its broader general knowledge and advanced reasoning capabilities.

You can learn more through:
https://openai.com/product/gpt-4
Overview page of GPT-4 and what early customers have built on top of the model.
https://openai.com/research/gpt-4
Blog post with details on the model’s capabilities and limitations, including eval results.

Availability
-- API Waitlist:
https://openai.com/waitlist/gpt-4-api
Please sign up for our waitlist to get rate-limited access to the GPT-4 API – which uses the same ChatCompletions API as gpt-3.5-turbo.
We’ll start inviting some developers today, and scale up availability and rate limits gradually to balance capacity with demand.
https://github.com/openai/evals

-- Priority Access:
Developers can get prioritized API access to GPT-4 for contributing model evaluations to OpenAI Evals that get merged, which will help us improve the model for everyone.

-- ChatGPT Plus:
https://openai.com/blog/chatgpt-plus
ChatGPT Plus subscribers will get GPT-4 access on chat.openai.com with a dynamically adjusted usage cap.
We expect to be severely capacity constrained, so the usage cap will depend on demand and system performance.
API access will still be through the waitlist.

-- API Pricing
gpt-4 with an 8K context window (about 13 pages of text) will cost $0.03 per 1K prompt tokens, and $0.06 per 1K completion tokens.
gpt-4-32k with a 32K context window (about 52 pages of text) will cost $0.06 per 1K prompt tokens, and $0.12 per 1K completion tokens.
-- Watch the GPT-4 Developer Demo here.
https://www.youtube.com/watch?v=outcGtbnMuQ&t=10s
-- GPT-4 Developer Livestream
---------------------
Last edited by garry on 06 Apr 2023, 14:29, edited 6 times in total.

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 14 Mar 2023, 17:32

garry wrote:
14 Mar 2023, 09:17
dies in 'Skripte und Funktionen' speichern (?)
hallo Garry, danke für deine Anfrage ich persönlich habe nicht vor das Skript dort zu veröffentlichen weil der gesamte Code nicht von mir stammt. Ich habe nur die GUI ein bisschen abgeändert und ein paar Kleinigkeiten halt. Wenn Du möchtest freue ich mich sehr wenn du es dort veröffentlichst allerdings bin ich noch nicht fertig. Ich habe die letzten Vorschläge von Just Me noch nicht implementiert und kann mich heute erst damit beschäftigen.

ich würde mich auch sehr freuen wenn du eventuell mit codest. Deine Ideen unterbringst. Besonders mit der GUI fühle ich mich noch schwach. Vielleicht hast du eine bessere GUI Idee. ich habe sie einfach nur auf biegen und brechen einigermaßen hinbekommen. Dafür musste ich einige male in die Hilfe auf github.

Manchmal bin ich für Monate auswärts am Malochen. Der Einstig fällt mir dann schwer, weil wichtiges Wissen einfach nicht mehr so Präsent ist dass man einfach in die Tasten haut ;)

In meiner jetzigen Version möchte ich die GUI so gestalten das die Anzeige entweder Deutsch oder Englisch oder beides ist (mit den Radios) und mit der Checkbox eine ListView mit der History. Die ListView Variante ist nur möglich wenn Mix nicht ausgewählt ist. So passt es in die kleine GUI.

Als wichtigen Punkt finde ich sollte TranslateBevorAsk erhalten bleiben, weil ich mit der Englischen Übersetzung teilweise erhebliche Unterschiede in der Antwort feststelle

just me wrote:
07 Mar 2023, 09:32
Moin @effel,noch ein paar späte Anmerkungen
Moin Just Me, danke das du mich hier mit deinen Ratschlägen begleitest. Ich war ein paar Tage nicht Zuhause und freue mich, dass ich jetzt endlich an meinem Rechner sitze und deine Vorschläge umsetzen kann.



So schaut die GUI aus
Unbenannt.png
Unbenannt.png (26.17 KiB) Viewed 3525 times

Code: Select all

#singleinstance force
; Your OpenAI API key
; api_key := "INSERT_API_KEY_HERE"  ; https://platform.openai.com/account/api-keys
; The endpoint URL for the GPT-3 API
api_url := "https://api.openai.com/v1/engines/text-davinci-003/completions"

; Set up the cURL session
curl := ComObjCreate("WinHttp.WinHttpRequest.5.1")
curl.Open("POST", api_url)
curl.SetRequestHeader("Content-Type", "application/json")
curl.SetRequestHeader("Authorization", "Bearer " api_key)
; Build the JSON payload
jsonY=

Gui, PleaseWait: +LastFound +AlwaysOnTop +Disabled -Caption +ToolWindow +hwndhGUIPleaseWait
Gui, PleaseWait: Color, FFFF00
Gui, PleaseWait: Add, Text,xm vTextA w200 Center, Please wait...
Gui, PleaseWait: Add, Text,xs vTextB w200 Center, Loading...
Gui, PleaseWait: Show,% "x300 y" (A_ScreenHeight/2),% hGUIPleaseWait

Gui, New, +hwndhGUIA +Border +Caption +AlwaysOnTop +Owner +LastFound +E0x20 +Resize -DPIScale -ToolWindow, hGUIA
 	Gui, Font, 	s12
Gui, Add, Tab3,,Main|TranslateJson|ResultJson|Settings
Gui, Tab, 1
;Gui, Add, Text,, Frage an ChatGPT:
Gui, Add, Edit, vSucheingabe hwndSucheingabe w540 r1, 
 	Gui, Font, 	s12
Gui, Add, Text,Section,% "Ausgangssprache: "
Gui, Add, Radio,ys  Group gRadioGroupAuswahl Checked1    vMeinRadioA, German
Gui, Add, Radio,ys  gRadioGroupAuswahl    vMeinRadioB, English
Gui, Add, Radio,ys  gRadioGroupAuswahl    vMeinRadioC     , Mix
Gui, Add, CheckBox,ys  gToggleListview   checked     vToggleListview , ListView History
Gui, Tab, 4
 	Gui, Font, 	s12
Gui, Add, Text,xs Section, API Key:
Gui, Add, Text,ys x+110, total_tokens: 
Gui, Add, Edit,ys  w220 vTextApiKey, Counter
 	Gui, Font, 	s11
Gui, Add, Edit,  xs vApi_key w540 h25 center Password,% api_key
 	Gui, Font, 	s12
Gui, Tab, 1
Gui, Add, Button, xs ys gButtonClick w200 h30 default  Section, Ask
Gui, Add, Button, ys gTranslatebevorAsk w200 h30, Translate bevor Ask
Gui, Add, Button, ys  gEditScript w30 h30,% Chr(0xE115)
Gui, Add, Button, ys gReloadApp w60 h30,% "Reload"
Gui, Add, Text,xs vAnswer, Answer
Gui, Add, Edit, vAnswerEdit r10 w540, 
Gui, Add, Text,vTextTranslate, Translate
Gui, Add, Edit, vAnswerEdit2 r10 w540, 
Gui, Tab, 2
Gui, Add, Text,, Json
Gui, Add, Edit, vJsonEdit r30 w540, 
Gui, Tab, 3
Gui, Add, Text,, Result
Gui, Add, Edit, vResultEdit r30 w540, 
;Gui, Show,% "x100 y" (A_ScreenHeight/10),% a_scriptname " - GuiHWND: " hGUIA  
 Gui, Show, x94 y11,% a_scriptname " - GuiHWND: " hGUIA  
Gui, PleaseWait: show, Hide
 	EM_SETCUEBANNER(Sucheingabe, a_space "Deine Frage an ChatGPT -- your question to ChatGPT")
;GuiControl,hide, ToggleListview
GuiControl,hide, AnswerEdit
GuiControl, Move, Answer, % "w400"
GuiControl,, Answer, ChatGPT Antwort übersetzt mit Google Translate:
GuiControl, Move, AnswerEdit2, % "y+140 h" 500
;GuiControl,hide, AnswerEdit2
GuiControl,hide, TextTranslate
; https://ahkde.github.io/docs/v1/lib/GuiControl.htm
Return

EM_SETCUEBANNER(HWND, Text) {
   ; EM_SETCUEBANNER = 0x1501 -> msdn.microsoft.com/en-us/library/bb761639(v=vs.85).aspx
   Return DllCall("SendMessage", "Ptr", HWND, "UInt", 0x1501, "Ptr", True, "WStr", Text, "Ptr")
}

EditScript:
try run, notepad.exe %A_ScriptName%
return

RadioGroupAuswahl:
return
ToggleListview:
return
ReloadApp:
Gui, Submit, NoHide
reload
return

TranslatebevorAsk:
Gui, Submit, NoHide
if res := ((toggleTranslatebevorAsk := !toggleTranslatebevorAsk) ? true : false) {
SucheingabeOLD := Sucheingabe
try thisTranslatebevorAsk := GoogleTranslate(Sucheingabe, "de", "en")
GuiControl,, Sucheingabe,% thisTranslatebevorAsk
}else{
GuiControl,, Sucheingabe,% SucheingabeOLD
}
return

ButtonClick:
Gui, Submit, NoHide
Gui, PleaseWait: Show,% "x300 y" (A_ScreenHeight/2),% AttemptNo
AttemptNo := 1
jsonY := thisJson(Sucheingabe)
; Send the request and get the response
curl.Send(jsonY)
result := curl.ResponseText
test := result
;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject",% isObject(result)
;msgbox,,% "A_LineNumber. " A_LineNumber " - result",% result

If test contains error
{
AttemptNo++
GuiControl,, AnswerEdit2, error
fileappend,% error "`n",% a_scriptdir "\chatGPT UI - mini - error A.txt"
msgbox,,% "A_LineNumber. " A_LineNumber " - error A",% test,5
sleep, 1000
GuiControl,PleaseWait: , TextB, %AttemptNo%
GoTo, ButtonClick
}

If test =
{
AttemptNo++
GuiControl,, AnswerEdit2, error
fileappend,% error "`n",% a_scriptdir "\chatGPT UI - mini - error B.txt"
msgbox,,% "A_LineNumber. " A_LineNumber " - error B",% test,5
sleep, 1000
GuiControl,PleaseWait: , TextB, %AttemptNo%
GoTo, ButtonClick
}


Array := []
;Array := JSON.Load(result)
Array := JsonToAHK(result)
;msgbox,,% "A_LineNumber. " A_LineNumber " - isObject",% isObject[Array)
Number := 1

While (Number < 100){
ToolTip % Number 
setTimer, ttStop, -3000
Answer := Array["choices"][Number]["text"]
If Answer !=
Break
Number++
}

Result := RegExReplace(Result, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
Answer := RegExReplace(Answer, "^[\s\r\n]+|[\s\r\n]+$", "")  ; remove leading and trailing whitespaces
;Answer := RegExReplace(Answer, "(?:\r\n|\r|\n)", " ")       ; replaces line breaks with space
Answer := StrReplace(Answer, "ß",  "ß")
Answer := StrReplace(Answer, "Ü",  "Ä")
Answer := StrReplace(Answer, "ä", "ä")
Answer := StrReplace(Answer, "ܖ", "Ö")
Answer := StrReplace(Answer, "ö", "ö")
Answer := StrReplace(Answer, "Ã",  "Ü")
Answer := StrReplace(Answer, "ü", "ü")
Answer := StrReplace(Answer, "ܼ", "ü")
Answer := StrReplace(Answer, "â",  "-")
Answer := StrReplace(Answer, "°",  "°") ; 100°C 100 Grad
; Gemeinschaftsgefܼhl. allmächtige, ° = 
; https://www.autohotkey.com/boards/viewtopic.php?style=19&p=384889#p384889
	         arr := {"ä":"ä"
			,"ü":"ü"
			,"�":"ü"
			,"ö":"ö"
			,"ß":"ß"
			,"Ãœ":"Ü"
			,"„":"„"
			,"“":"“"}
	for key, val in arr
		StrReplace(Answer,key,val)



if Answer
GuiControl,, AnswerEdit, %Answer%
else{
GuiControl,, AnswerEdit, %Result%
try Result2 := GoogleTranslate(Result, "auto", "de")
GuiControl,, AnswerEdit2, %Result2%
}
;  GuiControl, -Redraw, PleaseWait
try Answer2 := GoogleTranslate(Answer, "auto", "de")
if Answer2 
GuiControl,, AnswerEdit2, %Answer2%


try thisBeautifyJson := BeautifyJson(Result)
GuiControl,, ResultEdit, %thisBeautifyJson%

;GuiControl,, ResultEdit, %Result%

; Gui, PleaseWait: Destroy
Gui, PleaseWait: show, Hide
result =
thisAPI_completion_tokens := Array["usage", "completion_tokens"]
thisAPI_prompt_tokens     := Array["usage", "prompt_tokens"]
thisAPI_total_tokens      := Array["usage", "total_tokens"]
thisAPI_created		  := Array["created"] ; "`t"

   time := 1970
   time += thisAPI_created, s
   diff -= A_NowUTC, h
   time += diff, h
   FormatTime, TimeStamp, %time%, dd.MM.yyyy HH-mm-ss tt  ; 24.März.2018 05-20-37

GuiControl,, TextApiKey,% "[ " thisAPI_total_tokens " ]   " TimeStamp

    thisLV_ADD := Sucheingabe "`t"
 		. Answer "`t"
 		. Answer2 "`t"
fileappend,% thisLV_ADD "`n",% a_scriptdir "\chatGPT UI - mini - history.txt"

      this_ADD := Sucheingabe "`t"
 		. Answer "`t"
 		. Answer2 "`t"
 		. Array["choices", 1, "finish_reason"] "`t"
 		. Array["choices", 1, "index"] "`t"
 		. Array["choices", 1, "logprobs"] "`t"
 		. Array["choices", 1, "text"] "`t"
 		. Array["created"] "`t"
 		. Array["id"] "`t"
 		. Array["model"] "`t"
 		. Array["object"] "`t"
 		. Array["usage", "completion_tokens"] "`t"
 		. Array["usage", "prompt_tokens"] "`t"
 		. Array["usage", "total_tokens"] "`n"
fileappend,% thisLV_ADD "`n",% a_scriptdir "\chatGPT UI - mini - history-FULL.txt"
      this_LV_Line := Sucheingabe "`t"
 		    . Answer "`t"
 		    . Answer2 "`n"
fileappend,% this_LV_Line "`n",% a_scriptdir "\chatGPT UI - mini - this_LV_Line.txt"


Return

ttStop:
toolTip
return

GuiClose:
ExitApp

;json = {"ItemN": 625, "Digital": ["", "", {"key": "value"}], "LocalDel": "Check"}
;ahkObj := JsonToAHK(json)
;MsgBox, % ahkObj["Digital", 3, "key"]

JsonToAHK(json, rec := false) {
   static doc := ComObjCreate("htmlfile")
         , __ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
         , JS := doc.parentWindow
   if !rec
      obj := %A_ThisFunc%(JS.eval("(" . json . ")"), true)
   else if !IsObject(json)
      obj := json
   else if JS.Object.prototype.toString.call(json) == "[object Array]" {
      obj := []
      Loop % json.length
         obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
   }
   else {
      obj := {}
      keys := JS.Object.keys(json)
      Loop % keys.length {
         k := keys[A_Index - 1]
         obj[k] := %A_ThisFunc%(json[k], true)
      }
   }
   Return obj
}

thisJson(ByRef Sucheingabe := "PROMPT") {
 ; Build the JSON payload
 		Sucheingabe := RegExReplace(Sucheingabe, "\""", """""")
 		Sucheingabe := RegExReplace(Sucheingabe, "\n", "``n")
 		jsonY=
		(
			{
			    "prompt": "%Sucheingabe%",
			    "max_tokens": 4000,
			    "temperature": 0.1
			}
		)
Return jsonY
}

BeautifyJson(json, indent := "    ") {
   static Doc, JS
   if !Doc {
      Doc := ComObjCreate("htmlfile")
      Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
      JS := Doc.parentWindow
   }
   Return JS.eval("JSON.stringify(" . json . ",'','" . indent . "')")
}



;################################################################################################################

;MsgBox, % GoogleTranslate("今日の天気はとても良いです")
;MsgBox, % GoogleTranslate("Hello, World!", "en", "ru")

GoogleTranslate(str, from := "auto", to := "de") {
   static JS := CreateScriptObj(), _ := JS.( GetJScript() ) := JS.("delete ActiveXObject; delete GetObject;")
   
   json := SendRequest(JS, str, to, from, proxy := "")
   oJSON := JS.("(" . json . ")")

ATickCount := A_TickCount
try thisBeautifyJson := BeautifyJson(json)
GuiControl,, JsonEdit, %thisBeautifyJson%

;try fileappend,% thisBeautifyJson,% a_ScriptDir "\" ATickCount "-Google Translate json_History ChatGTP.json.txt"
;try run,% a_ScriptDir "\" ATickCount "-Google Translate json_History ChatGTP.json.txt"

   if !IsObject(oJSON[1]) {
      Loop % oJSON[0].length
         trans .= oJSON[0][A_Index - 1][0]
   }
   else {
      MainTransText := oJSON[0][0][0]
      Loop % oJSON[1].length {
         trans .= "`n+"
         obj := oJSON[1][A_Index-1][1]
         Loop % obj.length {
            txt := obj[A_Index - 1]
            trans .= (MainTransText = txt ? "" : "`n" txt)
         }
      }
   }
   if !IsObject(oJSON[1])
      MainTransText := trans := Trim(trans, ",+`n ")
   else
      trans := MainTransText . "`n+`n" . Trim(trans, ",+`n ")

   from := oJSON[2]
   trans := Trim(trans, ",+`n ")

   Return trans
}

SendRequest(JS, str, tl, sl, proxy) {
   static http
   ComObjError(false)
   if !http
   {
      http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
      ( proxy && http.SetProxy(2, proxy) )
      http.open("GET", "https://translate.google.com", true)
      http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
      http.send()
      http.WaitForResponse(-1)
   }
   http.open("POST", "https://translate.googleapis.com/translate_a/single?client=gtx"
                ; or "https://clients5.google.com/translate_a/t?client=dict-chrome-ex"
      . "&sl=" . sl . "&tl=" . tl . "&hl=" . tl
      . "&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=0&ssel=0&tsel=0&pc=1&kc=1"
      . "&tk=" . JS.("tk").(str), true)

   http.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
   http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
   http.send("q=" . URIEncode(str))
   http.WaitForResponse(-1)
   Return http.responsetext
}

URIEncode(str, encoding := "UTF-8")  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &var, encoding)

   while code := NumGet(Var, A_Index - 1, "UChar")  {
      bool := (code > 0x7F || code < 0x30 || code = 0x3D)
      UrlStr .= bool ? "%" . Format("{:02X}", code) : Chr(code)
   }
   Return UrlStr
}

GetJScript()
{
   script =
   (
      var TKK = ((function() {
        var a = 561666268;
        var b = 1526272306;
        return 406398 + '.' + (a + b);
      })());

      function b(a, b) {
        for (var d = 0; d < b.length - 2; d += 3) {
            var c = b.charAt(d + 2),
                c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
                c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
            a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
        }
        return a
      }

      function tk(a) {
          for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
              var c = a.charCodeAt(f);
              128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ?
              (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240,
              g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
          }
          a = h;
          for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
          a = b(a, "+-3^+b+-f");
          a ^= Number(e[1]) || 0;
          0 > a && (a = (a & 2147483647) + 2147483648);
          a `%= 1E6;
          return a.toString() + "." + (a ^ h)
      }
   )
   Return script
}

CreateScriptObj() {
   static doc, JS, _JS
   if !doc {
      doc := ComObjCreate("htmlfile")
      doc.write("<meta http-equiv='X-UA-Compatible' content='IE=9'>")
      JS := doc.parentWindow
      if (doc.documentMode < 9)
         JS.execScript()
      _JS := ObjBindMethod(JS, "eval")
   }
   Return _JS
}


garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ChatGPT GUI

Post by garry » 15 Mar 2023, 14:53

@effel Dein script funktioniert fein
lediglich wenn die Frage z.B. auf englisch gestellt wird ( oder translate before ask ) gibt es manchmal Problem mit den Buchstaben ( utf8 ? )
Who invented the ball point ?
Der Kugelschreiber wurde 1938 von dem ungarischen Journalisten LÜ¡szlܳ BÜrܳ erfunden. > Laszlo Biro

ChatGPT gibt immer verschiedene Antworten , die Erfindung ist einmal im Jahr 1877 oder 1938 oder 1946 und verschiedene Erfinder ...

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 15 Mar 2023, 18:35

garry wrote:
15 Mar 2023, 14:53
@effel Dein script funktioniert fein
lediglich wenn die Frage z.B. auf englisch gestellt wird ( oder translate before ask ) gibt es manchmal Problem mit den Buchstaben ( utf8 ? )

hast du mal versucht den Vorschlag von Just Me zu testen?

Code: Select all

Answer := FromUTF8(Answer)
...
...
FromUTF8(ByRef Text) {
	Size := StrPut(Text, "CP0")
	VarSetCapacity(UTF8, Size, 0)
	StrPut(Text, &Var, "CP0")
	Return StrGet(&Var, "UTF-8")
}
bei mir stürzt das Script ohne Fehlermeldung ab wenn ich Answer := FromUTF8(Answer) nutze

Schön das es bei dir funktioniert, als ich es bei meiner Freundin auf win 7 testete, hat das Script leider nicht funktioniert.

Es scheint an CURL zu liegen

Auf meinem Rechner habe ich mehrere Versionen von curl.exe liegen. Mit Everything konnte ich sehen, welche vom Script genutzt wird. Diese curl.exe habe ich dann dort in das a_scriptDir kopiert, jedoch leider ohne Erfolg.

---------------------------
chatGPTGui DEV.ahk
---------------------------
Error: 0x80072F7D -
Source: WinHttp.WinHttpRequest
Description: Im Support des sicheren Channels ist ein Fehler aufgetreten

HelpFile: (null)
HelpContext: 0

Specifically: Send

Line#
113: GuiControl,,Sucheingabe,SucheingabeOLD
114: }
115: Return
118: Gui,Submit,NoHide
119: Gui,PleaseWait: Show,"x300 y" (A_ScreenHeight/2),AttemptNo
120: AttemptNo := 1
121: jsonY := thisJson(Sucheingabe)
---> 123: curl.Send(jsonY)
124: result := curl.ResponseText
125: test := result
129: if test contains error
130: {
131: AttemptNo += 1
132: GuiControl,,AnswerEdit2,error
133: FileAppend,error "
",a_scriptdir "\chatGPT UI - mini - error A.txt"

Continue running the script?
---------------------------
Ja Nein
---------------------------


---------------------------
curl.exe - Systemfehler
---------------------------
Das Programm kann nicht gestartet werden, da libssl32.dll auf dem Computer fehlt. Installieren Sie das Programm erneut, um das Problem zu beheben.
---------------------------
OK
---------------------------


effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 16 Mar 2023, 02:30

03_16_23 @8_29_47.PNG
03_16_23 @8_29_47.PNG (26.12 KiB) Viewed 3379 times

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ChatGPT GUI

Post by garry » 16 Mar 2023, 02:35

danke effel , funktioniert fein , zur richtigen Darstellung auf 4K Monitor habe ich -dpiscale entfernt
hier mache ich was falsch ( lediglich wenn die Frage auf englisch gestellt wird ) :
Answer := FromUTF8(Answer) > erhalte memory read/write error

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 16 Mar 2023, 02:49

garry wrote:
16 Mar 2023, 02:35
Answer := FromUTF8(Answer) > erhalte memory read/write error
Seltsam es funktioniert nicht, wenn ich es für Answer nutze, wenn ich es woanders einbaue, z.B. so:

Code: Select all

EditScript:
msgbox % TESTAnswer := FromUTF8("Köln ist ein wichtiges Zentrum für Kultur")
try run, notepad.exe %A_ScriptName%
return
bekomme ich die MsgBox ohne Fehlermeldung angezeigt :headwall:

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ChatGPT GUI

Post by just me » 16 Mar 2023, 03:24

Moin,

tut mir leid, das war ungetestet dahingeschrieben. Wenn man VarSetCapacity() für die Variable UTF8 verwendet, müssen natürlich auch die folgenden Funktionen diese Variable nutzen:

Code: Select all

FromUTF8(ByRef Text) {
	Size := StrPut(Text, "CP0")
	VarSetCapacity(UTF8, Size, 0)
	StrPut(Text, &UTF8 "CP0")
	Return StrGet(&UTF8, "UTF-8")
}

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 16 Mar 2023, 04:15

just me wrote:
16 Mar 2023, 03:24
VarSetCapacity() für die Variable UTF8 verwendet, müssen natürlich auch die folgenden Funktionen diese Variable nutzen...
Moin
Just Me, Vielen Dank

habe es grade getestet, es scheint immer noch ein Fehler drin zu sein, die MsgBox ist leer

Code: Select all

msgbox % res := FromUTF8("Köln ist ein wichtiges Zentrum für Kultur")

FromUTF8(ByRef Text) {
	Size := StrPut(Text, "CP0")
	VarSetCapacity(UTF8, Size, 0)
	StrPut(Text, &UTF8 "CP0")
	Return StrGet(&UTF8, "UTF-8")
}

Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: ChatGPT GUI

Post by Ahk_fan » 16 Mar 2023, 05:09

das mit dem Encoding habe ich auch: viewtopic.php?f=10&t=111599
hab es nur per schreiben in eine temporäre Datei gelöst bekommen.
regards,
AHK_fan :)
https://hr-anwendungen.de

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ChatGPT GUI

Post by just me » 16 Mar 2023, 05:17

Sorry, ich habe bei der Korrektur versehentlich in Zeile 4 ein Komma eliminiert:

Code: Select all

FromUTF8(ByRef Text) {
	Size := StrPut(Text, "CP0")
	VarSetCapacity(UTF8, Size, 0)
	StrPut(Text, &UTF8, "CP0")
	Return StrGet(&UTF8, "UTF-8")
}
Ich hatte vor etwas mehr als zwei Wochen eine OP am rechten Auge und kämpfe immer noch mit kleinen Schriften und kontrastarmen Darstellungen.

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: ChatGPT GUI

Post by effel » 16 Mar 2023, 05:49

just me wrote:
16 Mar 2023, 05:17
...eine OP am rechten Auge
gute Besserung, als Brillenträger kann ich gut Mitfühlen.

Jetzt stürzt das Script nicht mehr ab, aber das ß wird nicht korrigiert. Ich habe Answer := StrReplace(Answer, "ß", "ß") hinzugefügt, so gehts.

Danke dir

03_16_23 @11_41_04.PNG
03_16_23 @11_41_04.PNG (49.18 KiB) Viewed 3312 times

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ChatGPT GUI

Post by garry » 16 Mar 2023, 06:24

@effel und @just me danke für den script
just me , gute Besserung , hoffentlich verheilt alles gut . Ich fühle mich wesentlich besser am Computer mit dem 4K Monitor , die schlechte Auflösung früher in der Firma machte mir Mühe . ( Habe einen geräuschlosen billigst/ klein-Computer montiert auf der Rückseite des Monitors LG 27" )

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ChatGPT GUI

Post by just me » 16 Mar 2023, 07:24

@garry, danke! Einen geräuschlosen Mini-PC habe ich auch, allerdings steht der neben einem billigen 21" Display. ;)

@effel, über das Problem mit dem ß bin ich erst kürzlich gestolpert, ich weiß aber nicht mehr wo. Kannst Du bitte mal eine JSON-Antwort, die ein paar Sonderzeichen inkl. ß enthält, aus Result im Original ins Forum stellen?

Ansonsten könntest Du noch versuchen, den JSON-Text in Result direkt zu konvertieren, bevor er weiter verarbeitet wird.

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ChatGPT GUI

Post by garry » 16 Mar 2023, 08:46

bei mir hat es jetzt funktioniert mit dem deutschen doppel s , > Answer := FromUTF8(Answer)

Post Reply

Return to “Ich brauche Hilfe”