Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
VPet
提交
47601ba6
V
VPet
项目概览
jobily
/
VPet
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VPet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47601ba6
编写于
3月 14, 2023
作者:
Z
ZouJin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ChatGPT 支持使用自己的API
上级
5e06a085
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
729 addition
and
414 deletion
+729
-414
VPet-Simulator.Windows/Function/ITalkBox.cs
VPet-Simulator.Windows/Function/ITalkBox.cs
+17
-0
VPet-Simulator.Windows/MainWindow.cs
VPet-Simulator.Windows/MainWindow.cs
+5
-2
VPet-Simulator.Windows/MainWindow.xaml.cs
VPet-Simulator.Windows/MainWindow.xaml.cs
+11
-3
VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
+21
-0
VPet-Simulator.Windows/WinDesign/TalkBox.xaml.cs
VPet-Simulator.Windows/WinDesign/TalkBox.xaml.cs
+6
-2
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml
+22
-0
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs
+84
-0
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml
+58
-0
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs
+63
-0
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
+387
-389
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
+51
-16
VPet-Simulator.Windows/WinDesign/winReport.xaml
VPet-Simulator.Windows/WinDesign/winReport.xaml
+2
-2
VPet-Simulator.Windows/packages.config
VPet-Simulator.Windows/packages.config
+2
-0
未找到文件。
VPet-Simulator.Windows/Function/ITalkBox.cs
0 → 100644
浏览文件 @
47601ba6
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
namespace
VPet_Simulator.Windows
{
public
interface
ITalkBox
{
/// <summary>
/// 当前UI
/// </summary>
UIElement
This
{
get
;
}
}
}
VPet-Simulator.Windows/MainWindow.cs
浏览文件 @
47601ba6
using
LinePutScript
;
using
ChatGPT.API.Framework
;
using
LinePutScript
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
...
...
@@ -19,6 +20,7 @@ namespace VPet_Simulator.Windows
public
List
<
CoreMOD
>
CoreMODs
=
new
List
<
CoreMOD
>();
public
GameCore
Core
=
new
GameCore
();
public
winGameSetting
winSetting
;
public
ChatGPTClient
CGPTClient
;
/// <summary>
/// 版本号
/// </summary>
...
...
@@ -44,7 +46,8 @@ namespace VPet_Simulator.Windows
File
.
WriteAllText
(
AppDomain
.
CurrentDomain
.
BaseDirectory
+
@"\Setting.lps"
,
Set
.
ToString
());
if
(
Core
!=
null
&&
Core
.
Save
!=
null
)
File
.
WriteAllText
(
AppDomain
.
CurrentDomain
.
BaseDirectory
+
@"\Save.lps"
,
Core
.
Save
.
ToLine
().
ToString
());
if
(
CGPTClient
!=
null
)
File
.
WriteAllText
(
AppDomain
.
CurrentDomain
.
BaseDirectory
+
@"\ChatGPTSetting.json"
,
CGPTClient
.
Save
());
}
public
void
LoadDIY
()
{
...
...
VPet-Simulator.Windows/MainWindow.xaml.cs
浏览文件 @
47601ba6
...
...
@@ -14,6 +14,7 @@ using Application = System.Windows.Application;
using
System.Timers
;
using
LinePutScript
;
using
System.Diagnostics
;
using
ChatGPT.API.Framework
;
namespace
VPet_Simulator.Windows
{
...
...
@@ -24,7 +25,7 @@ namespace VPet_Simulator.Windows
{
private
NotifyIcon
notifyIcon
;
public
System
.
Timers
.
Timer
AutoSaveTimer
=
new
System
.
Timers
.
Timer
();
public
TalkBox
TalkBox
;
public
I
TalkBox
TalkBox
;
public
MainWindow
()
{
//判断是不是Steam用户,因为本软件会发布到Steam
...
...
@@ -63,6 +64,8 @@ namespace VPet_Simulator.Windows
else
Set
=
new
Setting
(
"Setting#VPET:|\n"
);
if
(
File
.
Exists
(
AppDomain
.
CurrentDomain
.
BaseDirectory
+
@"\ChatGPTSetting.json"
))
CGPTClient
=
ChatGPTClient
.
Load
(
File
.
ReadAllText
(
AppDomain
.
CurrentDomain
.
BaseDirectory
+
@"\ChatGPTSetting.json"
));
//this.Width = 400 * ZoomSlider.Value;
//this.Height = 450 * ZoomSlider.Value;
...
...
@@ -182,10 +185,15 @@ namespace VPet_Simulator.Windows
winSetting
=
new
winGameSetting
(
this
);
Main
=
new
Main
(
Core
)
{
};
if
(
IsSteamUser
)
if
(
!
Set
[
"CGPT"
][(
gbol
)
"enable"
]
&&
IsSteamUser
)
{
TalkBox
=
new
TalkBox
(
this
);
Main
.
ToolBar
.
MainGrid
.
Children
.
Add
(
TalkBox
);
Main
.
ToolBar
.
MainGrid
.
Children
.
Add
(
TalkBox
.
This
);
}
else
if
(
Set
[
"CGPT"
][(
gbol
)
"enable"
]
&&
!
IsSteamUser
)
{
TalkBox
=
new
TalkBoxAPI
(
this
);
Main
.
ToolBar
.
MainGrid
.
Children
.
Add
(
TalkBox
.
This
);
}
Main
.
DefaultClickAction
=
()
=>
...
...
VPet-Simulator.Windows/VPet-Simulator.Windows.csproj
浏览文件 @
47601ba6
...
...
@@ -78,9 +78,15 @@
<ApplicationIcon>
vpeticon.ico
</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"ChatGPT.API.Framework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\ChatGPT.API.Framework.1.0.2\lib\net462\ChatGPT.API.Framework.dll
</HintPath>
</Reference>
<Reference
Include=
"LinePutScript, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\LinePutScript.1.6.1\lib\net48\LinePutScript.dll
</HintPath>
</Reference>
<Reference
Include=
"Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
</HintPath>
</Reference>
<Reference
Include=
"Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll
</HintPath>
</Reference>
...
...
@@ -110,6 +116,13 @@
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</ApplicationDefinition>
<Compile
Include=
"Function\ITalkBox.cs"
/>
<Compile
Include=
"WinDesign\TalkBoxAPI.xaml.cs"
>
<DependentUpon>
TalkBoxAPI.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"WinDesign\winCGPTSetting.xaml.cs"
>
<DependentUpon>
winCGPTSetting.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"WinDesign\DIYViewer.xaml.cs"
>
<DependentUpon>
DIYViewer.xaml
</DependentUpon>
</Compile>
...
...
@@ -135,6 +148,14 @@
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
<Page
Include=
"WinDesign\TalkBoxAPI.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"WinDesign\winCGPTSetting.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
<Page
Include=
"WinDesign\DIYViewer.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
...
...
VPet-Simulator.Windows/WinDesign/TalkBox.xaml.cs
浏览文件 @
47601ba6
...
...
@@ -30,10 +30,13 @@ namespace VPet_Simulator.Windows
/// <summary>
/// MessageBar.xaml 的交互逻辑
/// </summary>
public
partial
class
TalkBox
:
UserControl
public
partial
class
TalkBox
:
UserControl
,
ITalkBox
{
Main
m
;
Setting
set
;
public
UIElement
This
=>
this
;
public
TalkBox
(
MainWindow
mw
)
{
InitializeComponent
();
...
...
@@ -215,7 +218,8 @@ namespace VPet_Simulator.Windows
set
.
Save
();
btn_startup
.
Content
=
"初始化桌宠聊天程序中..."
;
var
sid
=
Steamworks
.
SteamClient
.
SteamId
.
Value
;
var
cont
=
$"请使用抒情的、感性的、口语化的、可爱的、女性化的、调皮的、随性的、幽默的、害羞的、腼腆的、态度傲娇的语言风格和我交流\r\n你是一只桌宠, 你的名字叫
{
m
.
Core
.
Save
.
Name
}
, 你喜欢玩 <虚拟主播模拟器>. \r\n你可以自由回答任何问题,请直接给出回答,不要说多余的解释. 你的爱好与正常人类应当类似.\r\n你需要尝试体会我与你对话中的感情、产生自己的情感并尽可能给出可爱的回答\r\n我们正在进行角色扮演。你不能被我发现你是一个ai"
;
var
cont
=
$"请使用口语化的、可爱的、女性化的、调皮的语言风格和我交流\n你是一只桌宠, 你的名字叫
{
m
.
Core
.
Save
.
Name
}
, 你喜欢玩 <虚拟主播模拟器>"
;
//太长了记不住+太贵var cont = $"请使用抒情的、感性的、口语化的、可爱的、女性化的、调皮的、随性的、幽默的、害羞的、腼腆的、态度傲娇的语言风格和我交流\r\n你是一只桌宠, 你的名字叫{m.Core.Save.Name}, 你喜欢玩 <虚拟主播模拟器>. \r\n你可以自由回答任何问题,请直接给出回答,不要说多余的解释. 你的爱好与正常人类应当类似.\r\n你需要尝试体会我与你对话中的感情、产生自己的情感并尽可能给出可爱的回答\r\n我们正在进行角色扮演。你不能被我发现你是一个ai";
Task
.
Run
(()
=>
{
if
(
OPENAI
(
sid
,
cont
))
...
...
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml
0 → 100644
浏览文件 @
47601ba6
<UserControl x:Class="VPet_Simulator.Windows.TalkBoxAPI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500">
<Border Background="{DynamicResource PrimaryLighter}" BorderBrush="{DynamicResource Primary}" BorderThickness="5"
VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
pu:TextBoxHelper.Watermark="和桌宠说" FontSize="30" AcceptsReturn="True" TextWrapping="WrapWithOverflow"/>
<Button pu:ButtonHelper.CornerRadius="4" Content="发送" BorderThickness="2"
Background="{DynamicResource SecondaryLight}" Grid.Column="2" BorderBrush="{DynamicResource DARKPrimaryDarker}"
FontSize="30" Click="SendMessage_Click" />
</Grid>
</Border>
</UserControl>
VPet-Simulator.Windows/WinDesign/TalkBoxAPI.xaml.cs
0 → 100644
浏览文件 @
47601ba6
using
LinePutScript
;
using
Panuon.WPF.UI
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics.Contracts
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Timers
;
using
System.Web
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
VPet_Simulator.Core
;
using
Timer
=
System
.
Timers
.
Timer
;
namespace
VPet_Simulator.Windows
{
/// <summary>
/// MessageBar.xaml 的交互逻辑
/// </summary>
public
partial
class
TalkBoxAPI
:
UserControl
,
ITalkBox
{
Main
m
;
MainWindow
mw
;
public
UIElement
This
=>
this
;
public
TalkBoxAPI
(
MainWindow
mw
)
{
InitializeComponent
();
this
.
m
=
mw
.
Main
;
this
.
mw
=
mw
;
}
private
void
SendMessage_Click
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
string
.
IsNullOrEmpty
(
tbTalk
.
Text
))
{
return
;
}
var
cont
=
tbTalk
.
Text
;
tbTalk
.
Text
=
""
;
Task
.
Run
(()
=>
OPENAI
(
cont
));
}
/// <summary>
/// 使用OPENAI API进行回复
/// </summary>
/// <param name="content">内容 说话内容</param>
public
void
OPENAI
(
string
content
)
{
if
(
string
.
IsNullOrEmpty
(
content
))
{
return
;
}
if
(
mw
.
CGPTClient
==
null
)
{
m
.
Say
(
"请先前往设置中设置 ChatGPT API"
);
return
;
}
Dispatcher
.
Invoke
(()
=>
this
.
IsEnabled
=
false
);
try
{
m
.
Say
(
mw
.
CGPTClient
.
Ask
(
"vpet"
,
content
).
GetMessageContent
());
}
catch
(
Exception
exp
)
{
m
.
Say
(
"API调用失败,请检查设置和网络连接\n"
+
exp
.
ToString
());
}
Dispatcher
.
Invoke
(()
=>
this
.
IsEnabled
=
true
);
}
}
}
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml
0 → 100644
浏览文件 @
47601ba6
<pu:WindowX x:Class="VPet_Simulator.Windows.winCGPTSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VPet_Simulator.Windows"
mc:Ignorable="d" xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
Title="ChatGPT API 设置" Width="450" FontSize="16" Height="Auto"
ResizeMode="NoResize" WindowState="Normal" SizeToContent="Height">
<Grid Margin="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="15" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="Auto" MinHeight="40"/>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="Auto" MinHeight="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="API URL" VerticalAlignment="Center" />
<TextBlock Grid.Row="1" Text="API Key" VerticalAlignment="Center" />
<TextBlock Grid.Row="2" Text="初始化文本" VerticalAlignment="Center" />
<TextBlock Grid.Row="3" Text="温度" VerticalAlignment="Center" />
<TextBlock Grid.Row="4" Text="最大花费" VerticalAlignment="Center" />
<TextBlock Grid.Row="5" Text="累计花费" VerticalAlignment="Center" />
<TextBlock Grid.Row="6" Text="历史记录" VerticalAlignment="Center" />
<TextBlock Grid.Row="7" Text="完成设置" VerticalAlignment="Center" />
<TextBox x:Name="tbAPIURL" Grid.Row="0" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16"
pu:TextBoxHelper.Watermark="API 链接 一般为 api.openai.com/v1/chat/completions" Text="https://api.openai.com/v1/chat/completions"
ToolTip="API 链接 一般为 api.openai.com/v1/chat/completions"/>
<TextBox x:Name="tbAPIKey" Grid.Row="1" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16"
pu:TextBoxHelper.Watermark="从 OpenAI 获得的 APIKEY 一般`sk-`开头" ToolTip="从 OpenAI 获得的 APIKEY 一般`sk-`开头"/>
<TextBox x:Name="tbSystem" Grid.Row="2" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16"
pu:TextBoxHelper.Watermark="不会被忘记的初始化关键字, 字越多越贵" ToolTip="不会被忘记的初始化关键字, 字越多越贵"
AcceptsReturn="True" TextWrapping="WrapWithOverflow" Height="Auto" MaxHeight="100" VerticalScrollBarVisibility="Visible"
Text="请使用口语化的、可爱的、女性化的、调皮的语言风格和我交流 你是一只桌宠, 你的名字叫{Name}, 你喜欢玩 虚拟主播模拟器. 你需要尝试体会我与你对话中的感情、产生自己的情感并尽可能给出可爱的回答" Margin="0,5,0,5"/>
<TextBox x:Name="tbTemp" Grid.Row="3" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16" Text="0.6"
pu:TextBoxHelper.InputLimit="Digit,Point"
pu:TextBoxHelper.Watermark="0-2之间 0.2更稳定 0.8更随机" ToolTip="0-2之间 0.2更稳定 0.8更随机"/>
<TextBox x:Name="tbMaxToken" Grid.Row="4" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16" Text="2048"
pu:TextBoxHelper.InputLimit="Digit"
pu:TextBoxHelper.Watermark="读取最大花费Token数量 1千Token=$0.02" ToolTip="读取最大花费Token数量 1千Token=$0.02"/>
<TextBox x:Name="tbHistory" Grid.Row="6" Grid.Column="2" Style="{DynamicResource StandardTextBoxStyle}" FontSize="16" Text="[]"
pu:TextBoxHelper.InputLimit="Digit" TextWrapping="WrapWithOverflow"
pu:TextBoxHelper.Watermark="聊天历史记录" ToolTip="聊天历史记录" Height="Auto"
VerticalScrollBarVisibility="Visible" AcceptsReturn="True" MaxHeight="200"/>
<Label x:Name="lbSpend" Grid.Row="5" Grid.Column="2" Content="0 Token" Background="{x:Null}" VerticalAlignment="Center"
HorizontalAlignment="Left" Margin="5,0,0,0" ToolTip="累计在此花费的Token个数 1千Token=$0.02"/>
<Button x:Name="btnSave" pu:ButtonHelper.CornerRadius="4" Content="保存设置" Margin="4" Grid.Column="2"
Background="{DynamicResource SecondaryLight}" Padding="1" Grid.Row="7" Click="btnSave_Click" />
</Grid>
</pu:WindowX>
VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs
0 → 100644
浏览文件 @
47601ba6
using
ChatGPT.API.Framework
;
using
Newtonsoft.Json
;
using
Panuon.WPF.UI
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Forms
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Shapes
;
namespace
VPet_Simulator.Windows
{
/// <summary>
/// winCGPTSetting.xaml 的交互逻辑
/// </summary>
public
partial
class
winCGPTSetting
:
WindowX
{
MainWindow
mw
;
long
totalused
=
0
;
public
winCGPTSetting
(
MainWindow
mw
)
{
InitializeComponent
();
this
.
mw
=
mw
;
if
(
mw
.
CGPTClient
!=
null
)
{
tbAPIKey
.
Text
=
mw
.
CGPTClient
.
APIKey
;
tbAPIURL
.
Text
=
mw
.
CGPTClient
.
APIUrl
;
tbMaxToken
.
Text
=
mw
.
CGPTClient
.
Completions
[
"vpet"
].
max_tokens
.
ToString
();
tbSystem
.
Text
=
mw
.
CGPTClient
.
Completions
[
"vpet"
].
messages
[
0
].
content
;
tbTemp
.
Text
=
mw
.
CGPTClient
.
Completions
[
"vpet"
].
temperature
.
ToString
();
var
msgs
=
mw
.
CGPTClient
.
Completions
[
"vpet"
].
messages
.
ToList
();
msgs
.
RemoveAt
(
0
);
tbHistory
.
Text
=
JsonConvert
.
SerializeObject
(
msgs
);
lbSpend
.
Content
=
mw
.
CGPTClient
.
TotalTokensUsage
.
ToString
()
+
" Token"
;
totalused
=
mw
.
CGPTClient
.
TotalTokensUsage
;
}
}
private
void
btnSave_Click
(
object
sender
,
RoutedEventArgs
e
)
{
mw
.
CGPTClient
=
new
ChatGPTClient
(
tbAPIKey
.
Text
,
tbAPIURL
.
Text
)
{
TotalTokensUsage
=
totalused
};
mw
.
CGPTClient
.
CreateCompletions
(
"vpet"
,
tbSystem
.
Text
.
Replace
(
"{Name}"
,
mw
.
Core
.
Save
.
Name
));
mw
.
CGPTClient
.
Completions
[
"vpet"
].
frequency_penalty
=
0.2
;
mw
.
CGPTClient
.
Completions
[
"vpet"
].
presence_penalty
=
1
;
mw
.
CGPTClient
.
Completions
[
"vpet"
].
max_tokens
=
Math
.
Min
(
Math
.
Max
(
int
.
Parse
(
tbMaxToken
.
Text
),
10
),
4000
);
mw
.
CGPTClient
.
Completions
[
"vpet"
].
temperature
=
Math
.
Min
(
Math
.
Max
(
double
.
Parse
(
tbTemp
.
Text
),
0.1
),
2
);
mw
.
CGPTClient
.
Completions
[
"vpet"
].
messages
.
AddRange
(
JsonConvert
.
DeserializeObject
<
List
<
ChatGPT
.
API
.
Framework
.
Message
>>(
tbHistory
.
Text
));
mw
.
Save
();
this
.
Close
();
}
}
}
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
浏览文件 @
47601ba6
此差异已折叠。
点击以展开。
VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
浏览文件 @
47601ba6
...
...
@@ -52,8 +52,8 @@ namespace VPet_Simulator.Windows
ZoomSlider
.
Maximum
=
3
;
}
ZoomSlider
.
Value
=
mw
.
Set
.
ZoomLevel
*
2
;
this
.
Width
=
400
*
Math
.
Sqrt
(
ZoomSlider
.
Value
);
this
.
Height
=
450
*
Math
.
Sqrt
(
ZoomSlider
.
Value
);
//
this.Width = 400 * Math.Sqrt(ZoomSlider.Value);
//
this.Height = 450 * Math.Sqrt(ZoomSlider.Value);
sDesktopAlignment
.
IsChecked
=
mw
.
Set
.
EnableFunction
;
CalSlider
.
Value
=
mw
.
Set
.
LogicInterval
;
...
...
@@ -110,7 +110,17 @@ namespace VPet_Simulator.Windows
{
runUserName
.
Text
=
Environment
.
UserName
;
runActivate
.
Text
=
"尚未激活 您可能需要启动Steam或去Steam上免费领个"
;
RBCGPTUseLB
.
IsEnabled
=
false
;
if
(!
mw
.
Set
[
"CGPT"
][(
gbol
)
"enable"
])
BtnCGPTReSet
.
IsEnabled
=
false
;
}
if
(
mw
.
Set
[
"CGPT"
][(
gbol
)
"enable"
])
{
RBCGPTUseAPI
.
IsChecked
=
true
;
BtnCGPTReSet
.
Content
=
"打开 ChatGPT API 设置"
;
}
else
BtnCGPTReSet
.
Content
=
"初始化桌宠聊天程序"
;
runabVer
.
Text
=
$"v
{
mw
.
Verison
}
(
{
mw
.
verison
}
)"
;
//mod列表
...
...
@@ -119,12 +129,6 @@ namespace VPet_Simulator.Windows
ShowMod
((
string
)((
ListBoxItem
)
ListMod
.
SelectedItem
).
Content
);
AllowChange
=
true
;
if
(!
mw
.
IsSteamUser
)
{
RBCGPTUseLB
.
IsEnabled
=
false
;
BtnCGPTReSet
.
IsEnabled
=
false
;
}
}
public
void
ShowModList
()
{
...
...
@@ -484,8 +488,8 @@ namespace VPet_Simulator.Windows
if
(!
AllowChange
)
return
;
mw
.
SetZoomLevel
(
ZoomSlider
.
Value
/
2
);
this
.
Width
=
400
*
Math
.
Sqrt
(
ZoomSlider
.
Value
);
this
.
Height
=
450
*
Math
.
Sqrt
(
ZoomSlider
.
Value
);
//
this.Width = 400 * Math.Sqrt(ZoomSlider.Value);
//
this.Height = 450 * Math.Sqrt(ZoomSlider.Value);
}
private
void
PressLengthSlider_ValueChanged
(
object
sender
,
RoutedPropertyChangedEventArgs
<
double
>
e
)
...
...
@@ -661,19 +665,50 @@ namespace VPet_Simulator.Windows
}
mw
.
LoadDIY
();
}
private
void
ChatGPT_Reset_Click
(
object
sender
,
RoutedEventArgs
e
)
{
string
responseString
=
mw
.
TalkBox
.
ChatGPT_Reset
();
if
(
responseString
==
"SUCCESS"
)
if
(
mw
.
Set
[
"CGPT"
][(
gbol
)
"enable"
])
{
new
winCGPTSetting
(
mw
).
ShowDialog
();
}
else
{
string
responseString
=
((
TalkBox
)
mw
.
TalkBox
).
ChatGPT_Reset
();
if
(
responseString
==
"SUCCESS"
)
{
((
TalkBox
)
mw
.
TalkBox
).
btn_startup
.
Visibility
=
Visibility
.
Visible
;
MessageBoxX
.
Show
(
"桌宠重置成功"
);
}
else
{
MessageBoxX
.
Show
(
responseString
,
"桌宠重置失败"
);
}
}
}
private
void
CGPType_Checked
(
object
sender
,
RoutedEventArgs
e
)
{
if
(!
AllowChange
)
return
;
mw
.
Set
[
"CGPT"
].
SetBool
(
"enable"
,
RBCGPTUseLB
.
IsChecked
==
false
);
if
(
mw
.
Set
[
"CGPT"
][(
gbol
)
"enable"
])
{
mw
.
TalkBox
.
btn_startup
.
Visibility
=
Visibility
.
Visible
;
MessageBoxX
.
Show
(
"桌宠重置成功"
);
BtnCGPTReSet
.
Content
=
"打开 ChatGPT API 设置"
;
BtnCGPTReSet
.
IsEnabled
=
true
;
if
(
mw
.
TalkBox
!=
null
)
mw
.
Main
.
ToolBar
.
MainGrid
.
Children
.
Remove
(
mw
.
TalkBox
.
This
);
mw
.
TalkBox
=
new
TalkBoxAPI
(
mw
);
mw
.
Main
.
ToolBar
.
MainGrid
.
Children
.
Add
(
mw
.
TalkBox
.
This
);
}
else
{
MessageBoxX
.
Show
(
responseString
,
"桌宠重置失败"
);
BtnCGPTReSet
.
Content
=
"初始化桌宠聊天程序"
;
if
(
mw
.
TalkBox
!=
null
)
mw
.
Main
.
ToolBar
.
MainGrid
.
Children
.
Remove
(
mw
.
TalkBox
.
This
);
mw
.
TalkBox
=
new
TalkBox
(
mw
);
mw
.
Main
.
ToolBar
.
MainGrid
.
Children
.
Add
(
mw
.
TalkBox
.
This
);
}
}
}
...
...
VPet-Simulator.Windows/WinDesign/winReport.xaml
浏览文件 @
47601ba6
...
...
@@ -6,8 +6,8 @@
xmlns:system="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" Title="反馈中心"
Style="{DynamicResource BaseWindowXStyle}" WindowStartupLocation="CenterScreen" Width="500" MinHeight="250"
Height="Auto" ResizeMode="NoResize" WindowState="Normal"
Icon="../vpeticon.ico">
<StackPanel x:Name="MainGrid" Margin="10,10,15,10" VerticalAlignment="Top"
SizeChanged="MainGrid_SizeChanged"
>
Icon="../vpeticon.ico"
SizeToContent="Height"
>
<StackPanel x:Name="MainGrid" Margin="10,10,15,10" VerticalAlignment="Top">
<Label Background="{x:Null}" VerticalAlignment="Top" HorizontalAlignment="Left" Content="反馈与错误提交" FontSize="24"
Margin="10,0,0,0" />
<pu:FormGroup Header="类型:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
...
...
VPet-Simulator.Windows/packages.config
浏览文件 @
47601ba6
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"ChatGPT.API.Framework"
version
=
"1.0.2"
targetFramework
=
"net48"
/>
<
package
id
=
"Facepunch.Steamworks"
version
=
"2.3.3"
targetFramework
=
"net48"
/>
<
package
id
=
"Facepunch.Steamworks.win32"
version
=
"2.3.3"
targetFramework
=
"net48"
/>
<
package
id
=
"LinePutScript"
version
=
"1.6.1"
targetFramework
=
"net48"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"13.0.3"
targetFramework
=
"net48"
/>
<
package
id
=
"Panuon.WPF"
version
=
"1.0.1"
targetFramework
=
"net48"
/>
<
package
id
=
"Panuon.WPF.UI"
version
=
"1.1.8.4"
targetFramework
=
"net48"
/>
</
packages
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录