分类 技术 下的文章

最近使用 Antigravity 自动生成Commit Message 会出错
Yup definitely broken… Error generating commit message: [unknown] error grabbing LLM response: stream error

很多人也有同样的问题,但官方都没修复。不知道是网络问题还是bug导致的。毕竟在国内都是魔法上网用的!
https://discuss.ai.google.dev/t/error-in-antigravity-not-generating-commit-message/114550/178

但这两天特别频繁,最后完全用不了了!
手写Commit Message太麻烦,后来想到可以用 Workflows 解决,也是挻方便的!

Description
Git Commit

Content

---
description: Automatically stage all changes and commit with a generated message
---
1. Stage all current changes in the repository.
   Run `git add .`
2. Generate a commit message following the Conventional Commits specification,written in Simplified Chinese.
   Ask: "Write a concise commit message summarizing the changes."
3. Create the commit using the generated message.
   Run `git commit -m "[generated commit message]"`

使用方法:在聊天窗口输入/后选择这个workflows既可!

最近练听力,找到 englishpod 的 mp3,非常不错,但是缺少同步字幕,所以用openai的whisper来转换
但是官方的 whisper 每次只处理30s,需要分片处理,所以找到了 Whisper Jax 声称速度更快,而且不需要自己处理分片的问题。

import jax
import jax.numpy as jnp
import os
import time
import json
import magic
from whisper_jax import FlaxWhisperPipline

def get_mp3_files(directory):
    total_files = 0
    print(f"scanning files...")
    for root, dirs, files in os.walk(directory):
        for file in files:
            mime = magic.Magic(mime=True)
            if mime.from_file(os.path.join(root, file)) == 'audio/mpeg':
                total_files += 1
                yield os.path.join(root, file)
    print(f"Total files: {total_files}")

def mp3_to_text(directory):
    pipeline = FlaxWhisperPipline("openai/whisper-large-v2", dtype=jnp.bfloat16)
    for mp3_file in get_mp3_files(directory):
        print(f"Processing file: {mp3_file}")

        txt_file = os.path.splitext(mp3_file)[0] + '.txt'
        if os.path.isfile(txt_file):
            print(f"Skipping file: {mp3_file}")
            continue

        start_time = time.time()
        text = pipeline(mp3_file, task="translate", language="chinese",return_timestamps=True)
        text_length = len(text['text'])  # 获取转录文本的长度
        print(f"Text length: {text_length} characters")
        end_time = time.time()
        print(f"Processed in {end_time - start_time} seconds")

        with open(txt_file, 'w') as f:
            f.write(json.dumps(text))


start_time = time.time()
mp3_to_text('/data/englishpod')
end_time = time.time()
print(f"Total time: {end_time - start_time} seconds")

使用这个工具
https://github.com/vzhd1701/evernote-backup

备份步骤1
如果是印象笔记要注意的是需要加入 --backend china 参数

./evernote-backup.exe init-db --backend china
Logging in to Evernote...
Username or Email: king@gmail.com
Password:
Enter one-time code (+XX XXX XXXX 2010): 638303
Authorizing auth token, china backend...
Successfully authenticated as king!
Current login will expire at 2024-07-09 07:31:21.
Initializing database en_backup.db...
Reading database en_backup.db...
Successfully initialized database for king!

备份步骤2

./evernote-backup.exe sync
Reading database en_backup.db...
Authorizing auth token, china backend...
Successfully authenticated as king!
Current login will expire at 2024-07-09 07:31:21.
Syncing user notebooks...
  [####################################]  60931/60931
2267 note(s) to download...
Downloading 2267 note(s)...
  [####################################]  2267/2267
Updated or added notebooks: 96
Updated or added notes: 2267
Expunged notebooks: 38
Expunged linked notebooks: 0
Expunged notes: 660
Synchronization completed!

备份步骤3

./evernote-backup.exe export ./
Reading database en_backup.db...
Exporting notes...
  [####################################]  96/96
All notes have been exported!

Swoole4.5.7 + hyperf

用阿里云上传文件的时候莫名奇妙的异常
Oss\Core\OssException: : RequestId:

找了好久才定位到是SWOOLE_HOOK_CURL导致的问题,于是
检查 bin/hyperf.php
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL);
配置是对的,根据Swoole官方文档 SWOOLE_HOOK_ALL:打开所有类型但不包括CURL
https://wiki.swoole.com/wiki/diff/?id=993&version=0&compare=current

然后发现一个好心人做了一个兼容组件
https://github.com/Reasno/swoole-aliyunoss-addon

安装后再把SWOOLE_HOOK_CURL打开
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL)

错误却变成了
string(106) "MissingContentLength: You must provide the Content-Length HTTP header. RequestId: 5FC048380D92D938376A214A"
这种情况不用定位了,还是换个Swoole版本看看效果,先删除swoole-aliyunoss-addon

composer remove swoole-aliyunoss-addon

然后把Swoole升级到4.5.8问题依旧
最后把Swoole降级到4.5.2问题解决

看了官方文档
https://wiki.swoole.com/#/runtime?id=swoole_hook_all
从 v4.5.4 版本起,SWOOLE_HOOK_ALL 包括 SWOOLE_HOOK_CURL
原来是这样....

如果版本高于4.5.4使用下面这个就可以解决问题了
! defined('SWOOLE_HOOK_FLAGS') && define('SWOOLE_HOOK_FLAGS', SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_CURL)

还有一个解决方案就是使用支持hook curl的php oss sdk
https://packagist.org/packages/starfalling/aliyun-oss-php-sdk

旁路由部署好后,问题来了,设备要手动设置网关地址,很不方便
例如我的主路由IP是192.168.1.1
旁路由是192.168.1.10
因为DHCP服务器在主路由上,所以获取到的网关都是主路由IP
这时候可以通过 dnsmasq 解决这个问题
在主路由OPENWRT里面编辑
vim /etc/dnsmasq.conf
在最后面添加
dhcp-option=3,192.168.1.10
dhcp-option=6,192.168.1.10
这样主路由的DHCP在分配IP的时候会把网站和DNS分配为192.168.1.10