Autor Thema: ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)  (Gelesen 2508 mal)

Offline shiraz

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 648
  • Geschlecht: Männlich
Hallo,

alle reden über ChatGP, wir machen ChatGPT !!!

Diese Datenbank enthält die Script-Library ChatGPT. Diese Skriptbibliothek liefert die Kernfunktionen, um die Chat-GPT-API mit minimalistischem Code im Notes-Client oder Web-Browser anzufordern. Sein Hauptzweck ist es, Sie schneller in die API einzuführen - es liefert Kernfunktionen und kann jederzeit erweitert und angepasst werden.

Ich hätte gerne diese Template auf OpenNTF hochgeladen, aber es ist leider sehr kompliziert um dies zu tun....
« Letzte Änderung: 26.02.23 - 13:32:56 von shiraz »
Gruß
Christian

Offline jBubbleBoy

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.290
  • Geschlecht: Männlich
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #1 am: 27.02.23 - 10:20:51 »
Beim OpenNTF-Problem scheint es ja keine Hilfe zu sein, für welche Aufgaben verwendet ihr denn ChatGPT?
« Letzte Änderung: 27.02.23 - 10:23:07 von jBubbleBoy »
Gruss Erik :: Freelancer :: KI-Dev, Notes, Java, Web, VBA und DomNav 2.5 / NSE 0.16 / OLI 1.0

--
Nur ein toter Bug, ist ein guter Bug!

Offline jBubbleBoy

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.290
  • Geschlecht: Männlich
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #2 am: 01.03.23 - 12:21:46 »
Ich frag nur weil ich mir auch ChatGPT angeschaut habe. Eine wirklich coole Sache, aber bei Arbeitsthemen muss ich dann doch parallel mit Google die Aussagen prüfen und werde am Ende mit Entschuldigungen und Ausreden überschüttet, nicht wirklich eine Hilfe ;)
Da finde ich ja die Bing-Chat-Bot Variante schon "Menschlicher", denn die bockt und beendet die Kommunikation wenn man auf Fehler hinweist. Aber auch das wurde schon "entschärft" :-:
Gruss Erik :: Freelancer :: KI-Dev, Notes, Java, Web, VBA und DomNav 2.5 / NSE 0.16 / OLI 1.0

--
Nur ein toter Bug, ist ein guter Bug!

Offline schroederk

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.924
  • Geschlecht: Männlich
  • Ich liebe dieses Forum!
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #3 am: 01.03.23 - 14:40:23 »
Einen Company-Nutzen kann ich mir im Moment auch nur begrenzt vorstellen. Vielleicht reicht hierfür aber auch einfach meine Phantasie nicht aus  ;)
Ich selber habe es 2-3 Mal genutzt, um ein spezifisches Coding-Problem zu lösen, dass bei einem Fall auch sogar mal geholfen hat.
Ein Freund lässt sich über ChatGPT immer kurze Gute-Nacht-Geschichten für seine Tochter generieren, die er dann vorliest.
Ich wäre ja gerne weniger egoistisch, aber was hab ich davon?

Offline Obrac

  • Senior Mitglied
  • ****
  • Beiträge: 275
  • Geschlecht: Männlich
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #4 am: 23.05.24 - 08:56:51 »
@shiraz: Erst einmal vielen Dank für die Bereitstellung der NTFS. Leider habe ich das Problem, dass sich immer die Fehlermeldung "HTTP/1.1 404 Not found there was an error retrieving the APi response" bekomme. Der API-Key (Project-Key) ist im OpenAI-Konto eingerichtet und im Skript eingetragen. Hast du eine Ahnung, was das Problem sein könnte?

Offline Obrac

  • Senior Mitglied
  • ****
  • Beiträge: 275
  • Geschlecht: Männlich
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #5 am: 23.05.24 - 12:08:03 »
Ich habe jetzt ChatGPT die Skriptbibliothek ("ChatGPT") selbst einmal fixen lassen. Anscheinend war die bestehende veraltet. Hier ist die funktionierende:

Code
%REM
	Library ChatGPT
	Created 25.02.2023 by 
		Ayhan Sahin/FDI		<ayhan.sahin@fdi.de>
		Christian Sadeghi/SUEDWESTMETALL	<sadeghi@suedwestmetall.de>
	Description: Simple ChatGPT API Client
