{"id":13432399,"url":"https://github.com/jiran214/chatBilibili","last_synced_at":"2025-03-16T23:31:14.648Z","repository":{"id":157014534,"uuid":"625253217","full_name":"jiran214/chatBilibili","owner":"jiran214","description":"ChatBilibili .基于Fastapi 和ChatGPT Embedding ，实时生成视频概要，检索上下文视频提问/聊天","archived":false,"fork":false,"pushed_at":"2023-04-18T00:46:10.000Z","size":205,"stargazers_count":30,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T21:51:06.633Z","etag":null,"topics":["bilibili","chatgpt","embedding","fastapi","gpt","gpt-3","openai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiran214.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-08T14:39:49.000Z","updated_at":"2025-02-19T17:10:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"39a98147-8b9a-4f87-9347-3c4fbaf1f26e","html_url":"https://github.com/jiran214/chatBilibili","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiran214%2FchatBilibili","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiran214%2FchatBilibili/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiran214%2FchatBilibili/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiran214%2FchatBilibili/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiran214","download_url":"https://codeload.github.com/jiran214/chatBilibili/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243949884,"owners_count":20373653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bilibili","chatgpt","embedding","fastapi","gpt","gpt-3","openai"],"created_at":"2024-07-31T02:01:11.140Z","updated_at":"2025-03-16T23:31:14.639Z","avatar_url":"https://github.com/jiran214.png","language":"Python","funding_links":[],"categories":["数据分析"],"sub_categories":["直播脚本"],"readme":"# 项目名称\n\nChatBilibili\n\n## 简介\n\n基于embedding和ChatGPT3.5，实时生成B站视频概要，同时支持和视频内容聊天\n\n## 环境\n\n- python 3. 8\n- mongo[暂时]\n\n## 安装配置\n\n```\ngit clone https://github.com/jiran214/chatBilibili.git\ncd backend\npip install -r .\\requirements.txt\npython ./main\n\n访问 host:port/docs 接口调试文档\n```\n\n在backend目录下创建配置文件config.int模板(该项目所有配置信息都在这)\n\n```ini\n[mongo]\nhost = localhost\nusername =\npassword =\nport = 27017\ndb_name = chat2Bili\n\n[openai]\napi_key = xxx\n\n[service]\nhost = 127.0.0.1\nport = 8080\n\n[other]\ndebug = True  \nproxy = 127.0.0.1:7890\nbili_cookie = SESSDATA=xxxxxxxxxxxxxx\nsome_config = ...\n```\n\n\n\n## 功能介绍\n\n![image-20230409211417238](https://raw.githubusercontent.com/jiran214/chatBilibili/master/public/image-20230409211417238.png)\n\n使用fastapi的docs体验功能\n\n![image-20230409211640365](https://raw.githubusercontent.com/jiran214/chatBilibili/master/public/image-20230409211640365.png)\n\nnote_query：BV号或者视频aid\n\nquestion：聊天的问题\n\n注：需要先调summary接口，在本地生成向量数据，才能开启聊天\n\n### summary\n\n示例：[【4K顶级画质60FPS】蔡徐坤《只因你太美》原版完整版现场！一晃眼6年过去了_哔哩哔哩_bilibili](https://www.bilibili.com/video/BV1ct4y1n7t9/?spm_id_from=333.337.search-card.all.click\u0026vd_source=df965f3f6f275f55ae2075576c0f4750)\n\n![image-20230409212218735](https://raw.githubusercontent.com/jiran214/chatBilibili/master/public/image-20230409212218735.png)\n\n```markdown\n## 摘要\n\n蔡徐坤演唱《只因你太美》原版完整版现场，以顶尖的幕后制作保证高质量音乐和画面。\n\n## 要点\\n\\n- 🎤 蔡徐坤以个人实力及原创作品展现音乐才华。\n- 🎶 充满感性色彩的歌词，表达爱情的美好。\n- 💃 独具匠心的编舞，为歌曲创造更动人的表演，体现音乐舞蹈的完美结合。\n- 🏀 蔡徐坤不仅是唱跳偶像，还是篮球运动员。\n- 📝 蔡徐坤不仅有才华，还拥有作词能力，为自己的音乐创作贡献更多。\n- 🤝 这是全民制作的作品，多方参与，体现团队力量。\n- 🎉 期待蔡徐坤的粉丝可以在接下来的节目中为他投票，为他加油打气。\n```\n\n### chat\n\n问问坤坤喜欢什么？\n\n![image-20230409213138401](https://raw.githubusercontent.com/jiran214/chatBilibili/master/public/image-20230409213138401.png)\n\n```markdown\n根据您提供的段落，我可以回答您的问题。据我了解，您是蔡徐坤粉丝或者喜欢他的音乐和表演，因为这些段落包含了一些与他相关的话题。蔡徐坤擅长的方面包括唱跳 rap、篮球、以及作曲编舞的原创作品。在他的歌曲中，\\\"只因你太美\\\" 和 \\\"who you\\\" 这两首歌深受粉丝们的喜爱，并且他还制作了很多自己的作词。如果您是蔡徐坤的粉丝，那么您应该期待他在未来的节目中的表现，并多多为他投票，以支持他的音乐事业。综上所述，蔡徐坤擅长的方面主要集中在音乐表演和篮球方面。\n```\n\n### comment\n\n自动视频的生成评论\n\n![image-20230409213138401](https://raw.githubusercontent.com/jiran214/chatBilibili/master/public/Snipaste_2023-04-17_16-41-23.png)\n\n\n### 一些说明：\n\n- 生成摘要时，根据标题匹配top n个向量对应的chunk，作为摘要上下文\n\n- 支持没有cc字幕的视频（必剪接口解决），也就是任何B站视频都能chat\n\n- 搜索邻近向量封装了方法，官方推荐用余弦相似度\n\n- 尝试过一些向量数据库，本地知识库的应用场景需要用到，本项目数据量较小没必要用\n\n- 长文本请求text-embedding-ada-002模型时，根据文本长度和最大token，要分批次请求\n\n- openAi库不支持修改aiohttp和requests模块的ssl，导致开启代理会报错，通过源码阅读利用猴子补丁实现openai库的代理请求\n\n  ```python\n  # openAi.py\n  \n  proxies = {}\n  import requests\n  from openai import api_requestor\n  \n  def make_session() -\u003e requests.Session:\n      s = requests.Session()\n      s.verify = False\n      s.proxies = proxies\n      urllib3.disable_warnings()\n      s.trust_env = False\n      s.mount(\n          \"https://\",\n          requests.adapters.HTTPAdapter(max_retries=2),\n      )\n      return s\n  \n  session = make_session()\n  @asynccontextmanager\n  async def aiohttp_session() -\u003e AsyncIterator[aiohttp.ClientSession]:\n      async with aiohttp.ClientSession(connector=TCPConnector(ssl=False)) as session:\n          yield session\n  \n  # 猴子补丁\n  if config.proxy:\n      # api_requestor._make_session = make_session\n      setattr(api_requestor._thread_context, 'session', session)\n      api_requestor.aiohttp_session = aiohttp_session\n  ```\n\n## 项目结构\n\n待更新...\n\n## 未来计划\n\n- [x] note_query支持各种形式的视频查询\n- [ ] 前端 ...\n- [ ] Event Stream\n- [ ] redis缓存chat上下文\n- [ ] prompt优化，支持更多选项\n- [ ] 优化接口响应速度\n- [x] Nginx部署\n\n...\n\n## 参考资料\n\n- prompt暂时参考了： [JimmyLv/BibiGPT: BibiGPT · One-click summary for video \u0026 audio content: Bilibili | YouTube | Websites丨Podcasts | Meetings | Local files, etc. 音视频内容一键总结：哔哩哔哩丨YouTube丨网页丨播客丨会议丨本地文件等 (原 BiliGPT 省流神器 \u0026 课代表) (github.com)](https://github.com/JimmyLv/BibiGPT)\n- 必剪语音转文字：[SocialSisterYi/bcut-asr: 使用必剪API的语音字幕识别 (github.com)](https://github.com/SocialSisterYi/bcut-asr)\n\n## Problem\n\n1. 最大的IO瓶颈在GPT3.5接口请求上，要40秒左右（改成stream输出会好些），可能是我vpn的问题\n2. 视频的字幕很碎，破坏了句子原本意思，很影响向量搜索的准确性\n\n## 更新日志\n\n- 4.15 新增自动生成视频评论：comment接口\n- 4.17 nginx部署\u0026note_query支持链接查询\n\n## Contact Me\n\n欢迎加我WX：yuchen59384 交流！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiran214%2FchatBilibili","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiran214%2FchatBilibili","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiran214%2FchatBilibili/lists"}