kd icon indicating copy to clipboard operation
kd copied to clipboard

查询同一句话有时会报错有时不会

Open SilverofLight opened this issue 1 year ago • 5 comments

image 我在使用 kd -t 查同一句话时,有时会出错:

☣ ERROR: 解析daemon返回结果失败: unexpected end of JSON input

有时又正常翻译

SilverofLight avatar Dec 19 '24 15:12 SilverofLight

相同的问题。在长时间的使用过程中我整理了一批出现过“解析daemon返回结果失败”的样例,列在这里供作者debug参考

曾经出现过

☣ ERROR: 解析daemon返回结果失败: unexpected end of JSON input

的测试样例:

========================================================================
>>> cash strapped
========================================================================
>>> economic sanctions
========================================================================
>>> articulatio coxae synovitis
========================================================================
>>> Recognizing Textual Entailment
========================================================================
>>> pickled turnips
========================================================================
>>> probiotic yogurt
========================================================================
>>> cooling racks
========================================================================
>>> penceil erasers
========================================================================
>>> littoral combat ship
========================================================================
>>> staff officers

这里ff命令等于kd -t 解析daemon返回结果失败

exaithrg avatar Dec 19 '24 15:12 exaithrg

https://github.com/Karmenzind/kd/issues/49 你这个守护进程的启动有问题,我另外开了issue,请在这里补充一下系统环境信息和日志文件 通过kd --status可以找到日志文件地址。 @exaithrg

Karmenzind avatar Dec 23 '24 07:12 Karmenzind

@SilverofLight 这个我没能复现,请问你用的是最新版本吗?你把配置文件中的logging level设置成debug,然后提供一下相关日志吧

Karmenzind avatar Dec 30 '24 07:12 Karmenzind

查询失败的log:

2024-12-31T20:16:10.119+0800	INFO	systemd/systemd.go:20	Executed: `/usr/bin/systemctl is-active --user kd-server` Result: `inactive` Error: exit status 4
2024-12-31T20:16:10.123+0800	INFO	systemd/systemd.go:20	Executed: `/usr/bin/systemctl is-active --user kd-server` Result: `inactive` Error: exit status 4
2024-12-31T20:16:10.146+0800	DEBUG	daemon/process.go:107	Got executable path /usr/bin/kd
2024-12-31T20:16:10.149+0800	INFO	internal/server.go:44	Started kd server
2024-12-31T20:16:10.149+0800	DEBUG	pkg/file.go:25	Updated json file /home/silver/.cache/kdcache/run/daemon.json. Error: <nil>. BodyLength: 156
2024-12-31T20:16:10.149+0800	INFO	model/others.go:67	Recorded running information of daemon &{StartTime:1735647370 PID:940037 Port:19707 ExeName:kd ExePath:/usr/bin/kd Version:v0.0.12 OS:0xc0000124b0 isServer:true termHeight:0 termWidth:0}
2024-12-31T20:16:11.192+0800	DEBUG	daemon/process.go:93	Found process {"pid":940037} Cmd: `/usr/bin/kd --server`
2024-12-31T20:16:11.192+0800	INFO	daemon/process.go:123	Started daemon process.
2024-12-31T20:16:11.192+0800	DEBUG	cmd/kd.go:333	Recieved Arguments (len: 1): [是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。] 

2024-12-31T20:16:11.192+0800	DEBUG	query/query.go:35	[cache] Query error: no cache for 是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。
2024-12-31T20:16:11.214+0800	DEBUG	daemon/process.go:93	Found process {"pid":940037} Cmd: `/usr/bin/kd --server`
2024-12-31T20:16:11.215+0800	DEBUG	query/query.go:53	Sending msg: {"Action":"query","B":{"Query":"是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。","Prompt":"","IsEN":false,"IsPhrase":false,"Output":"","Found":false,"IsLongText":true,"MachineTrans":""}}

2024-12-31T20:16:11.298+0800	DEBUG	query/online.go:66	[http-get] query 'http://dict.youdao.com/w/是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。/#keyfrom=dict2.top' Resp len: 14663 Status: 200 OK
2024-12-31T20:16:11.300+0800	DEBUG	query/youdao.go:205	Got Machine trans from fanyiToggle: What makes two diametrically opposed political parties? One reason is the old Trump, and the other reason is Trump
2024-12-31T20:16:11.305+0800	DEBUG	query/query.go:60	Message from server: 
2024-12-31T20:16:11.305+0800	ERROR	cmd/kd.go:359	解析daemon返回结果失败: unexpected end of JSON input

main.main.func1
	/home/runner/work/kd/kd/cmd/kd.go:359
github.com/urfave/cli/v2.(*Command).Run
	/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:276
github.com/urfave/cli/v2.(*App).RunContext
	/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:333
github.com/urfave/cli/v2.(*App).Run
	/home/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:307
main.main
	/home/runner/work/kd/kd/cmd/kd.go:368
runtime.main
	/opt/hostedtoolcache/go/1.23.3/x64/src/runtime/proc.go:272

查询成功的 log:

