Skip to content

初始化coze客户端后,有警告提示 #27

@zooyoyo

Description

@zooyoyo

func InitCozeloop(WithAPIToken, WorkspaceID string) (cozeloopClient cozeloop.Client, err error) {
// ctx := context.Background()
// IMPORTANT: The client is thread-safe. You should NewClient only once in your program.
client, err := cozeloop.NewClient(
// You can also set your oauth info instead of environment variables.
// loop.WithJWTOAuthClientID("your client id"),
// loop.WithJWTOAuthPrivateKey("your private key"),
// loop.WithJWTOAuthPublicKeyID("your public key id"),
cozeloop.WithAPIToken(WithAPIToken),
// You can set the workspace ID instead of environment variables.
cozeloop.WithWorkspaceID(WorkspaceID),

	// You can set the API base URL. Generally, there's no need to use it.
	// loop.WithAPIBaseURL("https://api.coze.cn"),

	// The SDK will communicate with the Loop server. You can set the read timeout for requests.
	// Default value is 3 seconds.
	cozeloop.WithTimeout(time.Second*3),
	// The SDK will upload images or large text to file storage server when necessary.
	// You can set the upload timeout for requests.
	// Default value is 30 seconds.
	cozeloop.WithUploadTimeout(time.Second*30),
	// Or you can set your own http client and make more custom configs.
	cozeloop.WithHTTPClient(http.DefaultClient),
	// If your trace input or output is more than 1M, and UltraLargeTraceReport is false,
	// input or output will be cut off.
	// If UltraLargeTraceReport is true, input or output will be uploaded to file storage server separately.
	// Default value is false.
	cozeloop.WithUltraLargeTraceReport(false),
	// The SDK will cache the prompts locally. You can set the max count of prompts.
	// Default value is 100.
	cozeloop.WithPromptCacheMaxCount(100),
	// The SDK will refresh the local prompts cache periodically. You can set the refresh interval.
	// Default value is 1 minute.
	cozeloop.WithPromptCacheRefreshInterval(time.Minute*1),
	// Set whether to report a trace span when get or format prompt.
	// Default value is false.
	cozeloop.WithPromptTrace(false),
)
if err != nil {
	return client, fmt.Errorf("cozeloop init error: %v", err)
}
return client, nil

}

log:
2025/11/17 05:53:25.104010 noop.go:56: [Warn] [cozeloop] Noop client not supported. invalid param: workspaceID is required

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions