Add GLM SDK Implementation
- Introduced a new GLM SDK for interacting with the GLM (Zhipu AI) API, designed for chat completions and text generation tasks. - Implemented core components including Client, Service, and SDK layers following Clean Architecture principles. - Added configuration management, error handling, and structured logging for improved usability and maintainability. - Included comprehensive documentation and usage examples to facilitate integration and understanding of the SDK's functionality. - Enhanced the API with features such as chat completion, streaming responses, and model management, ensuring robust interaction with the GLM service.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package glm
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// GLMService defines the interface for GLM service operations
|
||||
type GLMService interface {
|
||||
// ChatCompletion performs a chat completion request
|
||||
ChatCompletion(ctx context.Context, req *ChatCompletionRequest) (*ChatCompletionResponse, error)
|
||||
|
||||
// StreamChatCompletion performs a streaming chat completion request
|
||||
StreamChatCompletion(ctx context.Context, req *ChatCompletionRequest, onChunk func(*StreamChatCompletionResponse) error) error
|
||||
|
||||
// ListModels lists available models
|
||||
ListModels(ctx context.Context) (*ModelsResponse, error)
|
||||
|
||||
// Health checks if the GLM service is available
|
||||
Health(ctx context.Context) error
|
||||
}
|
||||
|
||||
// HTTPClient defines the interface for HTTP operations
|
||||
type HTTPClient interface {
|
||||
// Post performs a POST request
|
||||
Post(ctx context.Context, url string, body interface{}, result interface{}) error
|
||||
|
||||
// Get performs a GET request
|
||||
Get(ctx context.Context, url string, result interface{}) error
|
||||
}
|
||||
Reference in New Issue
Block a user