ask

package
v0.7.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskExpert

func AskExpert(ctx context.Context, input string) (reply string, err error)

AskExpert 调用AI专家模型进行咨询并返回回复

该函数通过 internal/shell 包执行 dscli chat 命令,将输入内容写入临时文件, 通过 --input 参数传递给 dscli,避免了命令行长度限制和 stdin 传递问题。

参数:

ctx: 上下文对象,用于传递执行环境配置
input: 要发送给AI模型的输入文本,可以是任意长度(受系统内存限制)

返回值:

reply: AI模型的回复文本。如果执行失败且没有获得回复,返回空字符串。
err: 执行过程中的错误。如果执行成功,返回nil。常见错误包括:
     - dscli命令执行失败
     - 临时文件创建/写入失败

功能说明:

函数通过执行以下命令调用AI模型:
     dscli chat --no-color --no-timestamp --histsize 0 --model <模型名称> --input <临时文件>
其中模型名称由ModelDeepseekReasoner变量指定。

注意事项:

  • 确保dscli命令行工具已正确安装并配置
  • 输入内容通过临时文件传递,执行后自动清理

示例:

ctx := context.Background()
reply, err := AskExpert(ctx, "请分析这段代码的质量")
if err != nil {
    log.Printf("咨询失败: %v", err)
} else {
    fmt.Println(reply)
}

参见:

  • shell.SimpleExecute: 执行shell命令的函数
  • handleAskExpert: 使用此函数的工具处理函数
  • handleAskExpert: 使用此函数的工具处理函数

Types

This section is empty.

Source Files

  • ask_expert.go
  • ask_user.go
  • code_review.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL