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

相关文章

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

Spring AI集成DeepSeek的详细步骤

《SpringAI集成DeepSeek的详细步骤》DeepSeek作为一款卓越的国产AI模型,越来越多的公司考虑在自己的应用中集成,对于Java应用来说,我们可以借助SpringAI集成DeepSe... 目录DeepSeek 介绍Spring AI 是什么?1、环境准备2、构建项目2.1、pom依赖2.2

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

redis群集简单部署过程

《redis群集简单部署过程》文章介绍了Redis,一个高性能的键值存储系统,其支持多种数据结构和命令,它还讨论了Redis的服务器端架构、数据存储和获取、协议和命令、高可用性方案、缓存机制以及监控和... 目录Redis介绍1. 基本概念2. 服务器端3. 存储和获取数据4. 协议和命令5. 高可用性6.

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

Spring AI Alibaba接入大模型时的依赖问题小结

《SpringAIAlibaba接入大模型时的依赖问题小结》文章介绍了如何在pom.xml文件中配置SpringAIAlibaba依赖,并提供了一个示例pom.xml文件,同时,建议将Maven仓... 目录(一)pom.XML文件:(二)application.yml配置文件(一)pom.xml文件:首

PLsql Oracle 下载安装图文过程详解

《PLsqlOracle下载安装图文过程详解》PL/SQLDeveloper是一款用于开发Oracle数据库的集成开发环境,可以通过官网下载安装配置,并通过配置tnsnames.ora文件及环境变... 目录一、PL/SQL Developer 简介二、PL/SQL Developer 安装及配置详解1.下

在Java中使用ModelMapper简化Shapefile属性转JavaBean实战过程

《在Java中使用ModelMapper简化Shapefile属性转JavaBean实战过程》本文介绍了在Java中使用ModelMapper库简化Shapefile属性转JavaBean的过程,对比... 目录前言一、原始的处理办法1、使用Set方法来转换2、使用构造方法转换二、基于ModelMapper

springboot启动流程过程

《springboot启动流程过程》SpringBoot简化了Spring框架的使用,通过创建`SpringApplication`对象,判断应用类型并设置初始化器和监听器,在`run`方法中,读取配... 目录springboot启动流程springboot程序启动入口1.创建SpringApplicat