ChatGPT 网页会话过程数据传输分析以及横向对比

2024-06-16 17:12

本文主要是介绍ChatGPT 网页会话过程数据传输分析以及横向对比,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

新建一个会话

https://chatgpt.com/backend-api/conversation POST

请求

{"action": "next","messages": [{"id": "aaa2d6d4-5a8b-473e-bd21-e3bf2ee4f571","author": {"role": "user"},"content": {"content_type": "text","parts": ["为 TikTok 帐户创建一个用于评估房地产楼盘的内容日历。"]},"metadata": {"is_starter_prompt": true}}],"parent_message_id": "aaa10e5b-13c0-4682-8285-23b44800ac47","model": "auto","timezone_offset_min": -480,"suggestions": ["为 TikTok 帐户创建一个用于评估房地产楼盘的内容日历。","让我们通过世界首都小测试来提高我的地理知识水平。你可以先随便问我一个国家的首都,我会尽我最大的努力提供正确答案。","随便告诉我一个关于罗马帝国的趣事","我刚搬到一个新城市,希望结交些朋友。你能推荐一些有趣的活动来帮助我实现这个目标吗?"],"history_and_training_disabled": false,"conversation_mode": {"kind": "primary_assistant"},"force_paragen": false,"force_paragen_model_slug": "","force_nulligen": false,"force_rate_limit": false,"reset_rate_limits": false,"websocket_request_id": "0352852e-f148-4288-ac1f-a0c452913f88","force_use_sse": false
}

响应

{"wss_url": "wss://chatgpt-async-webps-prod-southcentralus-0.chatgpt.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1zb3V0aGNlbnRyYWx1cy0wLndlYnB1YnN1Yi5henVyZS5jb20vY2xpZW50L2h1YnMvY29udmVyc2F0aW9ucyIsImlhdCI6MTcxODUyMTc3OSwiZXhwIjoxNzE4NTI1Mzc5LCJzdWIiOiJ1c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCIsInJvbGUiOlsid2VicHVic3ViLmpvaW5MZWF2ZUdyb3VwLnVzZXItUG1CT1pWRE5kM0FvamxsTHNnRWlJT0QwIl0sIndlYnB1YnN1Yi5ncm91cCI6WyJ1c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCJdfQ.FtFv5GNo_okUpcQa84k8B8TL3GfsUD-M-6CFxP-IQeo","fallback_wss_url": "wss://chatgpt-async-webps-prod-eastus-0.chatgpt.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1lYXN0dXMtMC53ZWJwdWJzdWIuYXp1cmUuY29tL2NsaWVudC9odWJzL2NvbnZlcnNhdGlvbnMiLCJpYXQiOjE3MTg1MjE3NzksImV4cCI6MTcxODUyNTM3OSwic3ViIjoidXNlci1QbUJPWlZETmQzQW9qbGxMc2dFaUlPRDAiLCJyb2xlIjpbIndlYnB1YnN1Yi5qb2luTGVhdmVHcm91cC51c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCJdLCJ3ZWJwdWJzdWIuZ3JvdXAiOlsidXNlci1QbUJPWlZETmQzQW9qbGxMc2dFaUlPRDAiXX0.ViTMpHrXz4XfZN4zH8nDZTSpl2gMZ4w2kKJ9WVhoHA0","expires_at": "2024-06-16T08:09:39.172404+00:00","conversation_id": "4744527e-da3d-4ae8-ba71-c16904fb36fe","response_id": "8948f9bac9347964-NRT","websocket_request_id": "0352852e-f148-4288-ac1f-a0c452913f88"
}

stop conversation?

https://chatgpt.com/backend-api/stop_conversation

请求

{"websocket_request_id":"0352852e-f148-4288-ac1f-a0c452913f88"} // 这个在上面新建一个会话那里出现过

响应

{"status":"ok"}

继续会话

https://chatgpt.com/backend-api/conversation

看起来 ChatGPT 用的是 eventsteam

建立 WebSocket 连接

  • 使用提供的 wss_url 或者 fallback_wss_url 来建立 WebSocket 连接。
  • 确保在建立连接时使用了正确的访问令牌(access_token)。

发送消息请求

  • 在建立连接后,发送你希望模型继续生成的消息请求。你需要将当前的对话 ID (conversation_id) 和父消息 ID (parent_message_id) 包含在请求中。

