Documentation
¶
Overview ¶
Package zai provides a Z.ai GLM API provider implementation for Iris.
Index ¶
- Constants
- Variables
- func GetModelInfo(id core.ModelID) *core.ModelInfo
- type Config
- type Option
- type Zai
- func (p *Zai) Chat(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)
- func (p *Zai) ID() string
- func (p *Zai) Models() []core.ModelInfo
- func (p *Zai) StreamChat(ctx context.Context, req *core.ChatRequest) (*core.ChatStream, error)
- func (p *Zai) Supports(feature core.Feature) bool
Constants ¶
const ( // GLM-4.7 series (latest flagship) ModelGLM47 core.ModelID = "glm-4.7" ModelGLM47Flash core.ModelID = "glm-4.7-flash" ModelGLM47FlashX core.ModelID = "glm-4.7-flashx" // GLM-4.6 series ModelGLM46 core.ModelID = "glm-4.6" ModelGLM46V core.ModelID = "glm-4.6v" ModelGLM46VFlash core.ModelID = "glm-4.6v-flash" ModelGLM46VFlashX core.ModelID = "glm-4.6v-flashx" // GLM-4.5 series ModelGLM45 core.ModelID = "glm-4.5" ModelGLM45V core.ModelID = "glm-4.5v" ModelGLM45X core.ModelID = "glm-4.5-x" ModelGLM45Air core.ModelID = "glm-4.5-air" ModelGLM45AirX core.ModelID = "glm-4.5-airx" ModelGLM45Flash core.ModelID = "glm-4.5-flash" // GLM-4 32B ModelGLM4_32B core.ModelID = "glm-4-32b-0414-128k" )
Model constants for Z.ai GLM models.
const DefaultBaseURL = "https://api.z.ai/api/coding/paas/v4"
DefaultBaseURL is the default base URL for the Z.ai API (coding endpoint).
Variables ¶
var ErrToolArgsInvalidJSON = errors.New("tool args invalid json")
ErrToolArgsInvalidJSON is returned when tool call arguments contain invalid JSON.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// APIKey is the API key for authentication.
APIKey string
// BaseURL is the base URL for the API. Defaults to DefaultBaseURL.
BaseURL string
// HTTPClient is the HTTP client to use for requests.
HTTPClient *http.Client
// Headers are additional headers to include in requests.
Headers http.Header
// Timeout is the request timeout. Zero means no timeout.
Timeout time.Duration
}
Config holds the configuration for the Z.ai provider.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring the Z.ai provider.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithHeaders ¶
WithHeaders sets additional headers to include in requests.
func WithTimeout ¶
WithTimeout sets the request timeout.
type Zai ¶
type Zai struct {
// contains filtered or unexported fields
}
Zai is an LLM provider implementation for the Z.ai GLM API. Zai is safe for concurrent use.
func (*Zai) Chat ¶
func (p *Zai) Chat(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)
Chat sends a non-streaming chat request.
func (*Zai) StreamChat ¶
func (p *Zai) StreamChat(ctx context.Context, req *core.ChatRequest) (*core.ChatStream, error)
StreamChat sends a streaming chat request.