%END REM
Option Public
Option Declare
Use "JSONParser"
Class ChatGPT
	
	Private query As String
	Private config As Variant
	Private request As String
	Private apiurl As String
	Private apikey As String
	Private modell As String
	Private maxtokens As String
	Private temperature As String
	Private presencepenalty As String
	Private frequencypenalty As String
	Private topp As String
	Private responsetype As String



	%REM 
		Constructor
	%END REM
	Sub New ()
		Call setup()
	End Sub
	
	
	
	%REM 
		Destructor
	%END REM
	Sub Delete()
	End Sub
	
	
	
	%REM
		Main routine to build and query ChatGPT API
		@ToDo: Extend the checks on oRequest after request for errors
	%END REM		
	Public Function init(sQuery As String, aConfig As Variant)
		Dim s As New NotesSession
		Dim oRequest As NotesHTTPRequest
		Dim sResponseContent As String
		Dim oResponseHeaders As Variant
		
		'	Set query and config
		Me.query 		= cGetQuery(sQuery)
		Me.config		= aConfig
		
		'	Setup / Override the config
		Call setConfig()

		'	Validate and request the API
		If isValidRequest Then
			Me.request = cGetRequestContent()
			Me.apiurl = cGetAPIUrl()
			
			'	Do the request
			Set oRequest = s.CreateHTTPRequest()
			oRequest.Preferstrings = True
			Call oRequest.SetHeaderField("Content-Type", "application/json")
			Call oRequest.SetHeaderField("Authorization", "Bearer " & Me.apikey)
			sResponseContent = oRequest.post(Me.apiurl, Me.request)
			oResponseHeaders = oRequest.Getresponseheaders()
			
			'	***	Simple check (needs to be extended)
			If UCase(oRequest.Responsecode) <> "HTTP/1.1 200 OK" Then
				If Me.responsetype = "TEXT" Then
					sResponseContent = |{"choices":[{"text":"| & oRequest.ResponseCode & |"}, {"text": "There was an error retrieving the API response"}]}|
				Else
					sResponseContent = |{"status":"| & oRequest.ResponseCode & |", "message": "There was an error retrieving the API response"}|
				End If
			End If
		End If

		'	***	Return-Mode of the response
		If Me.responsetype = "TEXT" Then
			sResponseContent = getResponseAsText(sResponseContent)
		Else
			'	Fix the response for a valid JSON if empty
			If sResponseContent = "" Then
				sResponseContent = "[]"
			End If
		End If

		init = sResponseContent
		
	End Function
	
	
	
	%REM
		Function setup
		Description: Set default values for this class
	%END REM
	Private Function setup()
		Me.apikey			= ""
		Me.modell 			= "gpt-4"
		Me.maxtokens 		= "1000"
		Me.temperature 		= "0"
		Me.presencepenalty 	= "0"
		Me.frequencypenalty = "0"
		Me.topp				= "1"
		Me.responsetype		= "JSON"
	End Function
	
	
	
	%REM
		Function setConfig
		Description: Sets / Overrides the current config from the given one
	%END REM
	Private Function setConfig()
		If getConfigKey("apikey") <> "" Then
			Me.apikey = getConfigKey("apikey")
		End If
		If getConfigKey("modell") <> "" Then
			Me.modell = getConfigKey("modell")
		End If
		If getConfigKey("maxtokens") <> "" Then
			Me.maxtokens = getConfigKey("maxtokens")
		End If
		If getConfigKey("temperature") <> "" Then
			Me.temperature = getConfigKey("temperature")
		End If
		If getConfigKey("presencepenalty") <> "" Then
			Me.presencepenalty = getConfigKey("presencepenalty")
		End If
		If getConfigKey("frequencypenalty") <> "" Then
			Me.frequencypenalty = getConfigKey("frequencypenalty")
		End If
		If getConfigKey("topp") <> "" Then
			Me.topp = getConfigKey("topp")
		End If
		If getConfigKey("responsetype") <> "" Then
			Me.responsetype = getConfigKey("responsetype")
		End If
	End Function
	
	
	
	%REM
		Function getConfigKey
		Description: Returns values from given configuration key
	%END REM
	Private Function getConfigKey(key As String) As String
		If IsElement(Me.config(key)) = True Then
			getConfigKey = Me.config(key)
		Else
			getConfigKey = ""
		End If
	End Function
	
	
	
	%REM
		Function isValidRequest
		Description: Checks if everything is set properly to call the webservice
		@ToDo: More accurate checks
	%END REM
	Private Function isValidRequest()
		Dim bReturn As Boolean
		bReturn = True
		
		If Me.apikey = "" Then
			bReturn = False
		End If
		
		If Me.query = "" Then
			bReturn = False
		End If
		
		If Me.modell = "" Then
			bReturn = False
		End If
		
		isValidRequest = bReturn
	End Function



	%REM
		Function cGetAPIUrl
		Description: Returns the API URL
		@ToDo: Retrieve this from a configuration
	%END REM
	Private Function cGetAPIUrl()
		cGetAPIUrl = "https://api.openai.com/v1/chat/completions"
	End Function
	
	
	%REM
		Function cCleanQuery
		Description: Removes unwanted characters from the query
	%END REM
	Private Function cGetQuery(sQuery As String)
		Dim sTmp As String 
		sTmp = FullTrim(sQuery)
		
		If sTmp <> "" Then
			sTmp = cReplaceSubString(sTmp, |"|, ||)
			sTmp = cReplaceSubString(sTmp, |'|, ||)
			sTmp = cReplaceSubString(sTmp, |&|, ||)
			sTmp = cReplaceSubString(sTmp, Chr(10), ||)
			sTmp = cReplaceSubString(sTmp, Chr(9), ||)
			sTmp = cReplaceSubString(sTmp, Chr(13), ||)
		End If

		cGetQuery = FullTrim(sTmp)
	End Function


	%REM
		Function cGetRequestSkeleton
		Description: Gets the basic skeleton for a ChatGPT request
		@ToDo:	Extend the skeleton
	%END REM
	Private Function cGetRequestContent()
		Dim sData As String
		sData = |{
  			"model": "| & Me.modell & |",
  			"messages": [{"role": "user", "content": "| & Me.query & |"}],
  			"temperature": | & Me.temperature & |,
  			"max_tokens": | & Me.maxtokens & |,
  			"top_p": | & Me.topp & |,
  			"frequency_penalty": | & Me.frequencypenalty & |,
  			"presence_penalty": | & Me.presencepenalty & |
		}|
		cGetRequestContent = sData
	End Function



	%REM
		Function getResponseAsText
		Description: Merges the API-Response-Text (JSON) to a single Text
	%END REM
	Private Function getResponseAsText(sJSON As String)
		Dim sTmp As String
		
		Dim parser As JSONParser
		Dim jsonObj As JSONObject
		Dim jsonArr As JSONArray
		Dim jsonString As String

		Set parser = New JSONParser
		Set jsonObj = parser.parse(sJSON)

		If jsonObj.HasItem("choices") = True Then
			ForAll x In jsonObj.GetItem("choices").Items
				sTmp = sTmp + " " + x.GetItem("message").GetItem("content")
			End ForAll			
		End If
		
		getResponseAsText = sTmp
	End Function



	%REM
		Helper Class
	%END REM
	Private Function cReplaceSubString(sString As String, sFind As String, sReplace As String)
		Dim sReturn As String
		Dim sTemp As String
		
		If sFind = "" Then
			cReplaceSubString = sString
			Exit Function
		End If
		
		sTemp = sString
		Dim i As Double
		i = InStr(sTemp, sFind)
		
		While (i > 0)
			sReturn =  sReturn + Left(sTemp, i -1) + sReplace
			sTemp = Mid(sTemp, i + Len(sFind))
			i = InStr(sTemp, sFind)
		Wend
		
		sReturn = sReturn + sTemp
		cReplaceSubString = sReturn
	End Function
	
End Class

Offline jBubbleBoy

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 1.290
  • Geschlecht: Männlich
Antw:ChatGPT APIs für HCL / DOMINO (FREE TO DOWNLOAD)
« Antwort #6 am: 03.06.24 - 12:56:34 »
Der API-Key (Project-Key) ist im OpenAI-Konto eingerichtet ...

OK Chat-GPT ist derzeit das beste LLM, wer aber seine Daten nicht an ein US-Rechenzentrum übertragen will oder darf, kann auch frei verfügbare LLMs lokal nutzen und das geht mit ollama recht einfach - inklusive eines Installers und einer API-Anbindung. Außerdem ist es kostenlos, man zahlt nichts für seine Token:
https://github.com/ollama/ollama

Z.B. steht llama3 auf Platz 11 in der Chat-Bot-Arena und sollte damit für die meisten Aufgaben ausreichen:
https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard
« Letzte Änderung: 03.06.24 - 16:00:37 von jBubbleBoy »
Gruss Erik :: Freelancer :: KI-Dev, Notes, Java, Web, VBA und DomNav 2.5 / NSE 0.16 / OLI 1.0

--
Nur ein toter Bug, ist ein guter Bug!

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz