-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0ca158b
Showing
733 changed files
with
8,323 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="VisualChatBot.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:VisualChatBot" | ||
StartupUri="Views/VisualChat.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace VisualChatBot | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<ControlTemplate TargetType="Button" x:Key="WindowControlButtomTemplate"> | ||
<Border | ||
Name="Typebutton" | ||
Background="{x:Null}"> | ||
<TextBlock | ||
Text="{Binding Content,RelativeSource={RelativeSource AncestorType=Button,Mode=FindAncestor}}" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center" | ||
FontFamily="../Fonts/#iconfont"/> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter TargetName="Typebutton" Property="Background" Value="#44FFFFFF"/> | ||
</Trigger> | ||
<Trigger Property="IsPressed" Value="True"> | ||
<Setter TargetName="Typebutton" Property="Background" Value="#22FFFFFF"/> | ||
</Trigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
<ControlTemplate TargetType="Button" x:Key="ConfirmButtonTemplate"> | ||
<Border | ||
x:Name="borderBack" | ||
Cursor="Hand" | ||
CornerRadius="5" | ||
BorderBrush="LightGray" | ||
BorderThickness="1"> | ||
<TextBlock | ||
x:Name="ButtonName" | ||
Text="{Binding Content, RelativeSource={RelativeSource AncestorType=Button,Mode=FindAncestor}}" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Foreground="Black"/> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsMouseOver" Value="true"> | ||
<Setter TargetName="borderBack" Property="Background" Value="#C0C0C0"/> | ||
</Trigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
<ControlTemplate TargetType="ToggleButton" x:Key="ToggleButtonTemplate"> | ||
<Border> | ||
<TextBlock | ||
Text="{Binding Content, RelativeSource={RelativeSource AncestorType=ToggleButton,Mode=FindAncestor}}" | ||
FontFamily="../Fonts/#iconfont"/> | ||
</Border> | ||
</ControlTemplate> | ||
<ControlTemplate TargetType="Button" x:Key="MenuBtnTemplate"> | ||
<Border | ||
x:Name="borderBack" | ||
Cursor="Hand" | ||
BorderBrush="LightGray" | ||
BorderThickness="0,0,0,1"> | ||
<TextBlock | ||
x:Name="ButtonName" | ||
Text="{Binding Content, RelativeSource={RelativeSource AncestorType=Button,Mode=FindAncestor}}" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Foreground="Black"/> | ||
</Border> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="IsMouseOver" Value="true"> | ||
<Setter TargetName="borderBack" Property="Background" Value="#C0C0C0"/> | ||
</Trigger> | ||
</ControlTemplate.Triggers> | ||
</ControlTemplate> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VisualChatBot.Models | ||
{ | ||
class HttpGetModel | ||
{ | ||
[JsonProperty("id")] | ||
public string? Id { get; set; } | ||
|
||
[JsonProperty("object")] | ||
public string? Object { get; set; } | ||
|
||
[JsonProperty("created")] | ||
public string? Created { get; set; } | ||
|
||
[JsonProperty("model")] | ||
public string? Model { get; set; } | ||
|
||
[JsonProperty("choices")] | ||
public List<Choices>? Choicese { get; set; } | ||
|
||
[JsonProperty("usage")] | ||
public Usage? Usages { get; set; } | ||
|
||
[JsonProperty("error")] | ||
public ErrorInfo? error { get; set; } | ||
|
||
public class Choices | ||
{ | ||
[JsonProperty("text")] | ||
public string? Text { get; set; } | ||
[JsonProperty("index")] | ||
public string? Index { get; set; } | ||
[JsonProperty("logprobs")] | ||
public string? Logprobs { get; set; } | ||
[JsonProperty("finish_reson")] | ||
public string? Finish_reson { get; set; } | ||
} | ||
public class Usage | ||
{ | ||
[JsonProperty("prompt_tokens")] | ||
public string? Prompt_tokens { get; set; } | ||
[JsonProperty("completion_tokens")] | ||
public string? Completion_tokens { get; set; } | ||
[JsonProperty("total_tokens")] | ||
public string? Total_tokens { get; set; } | ||
} | ||
public class ErrorInfo | ||
{ | ||
[JsonProperty("message")] | ||
public string? message { get; set; } | ||
|
||
[JsonProperty("type")] | ||
public string? type { get; set; } | ||
|
||
[JsonProperty("param")] | ||
public string? param { get; set; } | ||
|
||
[JsonProperty("code")] | ||
public string? code { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net; | ||
using System.Reflection.Metadata; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using VisualChatBot.Models; | ||
|
||
namespace VisualChatBot.Tools | ||
{ | ||
public class WebRequest | ||
{ | ||
public async Task<string?> WebRequestMethon(string apikey,string requestUrl,StringContent input) | ||
{ | ||
try | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apikey}"); | ||
var response = await client.PostAsync(requestUrl, input); | ||
response.Content.Headers.ContentLength = 1024; | ||
var responseContent = await response.Content.ReadAsStringAsync(); | ||
var responType = new HttpGetModel(); | ||
responType = JsonConvert.DeserializeObject<HttpGetModel>(responseContent); | ||
if (response.IsSuccessStatusCode == false) | ||
{ | ||
string errorInfo = $"\n错误类型:{responType.error.type}\n错误内容:{responType.error.message}\n\n"; | ||
return errorInfo; | ||
} | ||
|
||
// 返回接收到的内容 | ||
return await Task.FromResult(result: responType?.Choicese?.First().Text); | ||
} | ||
} | ||
catch(Exception ex) | ||
{ | ||
return $"\n错误:\n{ex}\n"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.