2024-12-31T20:18:05.743+0800	DEBUG	cmd/kd.go:333	Recieved Arguments (len: 1): [是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。] 

2024-12-31T20:18:05.743+0800	DEBUG	query/query.go:35	[cache] Query error: no cache for 是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。
2024-12-31T20:18:05.765+0800	DEBUG	daemon/process.go:107	Got executable path /usr/bin/kd
2024-12-31T20:18:05.768+0800	INFO	internal/server.go:44	Started kd server
2024-12-31T20:18:05.769+0800	DEBUG	pkg/file.go:25	Updated json file /home/silver/.cache/kdcache/run/daemon.json. Error: <nil>. BodyLength: 156
2024-12-31T20:18:05.769+0800	INFO	model/others.go:67	Recorded running information of daemon &{StartTime:1735647485 PID:940803 Port:19707 ExeName:kd ExePath:/usr/bin/kd Version:v0.0.12 OS:0xc0001364c8 isServer:true termHeight:0 termWidth:0}
2024-12-31T20:18:06.792+0800	DEBUG	daemon/process.go:93	Found process {"pid":940803} Cmd: `/usr/bin/kd --server`
2024-12-31T20:18:06.792+0800	INFO	daemon/process.go:123	Started daemon process.
2024-12-31T20:18:06.793+0800	DEBUG	query/query.go:53	Sending msg: {"Action":"query","B":{"Query":"是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。","Prompt":"","IsEN":false,"IsPhrase":false,"Output":"","Found":false,"IsLongText":true,"MachineTrans":""}}

2024-12-31T20:18:06.873+0800	DEBUG	query/online.go:66	[http-get] query 'http://dict.youdao.com/w/是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。/#keyfrom=dict2.top' Resp len: 14663 Status: 200 OK
2024-12-31T20:18:06.874+0800	DEBUG	query/youdao.go:205	Got Machine trans from fanyiToggle: What makes two diametrically opposed political parties? One reason is the old Trump, and the other reason is Trump
2024-12-31T20:18:06.874+0800	DEBUG	query/query.go:60	Message from server: {"R":{"k":"","pron":null,"para":null,"eg":null,"co":{"star":0,"rank":"","pat":"","li":null}},"Error":"","Base":{"Query":"是什么造就了两个完全相反的政党?一个原因是以前的川普,另一个原因是川普。","Prompt":"","IsEN":false,"IsPhrase":false,"Output":"","Found":true,"IsLongText":true,"MachineTrans":"What makes two diametrically opposed political parties? One reason is the old Trump, and the other reason is Trump"}}

2024-12-31T20:18:06.874+0800	DEBUG	pkg/terminal.go:132	Got path of less: /usr/bin/less
2024-12-31T20:18:06.874+0800	DEBUG	pkg/terminal.go:64	Using default pager less -RF
2024-12-31T20:18:06.874+0800	DEBUG	pkg/terminal.go:132	Got path of less: /usr/bin/less

而且我也出现了每次查询句子都重启守护进程的问题

版本v0.0.12

SilverofLight avatar Dec 31 '24 12:12 SilverofLight

补充系统信息

❯ fastfetch
                                               silver@lee
                                               ╭───────────────────────────────╮
                                               |  OS: Arch Linux x86_64
                                               |  Kernel: Linux 6.12.7-arch1-1
                                               |  Uptime: 1 day, 9 hours, 16 mins
                                               |  Packages: 1507 (pacman)
                                               |  Shell: fish 3.7.1
                                               |  WM: Hyprland (Wayland)
                                               |  Theme: Fusion [Qt], dradula_a [GTK2/3]
                                               |  Icons: Papirus-Dark [Qt], Dracula [GTK2/3]
                                               |  Font: Cantarell (11pt) [Qt], System-ui (12pt) [GTK2/3]
                                               |  Terminal: kitty 0.38.1
                                               |  Terminal Font: HackNF-Regular (13pt)
                                               |  CPU: Intel(R) Core(TM) i5-10200H (8) @ 4.10 GHz
                                               |  GPU: NVIDIA GeForce GTX 1650 Ti Mobile [Discrete]
                                               |  Memory: 3.13 GiB / 7.54 GiB (42%)
                                               |  Swap: 3.28 GiB / 10.00 GiB (33%)
                                               |  Locale: en_US.UTF-8
                                               |
                                               |  Colors: ● ● ● ● ● ● ● ●
                                               ╰───────────────────────────────╯

[I] silver@lee ~ 
❯ cat /etc/*-release

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
[I] silver@lee ~ 
❯ lsb_release  -a
LSB Version:    n/a
Distributor ID: Arch
Description:    Arch Linux
Release:        rolling
Codename:       n/a
[I] silver@lee ~ 
❯ uname -a
Linux lee 6.12.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 27 Dec 2024 14:24:37 +0000 x86_64 GNU/Linux

SilverofLight avatar Dec 31 '24 12:12 SilverofLight

v0.0.14已经修复,请更新 https://github.com/Karmenzind/kd/releases/tag/v0.0.14

Karmenzind avatar Jul 30 '25 15:07 Karmenzind