1 Star 0 Fork 0

Survivor_zzc/langchaingo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Survivor_zzc 提交于 2023-10-24 17:21 . package name
package vertexai
import (
"gitee.com/zzcadmin/langchaingo/llms/vertexai"
)
const (
_defaultBatchSize = 512
_defaultStripNewLines = true
)
// Option is a function type that can be used to modify the client.
type Option func(p *VertexAIPaLM)
// WithClient is an option for providing the LLM client.
func WithClient(client vertexai.LLM) Option {
return func(p *VertexAIPaLM) {
p.client = &client
}
}
// WithStripNewLines is an option for specifying the should it strip new lines.
func WithStripNewLines(stripNewLines bool) Option {
return func(p *VertexAIPaLM) {
p.StripNewLines = stripNewLines
}
}
// WithBatchSize is an option for specifying the batch size.
func WithBatchSize(batchSize int) Option {
return func(p *VertexAIPaLM) {
p.BatchSize = batchSize
}
}
func applyClientOptions(opts ...Option) (*VertexAIPaLM, error) {
v := &VertexAIPaLM{
StripNewLines: _defaultStripNewLines,
BatchSize: _defaultBatchSize,
}
for _, opt := range opts {
opt(v)
}
if v.client == nil {
client, err := vertexai.New()
if err != nil {
return nil, err
}
v.client = client
}
return v, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zzcadmin/langchaingo.git
git@gitee.com:zzcadmin/langchaingo.git
zzcadmin
langchaingo
langchaingo
v0.2.3

搜索帮助

344bd9b3 5694891 D2dac590 5694891