接收消息响应

  • 监听 WebSocket 连接,接收服务器发送的响应消息。
  • 响应消息中应该包含实际的输出内容。
{"action": "next","messages": [{"id": "aaa2a4fc-dce4-45be-96c0-91e36b9d6288","author": {"role": "user"},"content": {"content_type": "text","parts": ["噢噢好的"]},"metadata": {}}],"conversation_id": "4744527e-da3d-4ae8-ba71-c16904fb36fe",// 父消息id"parent_message_id": "4f2bfcfd-a93b-4b49-bd0a-134883a2a558","model": "auto","timezone_offset_min": -480,"suggestions": [],"history_and_training_disabled": false,"conversation_mode": {"kind": "primary_assistant"},"force_paragen": false,"force_paragen_model_slug": "","force_nulligen": false,"force_rate_limit": false,"reset_rate_limits": false,"websocket_request_id": "8353fe2d-9927-451b-bb93-6ac65f28ab12","force_use_sse": false
}

响应

难道响应用的是 websocket?

{"wss_url": "wss://chatgpt-async-webps-prod-southcentralus-0.chatgpt.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1zb3V0aGNlbnRyYWx1cy0wLndlYnB1YnN1Yi5henVyZS5jb20vY2xpZW50L2h1YnMvY29udmVyc2F0aW9ucyIsImlhdCI6MTcxODUyMjY3MSwiZXhwIjoxNzE4NTI2MjcxLCJzdWIiOiJ1c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCIsInJvbGUiOlsid2VicHVic3ViLmpvaW5MZWF2ZUdyb3VwLnVzZXItUG1CT1pWRE5kM0FvamxsTHNnRWlJT0QwIl0sIndlYnB1YnN1Yi5ncm91cCI6WyJ1c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCJdfQ.QhSJPJ0NSr4wAFgobR5ft8tK5BtMGLHIlX_Vgt6O4mM","fallback_wss_url": "wss://chatgpt-async-webps-prod-eastus-0.chatgpt.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1lYXN0dXMtMC53ZWJwdWJzdWIuYXp1cmUuY29tL2NsaWVudC9odWJzL2NvbnZlcnNhdGlvbnMiLCJpYXQiOjE3MTg1MjI2NzEsImV4cCI6MTcxODUyNjI3MSwic3ViIjoidXNlci1QbUJPWlZETmQzQW9qbGxMc2dFaUlPRDAiLCJyb2xlIjpbIndlYnB1YnN1Yi5qb2luTGVhdmVHcm91cC51c2VyLVBtQk9aVkROZDNBb2psbExzZ0VpSU9EMCJdLCJ3ZWJwdWJzdWIuZ3JvdXAiOlsidXNlci1QbUJPWlZETmQzQW9qbGxMc2dFaUlPRDAiXX0.vd-Gu40JVwJxoMkIFBWUEG9mXtQlM2Se-AUE8N-onww","expires_at": "2024-06-16T08:24:31.588490+00:00","conversation_id": "4744527e-da3d-4ae8-ba71-c16904fb36fe","response_id": "89490f8489ec6876-NRT","websocket_request_id": "8353fe2d-9927-451b-bb93-6ac65f28ab12"
}

看看 qwen

这个是历史对话消息。

{"limit": 20,"has_more": false,"data": [{"id": "f929b595-18a9-4b51-a22b-a7642d189378","conversation_id": "a9de725e-f3c3-4bc6-9803-362ef76d3c49","inputs": {},"query": "111","answer": "","message_files": [],"feedback": null,"retriever_resources": [],"created_at": 1716340511,"agent_thoughts": [],"status": "error","error": "[openai_api_compatible] Server Unavailable Error, HTTPConnectionPool(host='211.71.15.49', port=8000): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4621ecb2e0>: Failed to establish a new connection: [Errno 111] Connection refused'))"},{"id": "8c035b93-1f01-43f8-b845-8acde26a05bd","conversation_id": "a9de725e-f3c3-4bc6-9803-362ef76d3c49","inputs": {},"query": "222","answer": "Hello! It seems you've typed \"222\". How can I assist you with this? Are you looking for mathematical operations or is it related to a code, phone number or something else? Please provide more details so I can assist you better.","message_files": [],"feedback": null,"retriever_resources": [],"created_at": 1718523368,"agent_thoughts": [],"status": "normal","error": null},{"id": "3f61f0de-f759-4039-9d83-dcd3f4126c65","conversation_id": "a9de725e-f3c3-4bc6-9803-362ef76d3c49","inputs": {},"query": "333","answer": "It looks like you've now typed \"333\". Are you perhaps sharing numbers for a specific reason or looking for a particular pattern or information associated with these numbers? Kindly provide more context so I can assist you effectively.","message_files": [],"feedback": null,"retriever_resources": [],"created_at": 1718523378,"agent_thoughts": [],"status": "normal","error": null}]
}

下面这个是 eventstream 返回。

