Skip to content

Commit

Permalink
feat: add a new api to get rag evaluation report
Browse files Browse the repository at this point in the history
  • Loading branch information
0xff-dev committed Feb 19, 2024
1 parent 8fed481 commit dc10c00
Show file tree
Hide file tree
Showing 8 changed files with 1,133 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apiserver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import (
"flag"
"os"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"

"github.com/kubeagi/arcadia/api/base/v1alpha1"
evaluationarcadiav1alpha1 "github.com/kubeagi/arcadia/api/evaluation/v1alpha1"
"github.com/kubeagi/arcadia/apiserver/pkg/dataprocessing"
)

Expand All @@ -39,6 +45,8 @@ type ServerConfig struct {
IssuerURL, MasterURL, ClientID, ClientSecret string

DataProcessURL string

Scheme *runtime.Scheme
}

func NewServerFlags() ServerConfig {
Expand All @@ -58,6 +66,12 @@ func NewServerFlags() ServerConfig {
klog.InitFlags(nil)
flag.Parse()

s.Scheme = runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(s.Scheme))
utilruntime.Must(v1.AddToScheme(s.Scheme))
utilruntime.Must(evaluationarcadiav1alpha1.AddToScheme(s.Scheme))
utilruntime.Must(v1alpha1.AddToScheme(s.Scheme))

dataprocessing.Init(s.DataProcessURL)
return *s
}
Expand Down
264 changes: 264 additions & 0 deletions apiserver/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,158 @@ const docTemplate = `{
}
}
}
},
"/rags/detail": {
"get": {
"description": "Get detail data of a rag",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"RAG"
],
"summary": "Get detail data of a rag",
"parameters": [
{
"type": "string",
"description": "rag name",
"name": "ragName",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the bucket",
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "application name",
"name": "appName",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "default is 1",
"name": "page",
"in": "query"
},
{
"type": "string",
"description": "default is 10",
"name": "size",
"in": "query"
},
{
"type": "string",
"description": "rag metrcis",
"name": "sortBy",
"in": "query"
},
{
"type": "string",
"description": "desc or asc",
"name": "order",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/rag.ReportDetail"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/rags/report": {
"get": {
"description": "Get a summary of rag",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"RAG"
],
"summary": "Get a summary of rag",
"parameters": [
{
"type": "string",
"description": "rag name",
"name": "ragName",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the bucket",
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "application name",
"name": "appName",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/rag.Report"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -1392,6 +1544,118 @@ const docTemplate = `{
}
}
},
"rag.RadarData": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "number"
}
}
},
"rag.Report": {
"type": "object",
"properties": {
"radarChart": {
"type": "array",
"items": {
"$ref": "#/definitions/rag.RadarData"
}
},
"scatterChart": {
"type": "array",
"items": {
"$ref": "#/definitions/rag.ScatterData"
}
},
"summary": {
"description": "TODO",
"type": "string"
},
"totalScore": {
"$ref": "#/definitions/rag.TotalScoreData"
}
}
},
"rag.ReportDetail": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/rag.ReportLine"
}
},
"total": {
"type": "integer"
}
}
},
"rag.ReportLine": {
"type": "object",
"properties": {
"answer": {
"type": "string"
},
"contexts": {
"type": "array",
"items": {
"type": "string"
}
},
"costTime": {
"type": "number"
},
"data": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"groundTruths": {
"type": "array",
"items": {
"type": "string"
}
},
"question": {
"type": "string"
},
"totalScore": {
"type": "number"
}
}
},
"rag.ScatterData": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"score": {
"type": "number"
},
"type": {
"type": "string"
}
}
},
"rag.TotalScoreData": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"score": {
"type": "number"
}
}
},
"retriever.Reference": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit dc10c00

Please sign in to comment.