Skip to content

Commit

Permalink
gpt-35-turbo-16k が登場したため、maxtokens を秀丸マクロ側から指定できるようにした。これにより、バッファーが大き…
Browse files Browse the repository at this point in the history
…く増える。
  • Loading branch information
komiyamma committed Jun 14, 2023
1 parent ed5481a commit 7302e18
Show file tree
Hide file tree
Showing 36 changed files with 54 additions and 35 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified src/.vs/HmChatGPT35Turbo/v17/.futdcache.v2
Binary file not shown.
Binary file modified src/.vs/HmChatGPT35Turbo/v17/.suo
Binary file not shown.
Binary file not shown.
Binary file modified src/.vs/ProjectEvaluation/hmchatgpt35turbo.metadata.v7.bin
Binary file not shown.
Binary file modified src/.vs/ProjectEvaluation/hmchatgpt35turbo.projects.v7.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions src/HmChatGPT35Turbo/HmChatGPT35Turbo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<EnableComHosting>true</EnableComHosting>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<BaseOutputPath>bin\$(PlatformTarget)</BaseOutputPath>
<Authors>Akitsugu Komiyama</Authors>
<Copyright>$(Authors)</Copyright>
<AssemblyVersion>1.0.7.1</AssemblyVersion>
<FileVersion>1.0.7.1</FileVersion>
<Version>1.0.7.1</Version>
<AssemblyVersion>1.0.7.2</AssemblyVersion>
<FileVersion>1.0.7.2</FileVersion>
<Version>1.0.7.2</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)'=='x86'">
Expand Down
6 changes: 4 additions & 2 deletions src/HmChatGPT35Turbo/OpenAIChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class OpenAIChatMain
const string ErrorMessageNoOpenAIKey = OpenAIKeyEnvironmentVariableName + "キーが環境変数にありません。:" + NewLine;

string model = "";
int iMaxTokens;

public OpenAIChatMain(string key, string model, IOutputWriter output)
public OpenAIChatMain(string key, string model, int maxtokens, IOutputWriter output)
{
// 出力対象のDI用
this.output = output;
Expand All @@ -42,6 +43,7 @@ public OpenAIChatMain(string key, string model, IOutputWriter output)
this.model = Models.ChatGpt3_5Turbo;
// output.WriteLine(this.model);
}
this.iMaxTokens = maxtokens;