正常的单个item
{"event": "message", "conversation_id": "a9de725e-f3c3-4bc6-9803-362ef76d3c49", "message_id": "3f61f0de-f759-4039-9d83-dcd3f4126c65", "created_at": 1718523378, "task_id": "438214f6-e4a7-4020-84ae-ec5b0c3bd511", "id": "3f61f0de-f759-4039-9d83-dcd3f4126c65", "answer": ""}
eventstream的最后一个
{"event": "message_end", "conversation_id": "a9de725e-f3c3-4bc6-9803-362ef76d3c49", "message_id": "3f61f0de-f759-4039-9d83-dcd3f4126c65", "created_at": 1718523378, "task_id": "438214f6-e4a7-4020-84ae-ec5b0c3bd511", "id": "3f61f0de-f759-4039-9d83-dcd3f4126c65", "metadata": {"usage": {"prompt_tokens": 1, "prompt_unit_price": "0", "prompt_price_unit": "0", "prompt_price": "0.0000000", "completion_tokens": 44, "completion_unit_price": "0", "completion_price_unit": "0", "completion_price": "0.0000000", "total_tokens": 45, "total_price": "0.0000000", "currency": "USD", "latency": 2.9540078879799694}}}

这么奢侈的吗?

在这里插入图片描述

看看 coze

用的也是 eventstream。

response 的 type 大概有这几种:

  • ack
  • verbose
  • answer
  • follow_up
{"message":{"role":"user","type":"ack","content":"你知道薛之谦吗?","content_type":"text","message_id":"7381002802132156435","reply_id":"7381002802132156435","section_id":"7366505240650285090","extra_info":{"local_message_id":"Vi2fyFvCENEa2KQn2f7Rx","input_tokens":"","output_tokens":"","token":"","plugin_status":"","time_cost":"","workflow_tokens":"","bot_state":"","plugin_request":"","tool_name":"","plugin":"","mock_hit_info":"","log_id":"20240616154036FE428F3592749279D50E","stream_id":"","message_title":"","stream_plugin_running":"","new_section_id":"","remove_query_id":"","execute_display_name":""},"status":"","sender_id":"7366504662972760100","content_time":1718523636761,"message_index":"1","source":0},"is_finish":true,"index":0,"conversation_id":"7366503630755315712","seq_id":0}{"message":{"role":"assistant","type":"verbose","content":"{\"msg_type\":\"time_capsule_recall\",\"data\":\"{\\\"wraped_text\\\":\\\"\\\",\\\"origin_search_results\\\":\\\"[]\\\"}\",\"from_module\":null,\"from_unit\":null}","content_type":"text","message_id":"7381002802132172819","reply_id":"7381002802132156435","section_id":"7366505240650285090","extra_info":{"local_message_id":"","input_tokens":"","output_tokens":"","token":"","plugin_status":"","time_cost":"0.3","workflow_tokens":"","bot_state":"","plugin_request":"","tool_name":"","plugin":"","mock_hit_info":"","log_id":"20240616154036FE428F3592749279D50E","stream_id":"","message_title":"","stream_plugin_running":"","new_section_id":"","remove_query_id":"","execute_display_name":""},"status":"","sender_id":"7366504662972760100","content_time":0,"message_index":"0","source":0},"is_finish":true,"index":1,"conversation_id":"7366503630755315712","seq_id":1}{"message":{"role":"assistant","type":"answer","content":"当然","content_type":"text","message_id":"7381002802132221971","reply_id":"7381002802132156435","section_id":"7366505240650285090","extra_info":{"local_message_id":"","input_tokens":"2618","output_tokens":"0","token":"2618","plugin_status":"","time_cost":"","workflow_tokens":"","bot_state":"{\"bot_id\":\"7366504662972760100\"}","plugin_request":"","tool_name":"","plugin":"","mock_hit_info":"","log_id":"20240616154036FE428F3592749279D50E","stream_id":"267da90686d0484b8751229cf045037c","message_title":"","stream_plugin_running":"","new_section_id":"","remove_query_id":"","execute_display_name":""},"status":"","sender_id":"7366504662972760100","content_time":1718523638670,"message_index":"2","source":0},"is_finish":false,"index":2,"conversation_id":"7366503630755315712","seq_id":2}最后一个:
{"message":{"role":"assistant","type":"verbose","content":"{\"msg_type\":\"generate_answer_finish\",\"data\":\"\",\"from_module\":null,\"from_unit\":null}","content_type":"text","message_id":"7381002802132353043","reply_id":"7381002802132156435","section_id":"7366505240650285090","extra_info":{"local_message_id":"","input_tokens":"","output_tokens":"","token":"","plugin_status":"","time_cost":"4.1","workflow_tokens":"","bot_state":"{\"bot_id\":\"7366504662972760100\"}","plugin_request":"","tool_name":"","plugin":"","mock_hit_info":"","log_id":"20240616154036FE428F3592749279D50E","stream_id":"","message_title":"","stream_plugin_running":"","new_section_id":"","remove_query_id":"","execute_display_name":""},"status":"","sender_id":"7366504662972760100","content_time":0,"message_index":"0","source":0},"is_finish":true,"index":3,"conversation_id":"7366503630755315712","seq_id":76}建议:
{"message":{"role":"assistant","type":"follow_up","content":"薛之谦的代表作有哪些?","content_type":"text","message_id":"7381002802132418579","reply_id":"7381002802132156435","section_id":"7366505240650285090","extra_info":{"local_message_id":"","input_tokens":"","output_tokens":"","token":"","plugin_status":"","time_cost":"","workflow_tokens":"","bot_state":"{\"bot_id\":\"7366504662972760100\"}","plugin_request":"","tool_name":"","plugin":"","mock_hit_info":"","log_id":"20240616154036FE428F3592749279D50E","stream_id":"","message_title":"","stream_plugin_running":"","new_section_id":"","remove_query_id":"","execute_display_name":""},"status":"","sender_id":"7366504662972760100","content_time":0,"message_index":"0","source":0},"is_finish":true,"index":4,"conversation_id":"7366503630755315712","seq_id":77}

