Skip to content

Commit 3c52d7a

Browse files
committed
Fixed NppOpenAI_instructions file creation
In the previous commit the `NppOpenAI_instructions` file wasn't created appropriately, and it has been resulted an "access violation" error
1 parent 9557d3c commit 3c52d7a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/NppPluginDemo.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include <windows.h>
2121

22-
#define VERSION_VALUE "0.3.0.0\0"
23-
#define VERSION_DIGITALVALUE 0, 3, 0, 0
22+
#define VERSION_VALUE "0.3.0.1\0"
23+
#define VERSION_DIGITALVALUE 0, 3, 0, 1
2424

2525
VS_VERSION_INFO VERSIONINFO
2626
FILEVERSION VERSION_DIGITALVALUE

src/PluginDefinition.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ void loadConfig()
203203
::WritePrivateProfileString(TEXT("INFO"), TEXT("; == The endpoints, like '/v1/chat/completions' will be added to `api_url` automatically. The trailing slash is optional in `api_url`. You should use a query string for custom URL, e.g. 'http://localhost/openai_test.php?endpoint=' ="), TEXT(""), iniFilePath);
204204
}
205205

206+
// Chat preparations + create file for instructions (aka. system message) +
207+
if (::GetPrivateProfileString(TEXT("PLUGIN"), TEXT("is_chat"), NULL, tbuffer2, 2, iniFilePath) == NULL)
208+
{
209+
::WritePrivateProfileString(TEXT("PLUGIN"), TEXT("is_chat"), TEXT("0"), iniFilePath);
210+
if ((instructionsFile = _wfopen(instructionsFilePath, L"w, ccs=UNICODE")) != NULL)
211+
{
212+
fclose(instructionsFile);
213+
}
214+
else
215+
{
216+
instructionsFileError(TEXT("The instructions (system message) file could not be created:\n\n"), TEXT("NppOpenAI: unavailable instructions file"));
217+
}
218+
}
219+
206220
// Get instructions (aka. system message) file
207221
if ((instructionsFile = _wfopen(instructionsFilePath, L"r, ccs=UNICODE")) != NULL)
208222
{

src/PluginDefinition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define CURL_STATICLIB
2121

2222
// Plugin version info
23-
#define NPPOPENAI_VERSION "0.3.0.0"
23+
#define NPPOPENAI_VERSION "0.3.0.1"
2424

2525
//
2626
// All difinitions of plugin interface

0 commit comments

Comments
 (0)