Skip to content

Commit

Permalink
Merge pull request #397 from 0xff-dev/prompt-output
Browse files Browse the repository at this point in the history
chore: support for selecting llm with different namespace
  • Loading branch information
bjwswang authored Jan 17, 2024
2 parents 1ea3af8 + 5743cb9 commit 2426d25
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 27 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/example_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

env:
LOG_DIR: "/tmp/kubebb-core-example-test/logs"
GO_VER: "1.21.6"

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
Expand All @@ -34,6 +35,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: |
make docker-build
- name: Save operator image to /tmp
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -77,6 +79,10 @@ jobs:
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin
cp /usr/local/bin/kustomize ${GITHUB_WORKSPACE}/bin/kustomize
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Rating test
run: config/samples/rating_test.sh
env:
Expand Down Expand Up @@ -113,6 +119,9 @@ jobs:
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin
cp /usr/local/bin/kustomize ${GITHUB_WORKSPACE}/bin/kustomize
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Example test
run: config/samples/example-test.sh
- name: Upload logs if test fail
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/image_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
env:
GO_VER: 1.20
GO_VER: "1.21.6"
GO_TAGS: ""

jobs:
Expand Down Expand Up @@ -60,4 +60,4 @@ jobs:
GO_VER=${{ env.GO_VER }}
GO_TAGS=${{ env.GO_TAGS }}
BUILD_ID=${{ env.SEMREV_LABEL }}
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_DATE=${{ env.BUILD_DATE }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
tags:
- 'v*'
env:
GO_VER: 1.20
GO_VER: 1.21
GO_TAGS: ""
permissions:
contents: write
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: verify test
run: hack/verify-all.sh
run: hack/verify-all.sh
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.20 as builder
ARG GO_VER=1.21.6
FROM golang:${GO_VER} as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ deploy-lowcode: kustomize
$(KUSTOMIZE) build pipeline/lowcode | kubectl apply -f -
rerun:
kubectl delete -f pipeline/lowcode/sample/publish.yaml
kubectl apply -f pipeline/lowcode/sample/publish.yaml
kubectl apply -f pipeline/lowcode/sample/publish.yaml
3 changes: 1 addition & 2 deletions api/v1alpha1/rating_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package v1alpha1

import (
arcadiav1 "github.com/kubeagi/arcadia/api/base/v1alpha1"
arcadiallms "github.com/kubeagi/arcadia/pkg/llms"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -87,7 +86,7 @@ type RatingSpec struct {

type Evaluator struct {
// LLM defines the LLM to be used when evaluating the component
LLM arcadiallms.LLMType `json:"llm,omitempty"`
LLM *arcadiav1.TypedObjectReference `json:"llm,omitempty"`
}

type RatingStatus struct {
Expand Down
8 changes: 7 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion config/crd/bases/core.kubebb.k8s.com.cn_ratings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,27 @@ spec:
llm:
description: LLM defines the LLM to be used when evaluating the
component
type: string
properties:
apiGroup:
description: APIGroup is the group for the resource being
referenced. If APIGroup is not specified, the specified
Kind must be in the core API group. For any other third-party
types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
namespace:
description: Namespace is the namespace of resource being
referenced
type: string
required:
- kind
- name
type: object
type: object
pipelineParams:
description: PipelineParams List of parameters defined in the pipeline
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
resources:
limits:
cpu: 5000m
memory: 1536Mi
memory: 2048Mi
requests:
cpu: 10m
memory: 64Mi
Expand Down
5 changes: 4 additions & 1 deletion config/samples/core_v1alpha1_rating_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ metadata:
namespace: kubebb-system
spec:
evaluator:
llm: zhipuai
llm:
kind: LLM
name: zhipuai
namespace: kubebb-system
componentName: repository-kubebb.kubebb-core
pipelineParams:
- pipelineName: component-reliability
Expand Down
5 changes: 4 additions & 1 deletion config/samples/core_v1alpha1_rating_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ metadata:
namespace: kubebb-system
spec:
evaluator:
llm: zhipuai
llm:
kind: LLM
name: zhipuai
namespace: kubebb-system
componentName: repository-kubebb.kubebb-core
pipelineParams:
- pipelineName: component-reliability
Expand Down
5 changes: 4 additions & 1 deletion config/samples/core_v1alpha1_rating_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ metadata:
namespace: kubebb-system
spec:
evaluator:
llm: zhipuai
llm:
kind: LLM
name: zhipuai
namespace: kubebb-system
componentName: repository-kubebb-disablerating.kubebb-core
pipelineParams:
- pipelineName: component-reliability
Expand Down
6 changes: 4 additions & 2 deletions controllers/rating_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ func (r *RatingReconciler) PipelineRunUpdate(logger logr.Logger) func(event.Upda
}

// When pipelinerun succeeded and llm is set,evaluate this Rating status
if curCond.Reason == string(corev1alpha1.RatingSucceeded) && rating.Spec.LLM != "" {
arcEval, err := evaluator.NewEvaluator(logger, context.TODO(), r.Client, r.Scheme, types.NamespacedName{Namespace: rating.Namespace, Name: string(rating.Spec.Evaluator.LLM)})
if curCond.Reason == string(corev1alpha1.RatingSucceeded) && rating.Spec.LLM != nil {
llmNamespace := rating.Spec.LLM.GetNamespace(rating.Namespace)
arcEval, err := evaluator.NewEvaluator(logger, context.TODO(), r.Client, r.Scheme,
types.NamespacedName{Namespace: llmNamespace, Name: rating.Spec.LLM.Name})
if err != nil {
logger.Error(err, "failed to create arcadia evaluator")
} else {
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/kubebb/core

go 1.20
go 1.21

toolchain go1.21.5

require (
github.com/Masterminds/semver/v3 v3.2.0
Expand Down Expand Up @@ -32,7 +34,7 @@ require (
require (
github.com/goharbor/go-client v0.26.2
github.com/google/go-github/v54 v54.0.1-0.20230830144129-e3cda7864bce
github.com/kubeagi/arcadia v0.1.0
github.com/kubeagi/arcadia v0.1.1-0.20240109075426-459dcdee8128
github.com/spf13/cobra v1.6.1
github.com/tektoncd/pipeline v0.40.2
golang.org/x/oauth2 v0.13.0
Expand Down Expand Up @@ -62,7 +64,7 @@ require (
github.com/Masterminds/squirrel v1.5.3 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
github.com/amikos-tech/chroma-go v0.0.0-20230901221218-d0087270239e // indirect
github.com/amikos-tech/chroma-go v0.0.0-20231228181736-e8f5e927093e // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
Expand Down Expand Up @@ -193,7 +195,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmc/langchaingo v0.0.0-20231209214832-00f364f27fe2 // indirect
github.com/tmc/langchaingo v0.1.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
Expand Down
Loading

0 comments on commit 2426d25

Please sign in to comment.