3. 第三放平台部署deepseek

news2025/4/1 16:58:34

有时候我们会发现使用deepseek服务器,异常卡顿,这是由于多方面原因造成的,比如说访问人数过多等。想要解决这个问题,我们可以选择第三方平台进行部署

第三方平台

我们可以选择的第三方平台很多,比如硅基流动、秘塔搜索、百度千帆等,常见平台官网如下

  • 阿里云:https://pai.console.aliyun.com/#/quick-start/models.
  • 腾讯云:https://console.cloud.tencent.com/tione/v2/aimarket/detail/deepseek series?regionld=1&detailTab=introducee
  • cursor:https://cursor.com 需要cursor会员
  • grok:https://groq.com/蒸馏版llama 70b,中文能力不足
  • 国家超算中心:https://www.scnet.cn/ui/mall/
  • 硅基流动:https://siliconflow.cn/zh-cn/models

我们以硅基流动为例来介绍第三方平台部署

部署

  1. 打卡硅基流动官网,我们可以看到他可以使用的模型在这里插入图片描述

  2. 我们以V3模型为例来进行部署,点击第一行第二个模型,他会出现模型的详情信息在这里插入图片描述

  3. 我们可以在线体检,也可以看api文档进行部署,我们打开API文档,在左侧我们可以看到它支持的接口在这里插入图片描述,右侧就是相关的例子了

  4. 我们以创建文本对话为例来进行部署,以官网为例写下如下代码

import requests

url = "https://api.siliconflow.cn/v1/chat/completions"

