Skip to content

Instantly share code, notes, and snippets.

View sdcb's full-sized avatar
👋
Console.WriteLine("Hello World");

ZHOU Jie sdcb

👋
Console.WriteLine("Hello World");
View GitHub Profile
@sdcb
sdcb / mcp-client.linq
Created July 21, 2025 09:23
mcp-protocol-dotnet
<Query Kind="Statements">
<NuGetReference Prerelease="true">ModelContextProtocol</NuGetReference>
<Namespace>ModelContextProtocol</Namespace>
<Namespace>ModelContextProtocol.Client</Namespace>
<Namespace>System.Text.Json.Nodes</Namespace>
</Query>
var clientTransport = new SseClientTransport(new SseClientTransportOptions()
{
Name = "MyServer",
diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc
index c9d5b7c..dbac930 100644
--- a/paddle/fluid/inference/api/analysis_predictor.cc
+++ b/paddle/fluid/inference/api/analysis_predictor.cc
@@ -447,7 +447,9 @@ bool AnalysisPredictor::Init(
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
std::string model_path = config_.prog_file();
- if (!model_path.empty()) {
+ if (config_.model_from_memory()) {
-- UserApiCache 主表
CREATE TABLE `UserApiCache` (
`Id` INTEGER PRIMARY KEY AUTOINCREMENT,
`UserApiKeyId` INTEGER NOT NULL,
`ModelId` INTEGER NOT NULL,
`RequestHashCode` INTEGER NOT NULL,
`Expires` DATETIME NOT NULL,
`ClientInfoId` INTEGER NOT NULL,
`CreatedAt` DATETIME NOT NULL,
FOREIGN KEY (`ClientInfoId`) REFERENCES `ClientInfo`(`Id`),
-- INSERT 语句
INSERT INTO `ModelReference` (`Id`, `ProviderId`, `Name`, `DisplayName`, `PublishDate`, `MinTemperature`, `MaxTemperature`, `AllowSearch`, `AllowVision`, `AllowSystemPrompt`, `AllowStreaming`, `ReasoningResponseKindId`, `ContextWindow`, `MaxResponseTokens`, `TokenizerId`, `InputTokenPrice1M`, `OutputTokenPrice1M`, `CurrencyCode`)
VALUES
(121, 1, 'gpt-4.1', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 2, 8, 'USD'),
(122, 1, 'gpt-4.1-mini', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 0.4, 1.6, 'USD'),
(123, 1, 'gpt-4.1-nano', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 0.1, 0.4, 'USD'),
(521, 5, 'gpt-4.1', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 2, 8, 'USD'),
(522, 5, 'gpt-4.1-mini', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 0.4, 1.6, 'USD'),
(523, 5, 'gpt-4.1-nano', 'gpt-4.1', '2025-04-14', 0, 2, 0, 1, 1, 1, 0, 1047576, 32768, 2, 0.1, 0.4, 'USD'),
(1223, 12,
-- 更新 AllowSearch 为 1
UPDATE `ModelReference` SET `AllowSearch` = 1 WHERE `Id` = 1301;
-- 插入多行数据
INSERT INTO `ModelReference` (`Id`, `ProviderId`, `Name`, `DisplayName`, `PublishDate`, `MinTemperature`, `MaxTemperature`, `AllowSearch`, `AllowVision`, `AllowSystemPrompt`, `AllowStreaming`, `ReasoningResponseKindId`, `ContextWindow`, `MaxResponseTokens`, `TokenizerId`, `InputTokenPrice1M`, `OutputTokenPrice1M`, `CurrencyCode`)
VALUES
(1304, 13, 'gemini-2.0-flash-exp', 'gemini', '2025-03-25', 0, 2, 0, 1, 0, 1, 0, 32768, 8000, NULL, 0, 0, 'USD'),
(209, 2, 'hunyuan-t1-latest', NULL, '2025-04-03', 0, 2, 1, 0, 1, 1, 1, 64000, 64000, NULL, 1, 4, 'RMB'),
(210, 2, 'hunyuan-turbos-latest', NULL, '2025-03-13', 0, 2, 1, 0, 1, 1, 0, 32000, 8000, NULL, 0.8, 2, 'RMB'),
(1104, 11, 'grok-3', 'grok-3', '2025-04-10', 0, 2, 0, 0, 1, 1, 0, 131072, 16384, NULL, 3, 15, 'USD'),
-------------------------------------------------------------------------------
-- 1~4 合并:ChatPreset 和 ChatPresetSpan 表的创建 + ModelReference 数据插入和更新
-------------------------------------------------------------------------------
-- ChatPreset 表
CREATE TABLE `ChatPreset`
(
`Id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`Name` TEXT NOT NULL,
`UserId` INTEGER NOT NULL,
-- 创建主表
CREATE TABLE ChatConfig (
Id INTEGER PRIMARY KEY AUTOINCREMENT,
HashCode INTEGER NOT NULL DEFAULT 0,
ModelId INTEGER NOT NULL,
SystemPrompt TEXT,
Temperature REAL,
WebSearchEnabled INTEGER NOT NULL,
MaxOutputTokens INTEGER,
ReasoningEffort INTEGER NOT NULL,
-- 添加阿里通义千问qwq-32b-preview和qwq-plus模型
-- 添加siliconflow的Qwen/QwQ-32B模型
INSERT INTO `ModelReference`(`Id`, `ProviderId`, `Name`, `DisplayName`, `PublishDate`, `MinTemperature`, `MaxTemperature`, `AllowSearch`, `AllowVision`, `AllowSystemPrompt`, `AllowStreaming`, `ReasoningResponseKindId`, `ContextWindow`, `MaxResponseTokens`, `TokenizerId`, `InputTokenPrice1M`, `OutputTokenPrice1M`, `CurrencyCode`)
VALUES
(735, 7, 'qwq-32b', NULL, '2025-03-07', 0.00, 1.99, 0, 0, 1, 1, 1, 131072, 8192, NULL, 0.00000, 0.00000, 'RMB'),
(736, 7, 'qwq-plus', NULL, '2025-03-07', 0.00, 1.99, 0, 0, 1, 1, 1, 131072, 8192, NULL, 0.00000, 0.00000, 'RMB'),
(1710, 17, 'Qwen/QwQ-32B', NULL, '2025-03-07', 0.00, 2.00, 0, 0, 1, 1, 1, 32768, 8192, NULL, 1.00000, 4.00000, 'RMB');
-- 更新qwq-32b-preview的PublishDate为2024/11/27
INSERT INTO `ModelProvider`(`Id`, `Name`, `InitialHost`, `InitialSecret`, `RequireDeploymentName`)
VALUES (18, 'OpenRouter', 'https://openrouter.ai/api/v1', 'sk-or-v1-***', 1);
INSERT INTO `ModelReference`(`Id`, `ProviderId`, `Name`, `DisplayName`, `PublishDate`, `MinTemperature`, `MaxTemperature`, `AllowSearch`, `AllowVision`, `AllowSystemPrompt`, `AllowStreaming`, `ReasoningResponseKindId`, `ContextWindow`, `MaxResponseTokens`, `TokenizerId`, `InputTokenPrice1M`, `OutputTokenPrice1M`, `CurrencyCode`)
VALUES (1800, 18, 'openrouter-general', null, null, 0, 2, 1, 0, 1, 1, 0, 128000, 8000, null, 0, 0, 'USD');
INSERT INTO `ModelReference`(`Id`, `ProviderId`, `Name`, `DisplayName`, `PublishDate`, `MinTemperature`, `MaxTemperature`, `AllowSearch`, `AllowVision`, `AllowSystemPrompt`, `AllowStreaming`, `ReasoningResponseKindId`, `ContextWindow`, `MaxResponseTokens`, `TokenizerId`, `InputTokenPrice1M`, `OutputTokenPrice1M`, `CurrencyCode`)
VALUES (1801, 18, 'openrouter-vision', null, null, 0, 2, 1, 1, 1, 1, 0, 1280
-- This script is converted from https://github.com/sdcb/chats/blob/3c72c1cea2e3b87a7f4dba71061f89fb65f087f1/src/scripts/db-migration/2025/20250224-more-ds.sql using ChatGPT
-- Region Parameters
UPDATE `ModelProvider`
SET `InitialHost` = 'https://api.hunyuan.cloud.tencent.com/v1', `InitialSecret` = 'sk-'
WHERE `Id` = 2;
UPDATE `ModelKey`
SET `host` = 'https://api.hunyuan.cloud.tencent.com/v1'
WHERE `ModelProviderId` = 2;