// とりあえず代入。エラーならChatGPTの方が言ってくれる。
if (key.Length > 0)
Expand Down Expand Up @@ -137,7 +139,7 @@ IAsyncEnumerable<ChatCompletionCreateResponse> ReBuildPastChatContents(Cancellat
{
Messages = messageList,
Model = this.model,
MaxTokens = 2000
MaxTokens = iMaxTokens
};

// ストリームとして会話モードを確率する。ストリームにすると解答が1文字ずつ順次表示される。
Expand Down
7 changes: 5 additions & 2 deletions src/HmChatGPT35Turbo/WinForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ class AppForm : Form
int DisplayDpi = 96;
string model = "";
int nTopMost = 0;
int iMaxTokens = 2000;

public AppForm(string key, string model, IOutputWriter output, IInputReader input)
public AppForm(string key, string model, int maxtokens, IOutputWriter output, IInputReader input)
{
// 「入力」や「出力」の対象を外部から受け取り
this.output = output;
this.input = input;
this.model = model;

this.iMaxTokens = maxtokens;

try
{
int isTopMostType = (int)(dynamic)(Hm.Macro.Var["#TOPMOST"]);
Expand Down Expand Up @@ -407,7 +410,7 @@ void SetOpenAI(string key)
{
try
{
ai = new OpenAIChatMain(key, model, output);
ai = new OpenAIChatMain(key, model, iMaxTokens, output);
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/HmChatGPT35Turbo/WinFormCOMInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class HmChatGPT35Turbo

HmChatGPT35TurboSharedMemory sm = new HmChatGPT35TurboSharedMemory();

public long CreateForm(string key = "", string model="")
public long CreateForm(string key = "", string model="", int maxtokens = 2000)
{
try
{
Expand All @@ -28,7 +28,7 @@ public long CreateForm(string key = "", string model="")
{
output = new HmOutputWriter();
input = new HmInputReader();
form = new AppForm(key, model, output, input);
form = new AppForm(key, model, maxtokens, output, input);

sm.CreateSharedMemory();
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"HmChatGPT35Turbo/1.0.7.1": {
"HmChatGPT35Turbo/1.0.7.2": {
"dependencies": {
"Betalgo.OpenAI": "7.0.0",
"HmNetCOM": "2.0.7.9"
Expand Down Expand Up @@ -154,7 +154,7 @@
}
},
"libraries": {
"HmChatGPT35Turbo/1.0.7.1": {
"HmChatGPT35Turbo/1.0.7.2": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*--------------------------------------------
* HmChatGPT35Turbo v1.0.7.1
* HmChatGPT35Turbo v1.0.7.2
*
* Copyright (C) 2023 Akitsugu Komiyama
* under the MIT License
Expand All @@ -17,9 +17,16 @@ SET_OPENAI_KEY:
}

// モデルの指定
SET_OPENAI_KEY:
SET_MODEL:

$MODEL = "gpt-3.5-turbo"; // あなたのOpenAIアカウント内のAPIで、gpt-4 以上が使えるならば、"gpt-4"などの設定可能。しかしながら値段が10倍以上に跳ね上がるので注意。
// 最大トークンを大きくしたいなら gpt-3.5-turbo-16k などとすれば4倍になる。この場合は料金は2倍ほどで済むので格安具合をある程度維持できる。


SET_MAXTOKENS:

#MAXTOKENS = 2000; // この数値は概ね 使用対象のmodelの最大トークンの半分程度を使用するのが望ましい。
// 「gpt-3.5-turbo なら 2000」、「gpt-3.5-turbo-16k なら 8000」、「gpt-4 なら 4000」、「gpt-4-32k なら 16000」といった具合。


SET_TOPMOST_TYPE:
Expand Down Expand Up @@ -92,6 +99,6 @@ SHOW_OPENAI_FORM:
setcomdetachmethod #CHATGPT_OBJ, "DestroyForm";

// フォームの表示。
#_ = member(#CHATGPT_OBJ, "CreateForm", $OPENAI_KEY, $MODEL);
#_ = member(#CHATGPT_OBJ, "CreateForm", $OPENAI_KEY, $MODEL, #MAXTOKENS);

return;
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"HmChatGPT35Turbo/1.0.7.1": {
"HmChatGPT35Turbo/1.0.7.2": {
"dependencies": {
"Betalgo.OpenAI": "7.0.0",
"HmNetCOM": "2.0.7.9"
Expand Down Expand Up @@ -154,7 +154,7 @@
}
},
"libraries": {
"HmChatGPT35Turbo/1.0.7.1": {
"HmChatGPT35Turbo/1.0.7.2": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*--------------------------------------------
* HmChatGPT35Turbo v1.0.7.1
* HmChatGPT35Turbo v1.0.7.2
*
* Copyright (C) 2023 Akitsugu Komiyama
* under the MIT License
Expand All @@ -17,9 +17,16 @@ SET_OPENAI_KEY:
}

// モデルの指定
SET_OPENAI_KEY:
SET_MODEL:

$MODEL = "gpt-3.5-turbo"; // あなたのOpenAIアカウント内のAPIで、gpt-4 以上が使えるならば、"gpt-4"などの設定可能。しかしながら値段が10倍以上に跳ね上がるので注意。
// 最大トークンを大きくしたいなら gpt-3.5-turbo-16k などとすれば4倍になる。この場合は料金は2倍ほどで済むので格安具合をある程度維持できる。


SET_MAXTOKENS:

#MAXTOKENS = 2000; // この数値は概ね 使用対象のmodelの最大トークンの半分程度を使用するのが望ましい。
// 「gpt-3.5-turbo なら 2000」、「gpt-3.5-turbo-16k なら 8000」、「gpt-4 なら 4000」、「gpt-4-32k なら 16000」といった具合。


SET_TOPMOST_TYPE:
Expand Down Expand Up @@ -92,6 +99,6 @@ SHOW_OPENAI_FORM:
setcomdetachmethod #CHATGPT_OBJ, "DestroyForm";

// フォームの表示。
#_ = member(#CHATGPT_OBJ, "CreateForm", $OPENAI_KEY, $MODEL);
#_ = member(#CHATGPT_OBJ, "CreateForm", $OPENAI_KEY, $MODEL, #MAXTOKENS);

return;
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Akitsugu Komiyama")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Akitsugu Komiyama")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.7.2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.7.2")]
[assembly: System.Reflection.AssemblyProductAttribute("HmChatGPT35Turbo")]
[assembly: System.Reflection.AssemblyTitleAttribute("HmChatGPT35Turbo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.7.2")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ffd34397b00ed9ff192b40e8c3b9c5121502c263
da7a0a33e24fd071804d25cd45c803f6bfa0ae86
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"projects": {
"G:\\repogitory\\hm_openai_chatgpt35_turbo\\src\\HmChatGPT35Turbo\\HmChatGPT35Turbo.csproj": {
"version": "1.0.7.1",
"version": "1.0.7.2",
"restore": {
"projectUniqueName": "G:\\repogitory\\hm_openai_chatgpt35_turbo\\src\\HmChatGPT35Turbo\\HmChatGPT35Turbo.csproj",
"projectName": "HmChatGPT35Turbo",
Expand Down Expand Up @@ -74,7 +74,7 @@
"privateAssets": "none"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.302\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.304\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Akitsugu Komiyama")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Akitsugu Komiyama")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.7.2")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.7.2")]
[assembly: System.Reflection.AssemblyProductAttribute("HmChatGPT35Turbo")]
[assembly: System.Reflection.AssemblyTitleAttribute("HmChatGPT35Turbo")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.7.1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.7.2")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
038a1d8ffd35355d658a3e668f00ddbd1795c383
273b59d68d74a20fe1e4a1a488b66955527e61b7
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"{cf709244-a284-419e-832d-0b354ee2950d}":{"type":"HmNetCOM.HmMacroCOMVar","assembly":"HmChatGPT35Turbo, Version=1.0.7.1, Culture=neutral, PublicKeyToken=null","progid":"HmNetCOM.HmMacroCOMVar"},"{bccbe82c-56e1-4056-ae7c-3c4f62806732}":{"type":"HmOpenAIChatGpt35Turbo.HmChatGPT35Turbo","assembly":"HmChatGPT35Turbo, Version=1.0.7.1, Culture=neutral, PublicKeyToken=null","progid":"HmOpenAIChatGpt35Turbo.HmChatGPT35Turbo"},"{9818f69e-a37d-4a03-bca1-c4c172366473}":{"type":"HmOpenAIChatGpt35Turbo.HmChatGPT35TurboSharedMemory","assembly":"HmChatGPT35Turbo, Version=1.0.7.1, Culture=neutral, PublicKeyToken=null","progid":"HmOpenAIChatGpt35Turbo.HmChatGPT35TurboSharedMemory"}}
{"{cf709244-a284-419e-832d-0b354ee2950d}":{"type":"HmNetCOM.HmMacroCOMVar","assembly":"HmChatGPT35Turbo, Version=1.0.7.2, Culture=neutral, PublicKeyToken=null","progid":"HmNetCOM.HmMacroCOMVar"},"{bccbe82c-56e1-4056-ae7c-3c4f62806732}":{"type":"HmOpenAIChatGpt35Turbo.HmChatGPT35Turbo","assembly":"HmChatGPT35Turbo, Version=1.0.7.2, Culture=neutral, PublicKeyToken=null","progid":"HmOpenAIChatGpt35Turbo.HmChatGPT35Turbo"},"{9818f69e-a37d-4a03-bca1-c4c172366473}":{"type":"HmOpenAIChatGpt35Turbo.HmChatGPT35TurboSharedMemory","assembly":"HmChatGPT35Turbo, Version=1.0.7.2, Culture=neutral, PublicKeyToken=null","progid":"HmOpenAIChatGpt35Turbo.HmChatGPT35TurboSharedMemory"}}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177aa2e28fc95f6cf29762436aaa544d3592602f
ccca23bf39ec8db02ea5f925cdac7497d65ddb9e
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/HmChatGPT35Turbo/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.7.1",
"version": "1.0.7.2",
"restore": {
"projectUniqueName": "G:\\repogitory\\hm_openai_chatgpt35_turbo\\src\\HmChatGPT35Turbo\\HmChatGPT35Turbo.csproj",
"projectName": "HmChatGPT35Turbo",
Expand Down Expand Up @@ -663,7 +663,7 @@
"privateAssets": "none"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.302\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.304\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/HmChatGPT35Turbo/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "JPhKo706ioDkGMBAtYavGb9GZ07lAm3tUQRWWK1O54TCeLt7l3oDBoapiTFcMVE6bxYq+nMY1dpiJ06Q/9J6ug==",
"dgSpecHash": "d4J7zcgsKL/+ZFi6wvCPX9ZUTRBLauCa8SJp71oeDLc1ZcEN4YeaVwshZ6x9+XRuecrfr0t1/D4SXB98Ud6pxA==",
"success": true,
"projectFilePath": "G:\\repogitory\\hm_openai_chatgpt35_turbo\\src\\HmChatGPT35Turbo\\HmChatGPT35Turbo.csproj",
"expectedPackageFiles": [
Expand Down

0 comments on commit 7302e18

Please sign in to comment.