Skip to content

Commit

Permalink
feat: add prompt controller
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Aug 21, 2023
1 parent bf13985 commit 48b9ae7
Show file tree
Hide file tree
Showing 19 changed files with 550 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:allowDangerousTypes=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,56 @@ The idea of `Arcadia` comes from the chat with `ClaudeAI`.See[POE Chat](https://

Our vision is to realize the ideal paradise for all through AI. To achieve a perfect fusion of technology and ideal life.We hope that through our work, we can take steps towards this grander goal of harnessing AI for the good of all.

## Quick start

### 1. Install arcadia

```shell
helm repo add arcadia https://kubeagi.github.io/arcadia
helm repo update
helm install arcadia arcadia/arcadia
```

### 2. Add a LLM

> Take [ZhiPuAI] as an example.
1. Prepare auth info

Update apiKey in [zhipuai's secret](https://github.com/kubeagi/arcadia/blob/main/config/samples/core_v1alpha1_arcadia_llm.yaml).

> On how to get apiKey, please refer to [ZhiPuAI](https://open.bigmodel.cn/dev/api#auth)
2. Create a LLM along with the auth secret

```shell
kubectl apply -f config/samples/arcadia_v1alpha1_llm.yaml
```

### 3. Create a prompt

```shell
kubectl apply -f config/samples/arcadia_v1alpha1_prompt.yaml
```

After prompt got created, you can see the prompt in the following command:

```shell
kubectl get prompt prompt-zhipuai-sample -oyaml
```

If no error found,you can use this command to get the prompt response data.

```shell
kubectl get prompt prompt-zhipuai-sample --output="jsonpath={.status.data}" | base64 --decode
```

Output:

```shell
{"code":200,"data":{"choices":[{"content":"\" Kubernetes (also known as K8s) is an open-source container orchestration system for automating the deployment, scaling, and management of containerized applications. It was originally designed by Google, and is now maintained by the Cloud Native Computing Foundation (CNCF).\\n\\nKubernetes provides a platform-as-a-service (PaaS) model, which allows developers to deploy, run, and scale containerized applications with minimal configuration and effort. It does this by abstracting the underlying infrastructure and providing a common set of APIs and tools that can be used to deploy, manage, and scale applications consistently across different environments.\\n\\nKubernetes is widely adopted by organizations of all sizes and has a large, active community of developers contributing to its continued development and improvement. It is available on a variety of platforms, including Linux, Windows, and 移动设备,and can be deployed on-premises, in the cloud, or in a hybrid environment.\"","role":"assistant"}],"request_id":"7865480399259975113","task_id":"7865480399259975113","task_status":"SUCCESS","usage":{"total_tokens":203}},"msg":"操作成功","success":true}
```

## Why in Kubernetes?

Kubernetes provides an ideal platform for building the intelligent systems required to realize our vision of an AI-powered utopia. Some of the key reasons are:
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
TypeReady ConditionType = "Ready"
// TypeUnknown resources are unknown to the system
TypeUnknown ConditionType = "Unknown"
// TypeDone resources are believed to be processed
TypeDone ConditionType = "Done"
)

// A ConditionReason represents the reason a resource is in a condition.
Expand Down
35 changes: 0 additions & 35 deletions api/v1alpha1/llm.go

This file was deleted.

6 changes: 1 addition & 5 deletions api/v1alpha1/llm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ type LLMSpec struct {
// Type defines the type of llm
Type llms.LLMType `json:"type"`
// URL keeps the URL of the llm service(Must required)
URL string `json:"url"`
URL string `json:"url,omitempty"`
// Auth keeps the authentication credentials when access llm
// keeps in k8s secret
Auth string `json:"auth,omitempty"`
}

type AuthInfo struct {
APIKey string `json:"apiKey,omitempty"`
}

// LLMStatus defines the observed state of LLM
type LLMStatus struct {
// ConditionedStatus is the current status
Expand Down
7 changes: 5 additions & 2 deletions api/v1alpha1/prompt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ type PromptSpec struct {

// PromptStatus defines the observed state of Prompt
type PromptStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// ConditionedStatus is the current status
ConditionedStatus `json:",inline"`

// Data retrieved after LLM Call
Data []byte `json:"data"`
}

//+kubebuilder:object:root=true
Expand Down
23 changes: 7 additions & 16 deletions api/v1alpha1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_llms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ spec:
type: string
required:
- type
- url
type: object
status:
description: LLMStatus defines the observed state of LLM
Expand Down
87 changes: 84 additions & 3 deletions charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_prompts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,94 @@ spec:
spec:
description: PromptSpec defines the desired state of Prompt
properties:
foo:
description: Foo is an example field of Prompt. Edit prompt_types.go
to remove/update
llm:
description: LLM serivice name(CRD LLM)
type: string
zhiPuAIParams:
description: ZhiPuAIParams defines the params of ZhiPuAI
properties:
incremental:
description: Incremental is only Used for SSE Invoke
type: boolean
method:
description: Method used for this prompt call
type: string
model:
description: Model used for this prompt call
type: string
prompt:
description: Contents
items:
description: Prompt defines the content of ZhiPuAI Prompt Call
properties:
content:
type: string
role:
type: string
type: object
type: array
task_id:
description: TaskID is used for getting result of AsyncInvoke
type: string
temperature:
description: Temperature is float in zhipuai
type: number
top_p:
description: TopP is float in zhipuai
type: number
required:
- prompt
type: object
required:
- llm
type: object
status:
description: PromptStatus defines the observed state of Prompt
properties:
conditions:
description: Conditions of the resource.
items:
description: A Condition that may apply to a resource.
properties:
lastSuccessfulTime:
description: LastSuccessfulTime is repository Last Successful
Update Time
format: date-time
type: string
lastTransitionTime:
description: LastTransitionTime is the last time this condition
transitioned from one status to another.
format: date-time
type: string
message:
description: A Message containing details about this condition's
last transition from one status to another, if any.
type: string
reason:
description: A Reason for this condition's last transition from
one status to another.
type: string
status:
description: Status of this condition; is it currently True,
False, or Unknown
type: string
type:
description: Type of this condition. At most one of each condition
type may apply to a resource at any point in time.
type: string
required:
- lastTransitionTime
- reason
- status
- type
type: object
type: array
data:
description: Data retrieved after LLM Call
format: byte
type: string
required:
- data
type: object
type: object
served: true
Expand Down
50 changes: 50 additions & 0 deletions config/arcadia.kubeagi.k8s.com.cn_laboratories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: laboratories.arcadia.kubeagi.k8s.com.cn
spec:
group: arcadia.kubeagi.k8s.com.cn
names:
kind: Laboratory
listKind: LaboratoryList
plural: laboratories
singular: laboratory
scope: Cluster
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: Laboratory is the Schema for the laboratories API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: LaboratorySpec defines the desired state of Laboratory
properties:
foo:
description: Foo is an example field of Laboratory. Edit laboratory_types.go
to remove/update
type: string
type: object
status:
description: LaboratoryStatus defines the observed state of Laboratory
type: object
type: object
served: true
storage: true
subresources:
status: {}
Loading

0 comments on commit 48b9ae7

Please sign in to comment.