在这里插入图片描述

这篇关于ChatGPT 网页会话过程数据传输分析以及横向对比的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1067046

相关文章

网页解析 lxml 库--实战

lxml库使用流程 lxml 是 Python 的第三方解析库,完全使用 Python 语言编写,它对 XPath表达式提供了良好的支 持,因此能够了高效地解析 HTML/XML 文档。本节讲解如何通过 lxml 库解析 HTML 文档。 pip install lxml lxm| 库提供了一个 etree 模块,该模块专门用来解析 HTML/XML 文档,下面来介绍一下 lxml 库

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

AI绘图怎么变现?想做点副业的小白必看!

在科技飞速发展的今天,AI绘图作为一种新兴技术,不仅改变了艺术创作的方式,也为创作者提供了多种变现途径。本文将详细探讨几种常见的AI绘图变现方式,帮助创作者更好地利用这一技术实现经济收益。 更多实操教程和AI绘画工具,可以扫描下方,免费获取 定制服务:个性化的创意商机 个性化定制 AI绘图技术能够根据用户需求生成个性化的头像、壁纸、插画等作品。例如,姓氏头像在电商平台上非常受欢迎,

作业提交过程之HDFSMapReduce

作业提交全过程详解 (1)作业提交 第1步:Client调用job.waitForCompletion方法,向整个集群提交MapReduce作业。 第2步:Client向RM申请一个作业id。 第3步:RM给Client返回该job资源的提交路径和作业id。 第4步:Client提交jar包、切片信息和配置文件到指定的资源提交路径。 第5步:Client提交完资源后,向RM申请运行MrAp

从去中心化到智能化:Web3如何与AI共同塑造数字生态

在数字时代的演进中,Web3和人工智能(AI)正成为塑造未来互联网的两大核心力量。Web3的去中心化理念与AI的智能化技术,正相互交织,共同推动数字生态的变革。本文将探讨Web3与AI的融合如何改变数字世界,并展望这一新兴组合如何重塑我们的在线体验。 Web3的去中心化愿景 Web3代表了互联网的第三代发展,它基于去中心化的区块链技术,旨在创建一个开放、透明且用户主导的数字生态。不同于传统

AI一键生成 PPT

AI一键生成 PPT 操作步骤 作为一名打工人,是不是经常需要制作各种PPT来分享我的生活和想法。但是,你们知道,有时候灵感来了,时间却不够用了!😩直到我发现了Kimi AI——一个能够自动生成PPT的神奇助手!🌟 什么是Kimi? 一款月之暗面科技有限公司开发的AI办公工具,帮助用户快速生成高质量的演示文稿。 无论你是职场人士、学生还是教师,Kimi都能够为你的办公文

性能分析之MySQL索引实战案例

文章目录 一、前言二、准备三、MySQL索引优化四、MySQL 索引知识回顾五、总结 一、前言 在上一讲性能工具之 JProfiler 简单登录案例分析实战中已经发现SQL没有建立索引问题,本文将一起从代码层去分析为什么没有建立索引? 开源ERP项目地址:https://gitee.com/jishenghua/JSH_ERP 二、准备 打开IDEA找到登录请求资源路径位置

Andrej Karpathy最新采访:认知核心模型10亿参数就够了,AI会打破教育不公的僵局

夕小瑶科技说 原创  作者 | 海野 AI圈子的红人,AI大神Andrej Karpathy,曾是OpenAI联合创始人之一,特斯拉AI总监。上一次的动态是官宣创办一家名为 Eureka Labs 的人工智能+教育公司 ,宣布将长期致力于AI原生教育。 近日,Andrej Karpathy接受了No Priors(投资博客)的采访,与硅谷知名投资人 Sara Guo 和 Elad G

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss