利用C#的BotSharp本地部署第一个大模型AI Agent示例(1)

测试环境:

window 11

visual studio 2022

.net 8

步骤如下:

1 使用git拉取BotSharp源码,仓库地址:https://github.com/SciSharp/BotSharp

复制代码
git clone https://github.com/dotnetcore/BotSharp

2 下载到源码后,用visual studio打开BotSharp.sln项目,等待一段时间,让visual studio自动下载nuget包

然后生成解决方案,然后进行调试运行,默认是运行BotSharp.AppHost

启动后,会自动打开网页,如下图:

3 为了方便操作,拉取前端BotSharp-UI源码,github地址:https://github.com/SciSharp/BotSharp-UI

拉取到本地后,使用命令

复制代码
npm install安装前端依赖包

修改.env文件的地址为C#后端的地址,如下图:

再使用命令运行

npm run dev,会自动打开网页,如下图:

刚开始是空白,要等一会

再点击get start按钮,进入登录界面,默认账号和密码,进入主界面,如下图:

4 下载模型文件,https://ai.gitcode.com/hf_mirrors/TheBloke/Llama-2-7B-Chat-GGUF/blob/main/llama-2-7b-chat.Q8_0.gguf

然后把下载的模型文件llama-2-7b-chat.Q8_0.gguf拷到D:/zxy/AIModel目录下(没有自己新建)

5 然后回到C#项目的WebStarter项目,打开对应的配置文件appsettings.json并配置如下:

配置的地方有两个,第一个如下,配置模型的路径及模型的名称

第二个如下:

完整的配置文件如下:

