mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-13 07:46:54 +08:00
refactor: restructure project directories for better modularity
- Delete llm/ dead code (3 files, zero references) - Split mcp/ into sub-packages: mcp/provider/ (8 providers) and mcp/payment/ (4 payment clients) with registry pattern - Export Client internal fields and ClientHooks interface for sub-package access - Split api/server.go (3892 lines) into 8 domain-specific handler files - Split trader/auto_trader.go (2296 lines) into 5 focused files - Reorganize web/src/components/ flat files into auth/, charts/, trader/, common/, modals/, backtest/ subdirectories - Update all consumer imports to use registry-based provider creation
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"nofx/mcp"
|
||||
"nofx/mcp/provider"
|
||||
)
|
||||
|
||||
// ============================================================
|
||||
@@ -24,7 +25,7 @@ func Example_backward_compatible() {
|
||||
|
||||
func Example_deepseek_backward_compatible() {
|
||||
// DeepSeek old code continues to work
|
||||
client := mcp.NewDeepSeekClient()
|
||||
client := provider.NewDeepSeekClient()
|
||||
client.SetAPIKey("sk-xxx", "", "")
|
||||
|
||||
result, _ := client.CallWithMessages("system", "user")
|
||||
@@ -141,12 +142,12 @@ func Example_custom_http_client() {
|
||||
|
||||
func Example_deepseek_new_api() {
|
||||
// Basic usage
|
||||
client := mcp.NewDeepSeekClientWithOptions(
|
||||
client := provider.NewDeepSeekClientWithOptions(
|
||||
mcp.WithAPIKey("sk-xxx"),
|
||||
)
|
||||
|
||||
// Advanced usage
|
||||
client = mcp.NewDeepSeekClientWithOptions(
|
||||
client = provider.NewDeepSeekClientWithOptions(
|
||||
mcp.WithAPIKey("sk-xxx"),
|
||||
mcp.WithLogger(&CustomLogger{}),
|
||||
mcp.WithTimeout(90*time.Second),
|
||||
@@ -163,12 +164,12 @@ func Example_deepseek_new_api() {
|
||||
|
||||
func Example_qwen_new_api() {
|
||||
// Basic usage
|
||||
client := mcp.NewQwenClientWithOptions(
|
||||
client := provider.NewQwenClientWithOptions(
|
||||
mcp.WithAPIKey("sk-xxx"),
|
||||
)
|
||||
|
||||
// Advanced usage
|
||||
client = mcp.NewQwenClientWithOptions(
|
||||
client = provider.NewQwenClientWithOptions(
|
||||
mcp.WithAPIKey("sk-xxx"),
|
||||
mcp.WithLogger(&CustomLogger{}),
|
||||
mcp.WithTimeout(90*time.Second),
|
||||
@@ -185,7 +186,7 @@ func Example_qwen_new_api() {
|
||||
func Example_trader_migration() {
|
||||
// Old code (continues to work)
|
||||
oldStyleClient := func(apiKey, customURL, customModel string) mcp.AIClient {
|
||||
client := mcp.NewDeepSeekClient()
|
||||
client := provider.NewDeepSeekClient()
|
||||
client.SetAPIKey(apiKey, customURL, customModel)
|
||||
return client
|
||||
}
|
||||
@@ -204,7 +205,7 @@ func Example_trader_migration() {
|
||||
opts = append(opts, mcp.WithModel(customModel))
|
||||
}
|
||||
|
||||
return mcp.NewDeepSeekClientWithOptions(opts...)
|
||||
return provider.NewDeepSeekClientWithOptions(opts...)
|
||||
}
|
||||
|
||||
// Both approaches work
|
||||
@@ -230,13 +231,7 @@ func (m *MockHTTPClient) Do(req *http.Request) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func Example_testing_with_mock() {
|
||||
// Use Mock during testing
|
||||
// mockHTTP := &MockHTTPClient{
|
||||
// Response: `{"choices":[{"message":{"content":"test response"}}]}`,
|
||||
// }
|
||||
|
||||
client := mcp.NewClient(
|
||||
// mcp.WithHTTPClient(mockHTTP), // Use mockHTTP in actual tests
|
||||
mcp.WithLogger(mcp.NewNoopLogger()), // Disable logging
|
||||
)
|
||||
|
||||
@@ -258,7 +253,6 @@ func Example_environment_specific() {
|
||||
// Production environment: structured logging + timeout protection
|
||||
prodClient := mcp.NewClient(
|
||||
mcp.WithDeepSeekConfig("sk-xxx"),
|
||||
// mcp.WithLogger(&ZapLogger{}), // Production-grade logging
|
||||
mcp.WithTimeout(30*time.Second),
|
||||
mcp.WithMaxRetries(3),
|
||||
)
|
||||
@@ -273,7 +267,7 @@ func Example_environment_specific() {
|
||||
|
||||
func Example_real_world_usage() {
|
||||
// Create client with complete configuration
|
||||
client := mcp.NewDeepSeekClientWithOptions(
|
||||
client := provider.NewDeepSeekClientWithOptions(
|
||||
mcp.WithAPIKey("sk-xxxxxxxxxx"),
|
||||
mcp.WithTimeout(60*time.Second),
|
||||
mcp.WithMaxRetries(5),
|
||||
|
||||
Reference in New Issue
Block a user