Skip to content

Commit bd45118

Browse files
authored
Add files via upload
1 parent d8c60ff commit bd45118

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

OpenAIFrameworkDemo.xlsm

568 Bytes
Binary file not shown.

clsOpenAI.cls

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Private Const DEFAULT_TEXT_TOKENS_COUNT As Integer = 1024
5656
Private Const UNASSIGNED_VALUE As Integer = -1
5757
Private Const MESSAGE_INVALID_API_KEY As String = "An OpenAI API key is either invalid or has not been specified!"
5858
Private Const HTTP_STATUS_OK As Long = 200 ' OK
59+
Private Const HTTP_REQUEST_COMPLETED As Integer = 4
60+
5961

6062
Private Function IOpenAINameProvider_GetClassName() As String
6163
IOpenAINameProvider_GetClassName = "clsOpenAI"
@@ -143,6 +145,11 @@ On Error GoTo ERR_HANDLER:
143145
.send (strRequestJson)
144146
End With
145147

148+
' completed
149+
Do While mobjHttpRequest.readyState <> HTTP_REQUEST_COMPLETED
150+
DoEvents
151+
Loop
152+
146153
Log "Response code from OpenAI API is: " & mobjHttpRequest.Status
147154

148155
If mobjHttpRequest.Status = HTTP_STATUS_OK Then
@@ -300,7 +307,7 @@ Public Function GetReadAPIKeyFromFolder(ByVal strfolderPath As String) As String
300307
'Purpose: Allows retrieval of an API KEY saved in an external file (possibly stored on a user access drive)
301308

302309
Dim intFileNumber As Integer
303-
Dim strApiKey As String
310+
Dim strAPIKey As String
304311
Dim strFilePath As String
305312

306313
strFilePath = strfolderPath & "\apikey.txt" ' Construct the full file path
@@ -311,13 +318,13 @@ Public Function GetReadAPIKeyFromFolder(ByVal strfolderPath As String) As String
311318
Open strFilePath For Input As intFileNumber
312319

313320
' Read the contents of the file into the variable.
314-
Input #intFileNumber, strApiKey
321+
Input #intFileNumber, strAPIKey
315322

316323
' Close the file.
317324
Close intFileNumber
318325

319326
' Return the API Key
320-
GetReadAPIKeyFromFolder = strApiKey
327+
GetReadAPIKeyFromFolder = strAPIKey
321328
End Function
322329

323330

0 commit comments

Comments
 (0)