Please modify the following VBA Excel code so that it is compatible with an open-source…
- User
Please modify the following VBA Excel code so that it is compatible with an open-source large language models instead of OpenAI's proprietary one. With the open-source models, I am typically able to produce a live endpoint URL generated on a Google Colab notebook using a T4 GPU. The endpoint is to run an open source LLM that has already been loaded into the Colab notebook. This Cloudfare URL only works while the Colab notebook is kept active, which is why I want the VBA code to be modified to incorporate it. Note that an API key is not produced in the Google Colab procedure, as the LLM is open source and no API keys are typically required. I am running VBA locally in Excel.
Sub ExecuteCode(code) Dim vbProj As Object Dim vbComp As Object Dim vbMod As Object
' Reference to the VBProject Set vbProj = ThisWorkbook.VBProject ' Create a new standard module Set vbComp = vbProj.VBComponents.Add(1) ' Add the code to the module Set vbMod = vbComp.CodeModule vbMod.AddFromString code ' Execute the procedure Application.Run vbComp.Name & ".MyProcedure" ' Remove the module vbProj.VBComponents.Remove vbCompEnd Sub
Sub testing() UserForm1.Show End Sub
Sub OpenAI(prompt)
Dim url As String, apiKey As String Dim response As Object, json As String, data As String apiKey = "here" url = "here" ' Construct the data string with the model, messages, and temperature parameters data = "{""model"":""gpt-3.5-turbo""," & _ """messages"":[{""role"":""user"",""content"":""" & " Write a VBA script to do the following also name your subroutine MyProcedure: " & prompt & """}]," & _ """temperature"":0}" Set response = CreateObject("MSXML2.ServerXMLHTTP") response.Open "POST", url, False response.setRequestHeader "Content-Type", "application/json" response.setRequestHeader "Authorization", "Bearer " & apiKey response.Send data json = response.responseText ' Find the position of "Sub" in the string startPos = InStr(1, json, "Sub", vbTextCompare) ' Find the position of "End Sub" in the string endPos = InStr(1, json, "End Sub", vbTextCompare) ' If both "Sub" and "End Sub" are found, extract the content between them If startPos > 0 And endPos > 0 Then ExtractSubCode = Mid(json, startPos, endPos - startPos + Len("End Sub")) ' ExtractSubCode = Mid(json, startPos, 5) Else ExtractSubCode = "Sub procedure not found." End If ' Replace \n with " & vbCrLf & _" and \" with "" convertedCode = Replace(ExtractSubCode, "\n", vbCrLf) convertedCode = Replace(convertedCode, "\", "") ' Add the initial quote for the string convertedCode = convertedCode ExecuteCode convertedCodeEnd Sub
- Assistant
- User
Tell me more about Postman testing
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.