payload = {
    "model": "Qwen/QwQ-32B",
    "messages": [
        {
            "role": "user",
            "content": "What opportunities and challenges will the Chinese large model industry face in 2025?"
        }
    ],
    "stream": False,
    "max_tokens": 512,
    "stop": None,
    "temperature": 0.7,
    "top_p": 0.7,
    "top_k": 50,
    "frequency_penalty": 0.5,
    "n": 1,
    "response_format": {"type": "text"},
    "tools": [
        {
            "type": "function",
            "function": {
                "description": "<string>",
                "name": "<string>",
                "parameters": {},
                "strict": False
            }
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

对于代码解释

这段代码是使用 Python 的 requests 库向 SiliconFlow API 发送一个 POST 请求,调用 Qwen/QwQ-32B 大语言模型,并获取其对 “2025年中国大模型产业面临的机遇与挑战” 这个问题的回答。

1. 请求目标(API 端点)
url = "https://api.siliconflow.cn/v1/chat/completions"

• 这是 SiliconFlow 提供的 Chat Completions API,用于与大模型对话。

2. 请求数据(Payload)
payload = {
    "model": "Qwen/QwQ-32B",  # 指定调用的模型
    "messages": [
        {
            "role": "user",  # 用户角色
            "content": "What opportunities and challenges will the Chinese large model industry face in 2025?"  # 用户提问
        }
    ],
    "stream": False,  # 是否流式返回(False 表示一次性返回完整回答)
    "max_tokens": 512,  # 限制返回的最大 token 数量(防止回答过长)
    "temperature": 0.7,  # 控制回答的随机性(0-1,越高越有创意)
    "top_p": 0.7,  # 控制生成多样性(类似 temperature)
    "top_k": 50,  # 限制采样范围(仅从 top_k 个最可能的 token 中选择)
    "frequency_penalty": 0.5,  # 降低重复内容的概率
    "n": 1,  # 只生成 1 个回答
    "response_format": {"type": "text"},  # 返回纯文本格式
    "tools": [...]  # (可选)用于函数调用,但这里未实际使用
}

model: 指定调用的模型(这里是 Qwen/QwQ-32B)。
messages: 对话历史,这里只有用户的一条提问。
stream: 是否流式返回(False 表示一次性返回完整回答)。
max_tokens: 限制回答长度(防止过长)。
temperaturetop_ptop_k: 控制回答的随机性和多样性。
frequency_penalty: 减少重复内容。
tools: 可用于 函数调用(Function Calling)

3. 请求头(Headers)
headers = {
    "Authorization": "Bearer <token>",  # 替换为你的 API Key
    "Content-Type": "application/json"  # 告诉服务器发送的是 JSON 数据
}

Authorization: 需要替换 <token> 为你的 SiliconFlow API Key(否则会返回 401 未授权错误)。
Content-Type: 指定数据格式为 application/json

4. 发送请求
response = requests.request("POST", url, json=payload, headers=headers)

• 使用 requests.post() 发送 POST 请求,传递 payload(JSON 格式)和 headers(包含认证信息)。

5. 打印响应
print(response.text)

• 打印 API 返回的 JSON 格式 的完整响应。

对于各个参数的取值,官网会有更详细的说明,点击

申请API KEY

在代码中,我们需要替换<token>,也就是API KEY来进行正确的调用,所以我们应该先进行申请 API KEY

  1. 进入申请API KEY 的页面,并登录

  2. 点击新建API KEY 在这里插入图片描述

  3. 点击余额充值,我们可以看到剩余的金额在这里插入图片描述

  4. 新建好后,我们将API KEY替换,运行上面代码,得到如下回答

{
	"id": "0195e27f092c94bd150980adec837ef5",
	"object": "chat.completion",
	"created": 1743261731,
	"model": "Qwen/QwQ-32B",
	"choices": [{
		"index": 0,
		"message": {
			"role": "assistant",
			"content": "",
			"reasoning_content": "Okay, the user is asking about the opportunities and challenges the Chinese large model industry will face in 2025. Hmm, I need to break this down. First, I should consider what tools are available. The provided functions might include something like a market analysis tool 
			or a future prediction model.\n\ nLooking at the tools given,
			there 's a function called \"analyze_market_trends\" which takes parameters like region, industry, and year. That seems relevant here. The user is focusing on China'
			s large model industry,
			so region would be\ "China\", industry \"AI/ML\" or \"Large Language Models\", and year 2025.\n\nWait, the parameters for analyze_market_trends include region (string), industry (string), year (integer), and maybe others like specific_subsector. Since the question is about large models specifically, maybe adding \"large language models\" as the specific_subsector would help narrow it down.\n\nI should also check if there's another function called \"predict_future_impact\" which takes technology (string), region (string), timeframe (string like \"2025\"), and factors like economic, regulatory. That could cover both opportunities and challenges by considering different factors.\n\nSo combining both functions might give a comprehensive answer. First use analyze_market_trends to get market trends in China's AI/ML sector focusing on large models by 2025. Then use predict_future_impact to look at technological, economic, regulatory factors affecting them.\n\nWait but the user's question is about opportunities and challenges specifically. The functions might already capture that in their outputs. Let me make sure each function's parameters are correctly filled. For analyze_market_trends: region China, industry \"AI/ML\", year 2025, specific_subsector \"large language models\". For predict_future_impact: technology \"large language models\", region China, timeframe \"2025\", factors including economic, regulatory, technological.\n\nI need to structure the tool calls correctly in XML tags as specified. Each tool_call should be separate. Let me format that properly.\n",
			"tool_calls": [{
				"id": "0195e27f26b353d40e8c41265d8faa9f",
				"type": "function",
				"function": {
					"name": "analyze_market_trends",
					"arguments": "{\"region\": \"China\", \"industry\": \"AI/ML\", \"year\": 2025, \"specific_subsector\": \"large language models\"}"
				}
			}]
		},
		"finish_reason": "tool_calls"
	}],
	"usage": {
		"prompt_tokens": 140,
		"completion_tokens": 512,
		"total_tokens": 652
	},
	"system_fingerprint": ""
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2324658.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【C++指针】搭建起程序与内存深度交互的桥梁(下)

&#x1f525;&#x1f525; 个人主页 点击&#x1f525;&#x1f525; 每文一诗 &#x1f4aa;&#x1f3fc; 往者不可谏&#xff0c;来者犹可追——《论语微子篇》 译文&#xff1a;过去的事情已经无法挽回&#xff0c;未来的岁月还可以迎头赶上。 目录 C内存模型 new与…

IEEE PDF Xpress校验出现 :字体无法嵌入问题以及pdf版本问题

文章目录 问题描述一、字体嵌入问题首先查看一下&#xff0c;哪些字体没有被嵌入查看window的font文件夹里的字体下载字体的网站修复字体嵌入问题 二、pdf版本不对 问题描述 在处理IEEE的camera ready的时候&#xff0c;提交到IEEE express的文件没有办法通过validate&#xf…

cookie详解

一、cookie出现原因 http是无状态的&#xff0c;浏览器无法记录当前是哪个人浏览的&#xff0c;所以出现了cookie 作用&#xff1a;会话状态管理&#xff08;用户登录状态、购物车、游戏分数&#xff09;、个性化设置&#xff08;主题、自定义设置&#xff09;、浏览器行为跟…

Mayo Clinic Platform在人工智能医疗领域的现状及启示意义研究

一、引言 1.1 研究背景与意义 在科技飞速发展的当下,人工智能(AI)已逐渐渗透至各个行业,医疗领域作为关乎人类生命健康的重要领域,也迎来了人工智能技术带来的深刻变革。人工智能医疗,作为人工智能与医疗行业深度融合的产物,正重塑着全球医疗的格局。 从全球范围来看,…

如何将 Java 应用做成 EXE 的可执行软件

目录 前言一、情景介绍二、实现步骤1. 打 Jar 包2. 编写 bat 批处理文件3. bat 转 exe 前言 最近使用 GUI 帮朋友写了一个软件&#xff0c;为了方便他处理工作上的重复性且很麻烦的事情&#xff0c;程序是使用 Java 写的&#xff0c;就不得不面对一个问题&#xff1a;我必须将…

第一篇:系统分析师首篇

目录 一、目标二、计划三、完成情况1.宏观思维导图2.过程中的团队管理和其它方面的思考 四、意外之喜(最少2点)1.计划内的明确认知和思想的提升标志2.计划外的具体事情提升内容和标志 一、目标 通过参加考试&#xff0c;训练学习能力&#xff0c;而非单纯以拿证为目的。 1.在复…

自动关机监控器软件 - 您的电脑节能助手

## 自动关机监控器 - 您的电脑节能助手 自动关机监控器是一款基于Python开发的实用工具&#xff0c;旨在帮助用户节省电力资源并延长电脑使用寿命。该程序通过监控用户的鼠标和键盘活动&#xff0c;在设定的无活动时间后自动关闭计算机&#xff0c;特别适合需要长时间离开电脑但…

线程概念与控制(中)

线程概念与控制&#xff08;上&#xff09;https://blog.csdn.net/Small_entreprene/article/details/146464905?sharetypeblogdetail&sharerId146464905&sharereferPC&sharesourceSmall_entreprene&sharefrommp_from_link我们经过上一篇的学习&#xff0c;接…

[GXYCTF2019]禁止套娃1 [GitHack] [无参数RCE]

Git基础 Git信息泄露原理解析及利用总结 - FreeBuf网络安全行业门户 CTF中的GIT泄露_ctf git泄露-CSDN博客 Git结构 dirsearch扫出来一大堆东西&#xff08;然而这些并没有什么屁用&#xff09; 但也算起码了解了git结构了吧 /.git/HEAD&#xff1a;表示当前HEAD指针的指…

从ChatGPT到AutoGPT——AI Agent的范式迁移

一、AI Agent的范式迁移 1. ChatGPT的局限性与Agent化需求 单轮对话的“工具属性” vs. 多轮复杂任务的“自主性” ChatGPT 作为强大的生成式AI,虽然能够进行连贯对话,但本质上仍然是“工具型”AI,依赖用户提供明确的指令,而无法自主规划和执行任务。 人类介入成本过高:提…

stock-pandas,一个易用的talib的替代开源库。

原创内容第841篇&#xff0c;专注智能量化投资、个人成长与财富自由。 介绍一个ta-lib的平替——我们来实现一下&#xff0c;最高价突破布林带上轨&#xff0c;和最低价突破布林带下轨的可视化效果&#xff1a; cross_up_upper stock[high].copy()# cross_up_upper 最高价突破…

Spring Cloud Gateway详细介绍简单案例

文章目录 1、Spring Cloud Gateway 详细介绍1.1. 统一入口&#xff08;Single Entry Point&#xff09;1.2. 请求路由&#xff08;Request Routing&#xff09;1.3. 负载均衡&#xff08;Load Balancing&#xff09;1.4. 流量控制&#xff08;Rate Limiting&#xff09;1.5. 身…

鸿蒙原生开发之状态管理V2

一、ArkTS状态变量的定义&#xff1a; State&#xff1a;状态&#xff0c;指驱动UI更新的数据。用户通过触发组件的事件方法&#xff0c;改变状态数据。状态数据的改变&#xff0c;引起UI的重新渲染。 在鸿蒙原生开发中&#xff0c;使用ArkTS开发UI的时候&#xff0c;我们可以…

矩阵中对角线的遍历问题【C++】

1&#xff0c;按对角线进行矩阵排序 题目链接&#xff1a;3446. 按对角线进行矩阵排序 - 力扣&#xff08;LeetCode&#xff09; 【题目描述】 对于一个m*n的矩阵grid&#xff0c;要求对该矩阵进行 变换&#xff0c;使得变换后的矩阵满足&#xff1a; 主对角线右上的所有对角…

[Lc4_dfs] 解数独 | 单词搜索

目录 1.解数独 题解 2.单词搜索 题解 1.解数独 链接&#xff1a;37. 解数独 编写一个程序&#xff0c;通过填充空格来解决数独问题。 数独的解法需 遵循如下规则&#xff1a; 数字 1-9 在每一行只能出现一次。数字 1-9 在每一列只能出现一次。数字 1-9 在每一个以粗实线…

day17 学习笔记

文章目录 前言一、数组的增删改查1.resize函数2.append函数3.insert函数4.delete函数5.argwhere函数6.unique函数 二、统计函数1.amax&#xff0c;amin函数2.ptp函数3.median函数4.mean函数5.average函数6.var&#xff0c;std函数 前言 通过今天的学习&#xff0c;我掌握了num…

自动语音识别(ASR)技术详解

语音识别&#xff08;Automatic Speech Recognition, ASR&#xff09;是人工智能和自然语言处理领域的重要技术&#xff0c;旨在将人类的语音信号转换为对应的文本。近年来&#xff0c;深度学习的突破推动语音识别系统从实验室走入日常生活&#xff0c;为智能助手、实时翻译、医…

git | 版本切换的相关指令

常见指令 git log --oneline #查看历史提交 git tag latest-backup # 对当前的提交进行标记&#xff0c;标记名为latest-backup git checkout -b old-version 55b16aa # 切换到[55b16aa]的提交中&#xff0c;并标记为[old-version]的分支 git checkout master …

19.OpenCV图像二值化

OpenCV图像二值化 图像二值化&#xff08;Binarization&#xff09;是图像预处理中的一种常用技术&#xff0c;其目的是将图像中的像素值分为两个类别——通常是“前景”和“背景”或者说0和255。二值化能够简化图像信息&#xff0c;为后续的形态学处理、边缘检测、目标识别等…

通过Appium理解MCP架构

MCP即Model Context Protocol&#xff08;模型上下文协议&#xff09;&#xff0c;是由Anthropic公司于2024年11月26日推出的开放标准框架&#xff0c;旨在为大型语言模型与外部数据源、工具及系统建立标准化交互协议&#xff0c;以打破AI与数据之间的连接壁垒。 MCP架构与Appi…