Skip to content

Commit f4c6151

Browse files
authored
Merge pull request #79 from marcominerva/functions
Updates and Optimizations
2 parents 1dc39b1 + bee3a8e commit f4c6151

File tree

15 files changed

+116
-181
lines changed

15 files changed

+116
-181
lines changed

.github/workflows/codeql.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

samples/DatabaseGpt.Web/DatabaseGpt.Web.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<SourceRevisionId>build$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</SourceRevisionId>
77
<Company>Marco Minerva</Company>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.426" />
12-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
13-
<PackageReference Include="MinimalHelpers.OpenApi" Version="2.0.16" />
14-
<PackageReference Include="MinimalHelpers.Routing.Analyzers" Version="1.0.13" />
15-
<PackageReference Include="OperationResultTools.AspNetCore.Http" Version="1.0.25" />
16-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
17-
<PackageReference Include="TinyHelpers" Version="3.1.18" />
18-
<PackageReference Include="TinyHelpers.AspNetCore" Version="3.1.19" />
11+
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.436" />
12+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
13+
<PackageReference Include="MinimalHelpers.OpenApi" Version="2.1.7" />
14+
<PackageReference Include="MinimalHelpers.Routing.Analyzers" Version="1.1.3" />
15+
<PackageReference Include="OperationResultTools.AspNetCore.Http" Version="1.0.28" />
16+
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.2" />
17+
<PackageReference Include="TinyHelpers" Version="3.2.25" />
18+
<PackageReference Include="TinyHelpers.AspNetCore" Version="4.0.26" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

samples/DatabaseGptConsole/DatabaseGptConsole.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<FileVersion>1.4</FileVersion>
99
<AssemblyVersion>1.4</AssemblyVersion>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Spectre.Console" Version="0.49.1" />
14-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
13+
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
14+
<PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
15+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.5.0-preview.1.25265.7" />
16+
<PackageReference Include="Spectre.Console" Version="0.50.0" />
17+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.5" />
1518
</ItemGroup>
1619

1720
<ItemGroup>

samples/DatabaseGptConsole/Program.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using ChatGptNet;
1+
using Azure;
2+
using Azure.AI.OpenAI;
23
using DatabaseGpt;
34
using DatabaseGptConsole;
5+
using Microsoft.Extensions.AI;
46
using Microsoft.Extensions.Configuration;
57
using Microsoft.Extensions.DependencyInjection;
68
using Microsoft.Extensions.Hosting;
@@ -29,6 +31,17 @@ static void ConfigureServices(HostBuilderContext context, IServiceCollection ser
2931
{
3032
services.AddSingleton<Application>();
3133

34+
services.AddHybridCache();
35+
36+
var apiKey = context.Configuration.GetValue<string>("ChatGPT:ApiKey")!;
37+
var deploymentName = context.Configuration.GetValue<string>("ChatGPT:DeploymentName")!;
38+
var endpoint = context.Configuration.GetValue<string>("ChatGpt:Endpoint")!;
39+
40+
var azureOpenAIClient = new AzureOpenAIClient(new(endpoint), new AzureKeyCredential(apiKey));
41+
var chatClient = azureOpenAIClient.GetChatClient(deploymentName).AsIChatClient();
42+
43+
services.AddChatClient(chatClient);
44+
3245
services.AddDatabaseGpt(database =>
3346
{
3447
// For SQL Server.
@@ -42,9 +55,5 @@ static void ConfigureServices(HostBuilderContext context, IServiceCollection ser
4255
// For SQLite.
4356
//database.UseConfiguration(context.Configuration)
4457
// .UseSqlite(context.Configuration.GetConnectionString("SqliteConnection"));
45-
},
46-
chatGpt =>
47-
{
48-
chatGpt.UseConfiguration(context.Configuration);
4958
});
5059
}

samples/DatabaseGptConsole/appsettings.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
"SqlConnection": ""
44
},
55
"ChatGPT": {
6-
"Provider": "OpenAI",
76
"ApiKey": "",
8-
"Organization": "",
9-
"ResourceName": "",
10-
"AuthenticationType": "ApiKey",
11-
"DefaultModel": "gpt-3.5-turbo-16k",
7+
"Endpoint": "",
8+
"DeploymentName": "",
129
"MessageLimit": 20,
1310
"MessageExpiration": "00:30:00"
1411
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
10+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.5" />
1111
</ItemGroup>
1212

1313
</Project>

src/DatabaseGpt.Npgsql/DatabaseGpt.Npgsql.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Dapper" Version="2.1.35" />
11-
<PackageReference Include="Npgsql" Version="8.0.5" />
10+
<PackageReference Include="Dapper" Version="2.1.66" />
11+
<PackageReference Include="Npgsql" Version="9.0.3" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/DatabaseGpt.SqlServer/DatabaseGpt.SqlServer.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
11-
<PackageReference Include="Dapper" Version="2.1.35" />
10+
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.0.2" />
11+
<PackageReference Include="Dapper" Version="2.1.66" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/DatabaseGpt.SqlServer/Models/ColumnEntity.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/DatabaseGpt.SqlServer/SqlServerDatabaseGptProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Dapper;
55
using DatabaseGpt.Abstractions;
66
using DatabaseGpt.Abstractions.Exceptions;
7-
using DatabaseGpt.SqlServer.Models;
87
using Microsoft.Data.SqlClient;
98

109
namespace DatabaseGpt.SqlServer;
@@ -68,7 +67,7 @@ FROM INFORMATION_SCHEMA.COLUMNS
6867
AND TABLE_SCHEMA + '.' + TABLE_NAME + '.' + COLUMN_NAME NOT IN @{nameof(excludedColumns)};
6968
""";
7069

71-
var columns = await connection.QueryAsync<ColumnEntity>(query, new { schema = table.Schema, table = table.Name, excludedColumns });
70+
var columns = await connection.QueryAsync<string>(query, new { schema = table.Schema, table = table.Name, excludedColumns });
7271

7372
result.AppendLine($"CREATE TABLE [{table.Schema}].[{table.Name}] ({string.Join(',', columns)});");
7473
}

0 commit comments

Comments
 (0)