Zabaware Forums > General Discussion
Something cool
(1/1)
cyberjedi:
Sending up a flair to any coderz left
Hey guys, interesting concept im working on a as a plugin in: As u can see, its all about XML.im like a broken record here
Chime in any time
Do NOT run this and then COMPLAIN, oh oh cyber f**Ked me up, This is a concept test..... Im just doing it publicly
If this can work reliably ill Port a hard copy as a training model for Hal stock Brains. Using GPT to train UltraHal out of the box . No small feat.
Rem Type=Plugin
Rem Name=ChatGpt
Rem Author= cyberjedi
Rem Host=All
Rem PLUGIN: PRE-PROCESS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
HalBrain.ReadOnlyMode = False
'Determines that you are talking about chatgpt
If InStr(1,InputString, "chatgpt",1) > 0 Then
UltraHal = chatgpt(HalCommands)
ElseIf InStr(1,InputString, "chatgpt",1) > 0 Then
End If
Rem PLUGIN: FUNCTIONS
Function chatgpt(HalCommands)
' Replace with your own API key from OpenAI
apiKey = "YOUR_OPENAI_API_KEY"
' Function to send a message to ChatGPT and get a response
Function SendMessageToChatGPT(message)
Dim xmlhttp
Set xmlhttp = CreateObject("MSXML2.XMLHTTP")
' API endpoint
url = "https://api.openai.com/v1/chat/completions"
' JSON payload
payload = "{""model"": ""gpt-4"", ""messages"": [{""role"": ""user"", ""content"": """ & message & """}]}"
' Open a connection to the API
xmlhttp.Open "POST", url, False
' Set the necessary headers
xmlhttp.setRequestHeader "Content-Type", "application/json"
xmlhttp.setRequestHeader "Authorization", "Bearer " & apiKey
' Send the request with the payload
xmlhttp.Send payload
' Wait for the response
Do While xmlhttp.readyState <> 4
WScript.Sleep 100
Loop
' Parse the JSON response (basic parsing, assuming a simple structure)
Dim response, jsonResponse
response = xmlhttp.responseText
Set jsonResponse = ParseJson(response)
' Get the assistant's reply from the JSON response
SendMessageToChatGPT = jsonResponse("choices")(0)("message")("content")
' Clean up
Set xmlhttp = Nothing
Set jsonResponse = Nothing
End Function
' Basic JSON parser function
Function ParseJson(jsonText)
Dim sc
Set sc = CreateObject("ScriptControl")
sc.Language = "JScript"
Set ParseJson = sc.Eval("(" & jsonText & ")")
End Function
' Main script
Dim userMessage, chatgptResponse
userMessage = "Hello, ChatGPT! How are you?"
chatgptResponse = SendMessageToChatGPT(userMessage)
HalMenu.HalCommand "<SPEAK>" & chatgptResponse & "</SPEAK>"
End Function
cyber jedi
Navigation
[0] Message Index
Go to full version