WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
// Package client provides the implementation for interacting with the WeKnora API
|
||||
// The Evaluation related interfaces are used for starting and retrieving model evaluation task results
|
||||
// Evaluation tasks can be used to measure model performance and
|
||||
// compare different embedding models, chat models, and reranking models
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// EvaluationTask represents an evaluation task
|
||||
// Contains basic information about a model evaluation task
|
||||
type EvaluationTask struct {
|
||||
ID string `json:"id"` // Task unique identifier
|
||||
Status string `json:"status"` // Task status: pending, running, completed, failed
|
||||
Progress int `json:"progress"` // Task progress, integer value 0-100
|
||||
DatasetID string `json:"dataset_id"` // Evaluation dataset ID
|
||||
EmbeddingID string `json:"embedding_id"` // Embedding model ID
|
||||
ChatID string `json:"chat_id"` // Chat model ID
|
||||
RerankID string `json:"rerank_id"` // Reranking model ID
|
||||
CreatedAt string `json:"created_at"` // Task creation time
|
||||
CompleteAt string `json:"complete_at"` // Task completion time
|
||||
ErrorMsg string `json:"error_msg"` // Error message, has value when task fails
|
||||
}
|
||||
|
||||
// EvaluationResult represents the evaluation results
|
||||
// Contains detailed evaluation result information
|
||||
type EvaluationResult struct {
|
||||
TaskID string `json:"task_id"` // Associated task ID
|
||||
Status string `json:"status"` // Task status
|
||||
Progress int `json:"progress"` // Task progress
|
||||
TotalQueries int `json:"total_queries"` // Total number of queries
|
||||
TotalSamples int `json:"total_samples"` // Total number of samples
|
||||
Metrics map[string]float64 `json:"metrics"` // Evaluation metrics collection
|
||||
QueriesStat []map[string]interface{} `json:"queries_stat"` // Statistics for each query
|
||||
CreatedAt string `json:"created_at"` // Creation time
|
||||
CompleteAt string `json:"complete_at"` // Completion time
|
||||
ErrorMsg string `json:"error_msg"` // Error message
|
||||
}
|
||||
|
||||
// EvaluationRequest represents an evaluation request
|
||||
// Parameters used to start a new evaluation task
|
||||
type EvaluationRequest struct {
|
||||
DatasetID string `json:"dataset_id"` // Dataset ID to evaluate
|
||||
EmbeddingModelID string `json:"embedding_id"` // Embedding model ID
|
||||
ChatModelID string `json:"chat_id"` // Chat model ID
|
||||
RerankModelID string `json:"rerank_id"` // Reranking model ID
|
||||
}
|
||||
|
||||
// EvaluationTaskResponse represents an evaluation task response
|
||||
// API response structure for evaluation tasks
|
||||
type EvaluationTaskResponse struct {
|
||||
Success bool `json:"success"` // Whether operation was successful
|
||||
Data EvaluationTask `json:"data"` // Evaluation task data
|
||||
}
|
||||
|
||||
// EvaluationResultResponse represents an evaluation result response
|
||||
// API response structure for evaluation results
|
||||
type EvaluationResultResponse struct {
|
||||
Success bool `json:"success"` // Whether operation was successful
|
||||
Data EvaluationResult `json:"data"` // Evaluation result data
|
||||
}
|
||||
|
||||
// StartEvaluation starts an evaluation task
|
||||
// Creates and starts a new evaluation task based on provided parameters
|
||||
// Parameters:
|
||||
// - ctx: Context, used for passing request context information such as deadline, cancellation signals, etc.
|
||||
// - request: Evaluation request parameters, including dataset ID and model IDs
|
||||
//
|
||||
// Returns:
|
||||
// - *EvaluationTask: Created evaluation task information
|
||||
// - error: Error information if the request fails
|
||||
func (c *Client) StartEvaluation(ctx context.Context, request *EvaluationRequest) (*EvaluationTask, error) {
|
||||
resp, err := c.doRequest(ctx, http.MethodPost, "/api/v1/evaluation", request, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var response EvaluationTaskResponse
|
||||
if err := parseResponse(resp, &response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &response.Data, nil
|
||||
}
|
||||
|
||||
// GetEvaluationResult retrieves evaluation results
|
||||
// Retrieves detailed results for an evaluation task by task ID
|
||||
// Parameters:
|
||||
// - ctx: Context, used for passing request context information
|
||||
// - taskID: Evaluation task ID, used to identify the specific evaluation task to query
|
||||
//
|
||||
// Returns:
|
||||
// - *EvaluationResult: Detailed evaluation task results
|
||||
// - error: Error information if the request fails
|
||||
func (c *Client) GetEvaluationResult(ctx context.Context, taskID string) (*EvaluationResult, error) {
|
||||
queryParams := url.Values{}
|
||||
queryParams.Add("task_id", taskID)
|
||||
|
||||
resp, err := c.doRequest(ctx, http.MethodGet, "/api/v1/evaluation", nil, queryParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var response EvaluationResultResponse
|
||||
if err := parseResponse(resp, &response); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &response.Data, nil
|
||||
}
|
||||
Reference in New Issue
Block a user