cs 复制代码
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "AllowedOrigins": [
    "http://localhost:5015",
    "http://0.0.0.0:5015",
    "https://botsharp.scisharpstack.org",
    "https://chat.scisharpstack.org"
  ],

  "Jwt": {
    "Issuer": "botsharp",
    "Audience": "botsharp",
    "Key": "31ba6052aa6f4569901facc3a41fcb4adfd9b46dd00c40af8a753fbdc2b89869"
  },

  "OAuth": {
    "GitHub": {
      "ClientId": "",
      "ClientSecret": ""
    },
    "Google": {
      "ClientId": "",
      "ClientSecret": ""
    },
    "Keycloak": {
      "BaseAddress": "",
      "Realm": "",
      "ClientId": "",
      "ClientSecret": "",
      "Version": 22
    },
    "Weixin": {
      "AppId": "",
      "AppSecret": ""
    }
  },

  "LlmProviders": [
    {
      "Provider": "azure-openai",
      "Models": [
        {
          "Id": "gpt-3.5-turbo",
          "Name": "gpt-35-turbo",
          "Version": "1106",
          "ApiKey": "",
          "Endpoint": "https://gpt-35-turbo-instruct.openai.azure.com/",
          "Type": "chat",
          "Capabilities": [
            "Chat"
          ]
        },
        {
          "Name": "gpt-35-turbo-instruct",
          "Version": "0914",
          "ApiKey": "",
          "Endpoint": "https://gpt-35-turbo-instruct.openai.azure.com/",
          "Type": "text",
          "Capabilities": [
            "Text"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        }
      ]
    },
    {
      "Provider": "llama-sharp",
      "Models": [
        {
          "Name": "llama-2-7b-chat.Q8_0.gguf",
          "Type": "chat",
          "Capabilities": [
            "Chat"
          ]
        }
      ]
    },
    {
      "Provider": "huggingface",
      "Models": [
        {
          "Name": "mistralai/Mistral-7B-v0.1",
          "Type": "text",
          "Capabilities": [
            "Text"
          ]
        },
        {
          "Name": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
          "Type": "text",
          "Capabilities": [
            "Text"
          ]
        }
      ]
    },
    {
      "Provider": "sparkdesk",
      "Models": [
        {
          "Name": "gpt-35-turbo",
          "Type": "chat",
          "Capabilities": [
            "Chat"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        }
      ]
    },
    {
      "Provider": "metaglm",
      "Models": [
        {
          "Name": "chatglm3_6b",
          "Type": "chat",
          "Capabilities": [
            "Chat"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        }
      ]
    },
    {
      "Provider": "openai",
      "Models": [
        {
          "Id": "gpt-4",
          "Name": "gpt-4o-mini",
          "Version": "2024-07-18",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Cost": {
            "TextInputCost": 0.00015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.0006,
            "AudioOutputCost": 0
          }
        },
        {
          "Id": "gpt-4",
          "Name": "gpt-4o-2024-11-20",
          "Version": "2024-11-20",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Cost": {
            "TextInputCost": 0.0025,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.01,
            "AudioOutputCost": 0
          }
        },
        {
          "Id": "gpt-4",
          "Name": "gpt-4o-mini-realtime-preview-2024-12-17",
          "Version": "2024-12-17",
          "ApiKey": "",
          "Type": "realtime",
          "MultiModal": true,
          "Capabilities": [
            "Realtime"
          ],
          "Cost": {
            "TextInputCost": 0.0025,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.01,
            "AudioOutputCost": 0
          }
        },
        {
          "Id": "text-embedding-3",
          "Name": "text-embedding-3-small",
          "Version": "3-small",
          "ApiKey": "",
          "Type": "embedding",
          "Capabilities": [
            "Embedding"
          ],
          "Embedding": {
            "Dimension": 1536
          }
        },
        {
          "Id": "dall-e",
          "Name": "dall-e-2",
          "Version": "dall-e-2",
          "ApiKey": "",
          "Endpoint": "",
          "Type": "image",
          "Capabilities": [
            "ImageGeneration",
            "ImageEdit",
            "ImageVariation"
          ],
          "Image": {
            "Generation": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "256x256", "512x512", "1024x1024" ]
                },
                "Quality": {
                  "Default": "standard",
                  "Options": [ "standard" ]
                },
                "ResponseFormat": {
                  "Default": "bytes",
                  "Options": [ "url", "bytes" ]
                }
              }
            },
            "Edit": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "256x256", "512x512", "1024x1024" ]
                },
                "ResponseFormat": {
                  "Default": "bytes",
                  "Options": [ "url", "bytes" ]
                }
              }
            },
            "Variation": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "256x256", "512x512", "1024x1024" ]
                },
                "ResponseFormat": {
                  "Default": "bytes",
                  "Options": [ "url", "bytes" ]
                }
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.01,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.03,
            "AudioOutputCost": 0
          }
        },
        {
          "Id": "dall-e",
          "Name": "dall-e-3",
          "Version": "dall-e-3",
          "ApiKey": "",
          "Type": "image",
          "Capabilities": [
            "ImageGeneration"
          ],
          "Image": {
            "Generation": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "1024x1024", "1792x1024", "1024x1792" ]
                },
                "Quality": {
                  "Default": "standard",
                  "Options": [ "standard", "hd", "auto" ]
                },
                "Style": {
                  "Default": "natural",
                  "Options": [ "natural", "vivid" ]
                },
                "ResponseFormat": {
                  "Default": "bytes",
                  "Options": [ "url", "bytes" ]
                }
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.01,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.03,
            "AudioOutputCost": 0
          }
        },
        {
          "Id": "gpt-image",
          "Name": "gpt-image-1",
          "Version": "gpt-image-1",
          "ApiKey": "",
          "Type": "image",
          "Capabilities": [
            "ImageComposition"
          ],
          "Image": {
            "Edit": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "1024x1024", "1536x1024", "1024x1536", "auto" ]
                },
                "Quality": {
                  "Default": "medium",
                  "Options": [ "low", "medium", "high", "auto" ]
                },
                "Background": {
                  "Default": "auto",
                  "Options": [ "auto", "transparent", "opaque" ]
                }
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.01,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.03,
            "AudioOutputCost": 0,
            "ImageInputCost": 0.01,
            "CachedImageInputCost": 0.0025,
            "ImageOutputCost": 0.04,
            "ImageCosts": [
              {
                "Attributes": {
                  "Quality": "medium",
                  "Size": "1024x1024"
                },
                "Cost": 0.042
              },
              {
                "Attributes": {
                  "Quality": "high",
                  "Size": "1024x1024"
                },
                "Cost": 0.167
              }
            ]
          }
        },
        {
          "Id": "gpt-image",
          "Name": "gpt-image-1-mini",
          "Version": "gpt-image-1-mini",
          "ApiKey": "",
          "Type": "image",
          "Capabilities": [
            "ImageComposition"
          ],
          "Image": {
            "Edit": {
              "Parameters": {
                "Size": {
                  "Default": "1024x1024",
                  "Options": [ "1024x1024", "1536x1024", "1024x1536", "auto" ]
                },
                "Quality": {
                  "Default": "medium",
                  "Options": [ "low", "medium", "high", "auto" ]
                },
                "Background": {
                  "Default": "auto",
                  "Options": [ "auto", "transparent", "opaque" ]
                }
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.01,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.03,
            "AudioOutputCost": 0,
            "ImageInputCost": 0.0025,
            "CachedImageInputCost": 0.00025,
            "ImageOutputCost": 0.008,
            "ImageCosts": [
              {
                "Attributes": {
                  "Quality": "medium",
                  "Size": "1024x1024"
                },
                "Cost": 0.011
              },
              {
                "Attributes": {
                  "Quality": "high",
                  "Size": "1024x1024"
                },
                "Cost": 0.036
              }
            ]
          }
        },
        {
          "Id": "gpt-4o-web",
          "Name": "gpt-4o-search-preview",
          "Version": "gpt-4o-search-preview",
          "ApiKey": "",
          "Type": "chat",
          "Capabilities": [
            "WebSearch"
          ],
          "WebSearch": {
            "SearchContextSize": "low"
          },
          "Cost": {
            "TextInputCost": 0.005,
            "CachedTextInputCost": 0.0025,
            "AudioInputCost": 0.04,
            "CachedAudioInputCost": 0.0025,
            "TextOutputCost": 0.02,
            "AudioOutputCost": 0.08
          }
        },
        {
          "Id": "gpt-4o-web",
          "Name": "gpt-4o-mini-search-preview",
          "Version": "gpt-4o-mini-search-preview",
          "ApiKey": "",
          "Type": "chat",
          "Capabilities": [
            "WebSearch"
          ],
          "WebSearch": {
            "IsDefault": true,
            "SearchContextSize": "low"
          },
          "Cost": {
            "TextInputCost": 0.005,
            "CachedTextInputCost": 0.0025,
            "AudioInputCost": 0.04,
            "CachedAudioInputCost": 0.0025,
            "TextOutputCost": 0.02,
            "AudioOutputCost": 0.08
          }
        },
        {
          "Id": "gpt-5",
          "Name": "gpt-5",
          "Version": "gpt-5",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Reasoning": {
            "Temperature": 1.0,
            "Parameters": {
              "EffortLevel": {
                "Default": "minimal",
                "Options": [ "minimal", "low", "medium", "high" ]
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.005,
            "CachedTextInputCost": 0.0025,
            "AudioInputCost": 0.04,
            "CachedAudioInputCost": 0.0025,
            "TextOutputCost": 0.02,
            "AudioOutputCost": 0.08
          }
        },
        {
          "Id": "gpt-5",
          "Name": "gpt-5.1",
          "Version": "gpt-5.1",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Reasoning": {
            "Temperature": 1.0,
            "Parameters": {
              "EffortLevel": {
                "Default": "low",
                "Options": [ "none", "low", "medium", "high" ]
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.005,
            "CachedTextInputCost": 0.0025,
            "AudioInputCost": 0.04,
            "CachedAudioInputCost": 0.0025,
            "TextOutputCost": 0.02,
            "AudioOutputCost": 0.08
          }
        },
        {
          "Id": "gpt-5",
          "Name": "gpt-5.2",
          "Version": "gpt-5.2",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Reasoning": {
            "Temperature": 1,
            "Parameters": {
              "EffortLevel": {
                "Default": "low",
                "Options": [ "none", "low", "medium", "high", "xhigh" ]
              }
            }
          },
          "Cost": {
            "TextInputCost": 0.005,
            "CachedTextInputCost": 0.0025,
            "AudioInputCost": 0.04,
            "CachedAudioInputCost": 0.0025,
            "TextOutputCost": 0.02,
            "AudioOutputCost": 0.08
          }
        }
      ]
    },
    {
      "Provider": "deepseek-ai",
      "Models": [
        {
          "Name": "deepseek-chat",
          "ApiKey": "",
          "Endpoint": "https://api.deepseek.com/v1/",
          "Type": "chat",
          "Capabilities": [
            "Chat",
            "ImageReading"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        }
      ]
    },
    {
      "Provider": "google-ai",
      "Models": [
        {
          "Name": "gemini-2.0-flash",
          "ApiKey": "",
          "Type": "chat",
          "MultiModal": true,
          "Capabilities": [
            "Chat",
            "ImageReading",
            "PdfReading"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        },
        {
          "Name": "gemini-2.0-flash-exp",
          "ApiKey": "",
          "Type": "realtime",
          "MultiModal": true,
          "Capabilities": [
            "Realtime"
          ],
          "Cost": {
            "TextInputCost": 0.0015,
            "CachedTextInputCost": 0,
            "AudioInputCost": 0,
            "CachedAudioInputCost": 0,
            "TextOutputCost": 0.002,
            "AudioOutputCost": 0
          }
        }
      ]
    }
  ],

  "Router": {
  },

  "Evaluator": {
    "AgentId": "dfd9b46d-d00c-40af-8a75-3fbdc2b89869"
  },

  "Agent": {
    "DataDir": "agents",
    "TemplateFormat": "liquid",
    "HostAgentId": "01e2fc5c-2c89-4ec7-8470-7688608b496c",
    "EnableTranslator": false,
    "LlmConfig": {
      "Provider": "openai",
      "Model": "gpt-4.1-nano"
    }
  },

  "Coding": {
    "CodeGeneration": {
      "Provider": "openai",
      "Model": "gpt-5-mini",
      "MaxOutputTokens": 8192,
      "ReasoningEffortLevel": "minimal",
      "Processor": null,
      "MessageLimit": 50
    },
    "CodeExecution": {
      "Processor": null,
      "UseLock": false,
      "UseProcess": false,
      "TimeoutSeconds": 3
    }
  },

  "MCP": {
    "Enabled": false,
    "McpClientOptions": {
      "ClientInfo": {
        "Name": "SimpleToolsBotsharp",
        "Version": "1.0.0"
      }
    },
    "McpServerConfigs": [
      //{
      //  "Id": "PizzaServer",
      //  "Name": "PizzaServer",
      //  "SseConfig": {
      //    "Endpoint": "http://localhost:58905/sse"
      //  }
      //}
    ]
  },

  "Conversation": {
    "DataDir": "conversations",
    "ShowVerboseLog": false,
    "EnableLlmCompletionLog": false,
    "EnableExecutionLog": true,
    "EnableContentLog": true,
    "EnableStateLog": true,
    "EnableTranslationMemory": false,
    "CleanSetting": {
      "Enable": true,
      "BatchSize": 50,
      "MessageLimit": 2,
      "BufferHours": 12,
      "ExcludeAgentIds": []
    },
    "RateLimit": {
      "MaxConversationPerDay": 100,
      "MaxInputLengthPerRequest": 256,
      "MinTimeSecondsBetweenMessages": 2
    },
    "FileSelect": {
      "Provider": "openai",
      "Model": "gpt-5-mini",
      "MaxOutputTokens": 8192,
      "ReasoningEffortLevel": "low",
      "MessageLimit": 50
    }
  },

  "SideCar": {
    "Conversation": {
      "Provider": "botsharp"
    }
  },

  "WebBrowsing": {
    "Driver": "Playwright"
  },

  "SqlDriver": {
    "MySqlConnectionString": "",
    "SqlServerConnectionString": "",
    "SqlLiteConnectionString": ""
  },

  "Statistics": {
    "Enabled": false
  },

  "Crontab": {
    "Watcher": {
      "Enabled": false
    },
    "EventSubscriber": {
      "Enabled": false
    }
  },

  "Instruction": {
    "Logging": {
      "Enabled": true,
      "ExcludedAgentIds": []
    }
  },

  "ChatHub": {
    "EventDispatchBy": "group"
  },

  "SharpCache": {
    "Enabled": true,
    "CacheType": 1,
    "Prefix": "botsharp"
  },

  "LlamaSharp": {
    "Interactive": true,
    "ModelDir": "D:/zxy/AIModel",
    "DefaultModel": "llama-2-7b-chat.Q8_0.gguf",
    "MaxContextLength": 1024,
    "NumberOfGpuLayer": 20
  },

  "AzureOpenAi": {
  },

  "AnthropicAi": {
    "Claude": {

    }
  },

  "GoogleAi": {
    "PaLM": {
      "Endpoint": "https://generativelanguage.googleapis.com",
      "ApiKey": ""
    },
    "Gemini": {
      "ApiKey": "",
      "UseGoogleSearch": false,
      "UseGrounding": false
    }
  },

  "HuggingFace": {
    "Endpoint": "https://api-inference.huggingface.co",
    "Model": "tiiuae/falcon-180B-chat",
    "Token": ""
  },

  "MetaAi": {
    "fastText": {
      "ModelPath": "dbpedia.ftz"
    }
  },

  "RoutingSpeeder": {
  },

  "MetaMessenger": {
    "Endpoint": "https://graph.facebook.com",
    "ApiVersion": "v17.0",
    "PageId": "",
    "PageAccessToken": ""
  },

  "Twilio": {
    "PhoneNumber": "+1",
    "AccountSID": "",
    "AuthToken": "",
    "CallbackHost": "https://",
    "AgentId": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a"
  },

  "Database": {
    "Default": "FileRepository",
    "TablePrefix": "BotSharp",
    "BotSharpMongoDb": "",
    "Redis": "botsharp.redis.cache.windows.net:6380,password=,ssl=True,abortConnect=False",
    "FileRepository": "data",
    "Assemblies": [ "BotSharp.Core" ]
  },

  "FileCore": {
    "Storage": "LocalFileStorage",
    "ImageConverter": {
      "Provider": ""
    }
  },

  "FileHandler": {
    "Pdf": {
      "Reading": {
        "Provider": "google-ai",
        "Model": "gemini-2.0-flash",
        "ConvertToImage": false,
        "ImageDetailLevel": "auto",
        "ImageConverter": {
          "Provider": null
        }
      }
    }
  },

  "ImageHandler": {
    "Reading": {
      "Provider": "openai",
      "Model": "gpt-5-mini",
      "ImageDetailLevel": "auto"
    },
    "Composition": {
      "Provider": "openai",
      "Model": "gpt-image-1",
      "ImageConverter": {
        "Provider": null
      }
    }
  },

  "AudioHandler": {
    "Audio": {
      "Reading": {
        "Provider": "openai",
        "Model": "gpt-4o-mini-transcribe"
      }
    }
  },

  "ExcelHandler": {
    "Database": {
      "Provider": "mysql",
      "ConnectionString": ""
    }
  },

  "HttpHandler": {
    "BaseAddress": "",
    "Origin": ""
  },

  "ChartHandler": {
    "ChartPlot": {
      "Provider": "openai",
      "Model": "gpt-5",
      "MaxOutputTokens": 8192,
      "ReasoningEffortLevel": "minimal",
      "MessageLimit": 50
    }
  },

  "TencentCos": {
    "AppId": "",
    "SecretId": "",
    "SecretKey": "",
    "BucketName": "",
    "Region": ""
  },

  "Qdrant": {
    "Url": "",
    "ApiKey": ""
  },

  "Graph": {
    "BaseUrl": "",
    "SearchPath": ""
  },

  "Membase": {
    "Host": "",
    "ApiKey": ""
  },

  "WeChat": {
    "AgentId": "437bed34-1169-4833-95ce-c24b8b56154a",
    "Token": "#{Token}#",
    "EncodingAESKey": "#{EncodingAESKey}#",
    "WeixinAppId": "#{WeixinAppId}#",
    "WeixinAppSecret": "#{WeixinAppSecret}#"
  },

  "KnowledgeBase": {
    "VectorDb": {
      "Provider": "Qdrant"
    },
    "GraphDb": {
      "Provider": "Remote"
    },
    "Default": {
      "CollectionName": "BotSharp",
      "TextEmbedding": {
        "Provider": "openai",
        "Model": "text-embedding-3-small",
        "Dimension": 1536
      }
    }
  },

  "SparkDesk": {
    "AppId": "",
    "ApiKey": "",
    "ApiSecret": "",
    "ModelVersion": "V3_5"
  },

  "MetaGLM": {
    "ApiKey": "",
    "BaseAddress": "http://localhost:8100/v1/",
    "ModelId": "chatglm3_6b",
    "Temperature": 0.7,
    "TopP": 0.7
  },

  "GoogleApi": {
    "ApiKey": "",
    "Map": {
      "Endpoint": "https://maps.googleapis.com/maps/api/geocode/json",
      "Components": "country=US|country=CA"
    },
    "Youtube": {
      "Endpoint": "https://www.googleapis.com/youtube/v3/search",
      "RegionCode": "US",
      "Part": "id,snippet",
      "Channels": []
    }
  },

  "PythonInterpreter": {
    "InstallLocation": "C:/Users/xxx/AppData/Local/Programs/Python/Python313/python313.dll",
    "PythonVersion": "3.13.3"
  },

  "FuzzySharp": {
    "Data": {
      "BaseDir": "data/tokens",
      "Vocabulary": {
        "Folder": "vocabulary",
        "FileNames": []
      },
      "Synonym": {
        "Folder": "synonym",
        "FileNames": []
      }
    }
  },

  "RealtimeModel": {
    "Provider": "openai",
    "Model": "gpt-realtime",
    "InputAudioFormat": "pcm16",
    "OutputAudioFormat": "pcm16",
    "InterruptResponse": true,
    "MaxResponseOutputTokens": 4096,
    "InputAudioTranscribe": true,
    "InputAudioTranscription": {
      "Model": "whisper-1",
      "Language": "en"
    }
  },

  "PluginLoader": {
    "Assemblies": [
      "BotSharp.Core",
      "BotSharp.Core.SideCar",
      "BotSharp.Core.Crontab",
      "BotSharp.Core.Realtime",
      "BotSharp.Logger",
      "BotSharp.Plugin.MongoStorage",
      "BotSharp.Plugin.Dashboard",
      "BotSharp.Plugin.OpenAI",
      "BotSharp.Plugin.AzureOpenAI",
      "BotSharp.Plugin.AnthropicAI",
      "BotSharp.Plugin.GoogleAI",
      "BotSharp.Plugin.MetaAI",
      "BotSharp.Plugin.DeepSeekAI",
      "BotSharp.Plugin.MetaMessenger",
      "BotSharp.Plugin.HuggingFace",
      "BotSharp.Plugin.KnowledgeBase",
      "BotSharp.Plugin.Planner",
      "BotSharp.Plugin.Graph",
      "BotSharp.Plugin.Qdrant",
      "BotSharp.Plugin.Membase",
      "BotSharp.Plugin.ChatHub",
      "BotSharp.Plugin.WeChat",
      "BotSharp.Plugin.PizzaBot",
      "BotSharp.Plugin.WebDriver",
      "BotSharp.Plugin.LLamaSharp",
      "BotSharp.Plugin.SparkDesk",
      "BotSharp.Plugin.MetaGLM",
      "BotSharp.Plugin.HttpHandler",
      "BotSharp.Plugin.FileHandler",
      "BotSharp.Plugin.ImageHandler",
      "BotSharp.Plugin.EmailHandler",
      "BotSharp.Plugin.AudioHandler",
      "BotSharp.Plugin.ChartHandler",
      "BotSharp.Plugin.AudioHandler",
      "BotSharp.Plugin.ExcelHandler",
      "BotSharp.Plugin.SqlDriver",
      "BotSharp.Plugin.TencentCos",
      "BotSharp.Plugin.PythonInterpreter",
      "BotSharp.Plugin.FuzzySharp"
    ]
  }
}

6 利用nuget安装LLamaSharp.Backend.Cpu到项目中BotSharp.Plugin.LLamaSharp.csproj,版本选择0.25.0,如下图:

这个地址有介绍:https://botsharp.verdure-hiro.cn/zh/guide/llama-sharp/config-llamasharp

7 启动后端和前端项目,在前端界面找到插件菜单,找到LLamaSharp安装即可,如下图:

然后打开Agent代理的Chatbot,如下图:

然后选择llama-sharp,接着选择我们的模型llama-2-7b-chat.Q8_0.gguf,然后保存,回到Chatbot

然后点击Chatbot的Test按钮,进入对话交互界面,如下图:

输入Hello,要等半分钟后才回复,刚开始有点心急,咋那么久都没反应还以为那里没配对,网上各种找解决方案

好了,本文到此结束,如果本文对你有帮助,资助2毛钱作为鼓励呗,费了好大的心思了的,模型下载都找了好久,穷逼一个,就当筹个网费吧

相关推荐
才不做选择1 天前
基于 YOLOv8 的部落冲突 (Clash of Clans) 目标检测系统
人工智能·python·yolo·目标检测
AI探索先锋1 天前
高效!YOLO+SAM 目标检测与图像分割融合实战
人工智能·计算机视觉·目标跟踪
byzh_rc1 天前
[机器学习-从入门到入土] 基础知识
人工智能·机器学习
无限大.1 天前
为什么游戏需要“加载时间“?——从硬盘读取到内存渲染
网络·人工智能·游戏
vibag1 天前
使用底层API构建图
人工智能·语言模型·langchain·大模型·langgraph
权泽谦1 天前
医疗预测项目:CNN + XGBoost 实战全流程
人工智能·神经网络·cnn
汗流浃背了吧,老弟!1 天前
Transformer-初识
人工智能·深度学习·transformer
刘97531 天前
【第25天】25c#今日小结
java·开发语言·c#
Lkygo1 天前
Embedding 和 Reranker 模型
人工智能·embedding·vllm·sglang