Skip to content

Commit

Permalink
Merge branch 'labring:main' into aio
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie authored Aug 10, 2023
2 parents e1e3906 + a62daa6 commit fbc43a1
Show file tree
Hide file tree
Showing 195 changed files with 6,928 additions and 9,441 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
matrix:
module:
[
providers/template,
providers/adminer,
providers/applaunchpad,
providers/bytebase,
Expand Down Expand Up @@ -127,6 +128,7 @@ jobs:
matrix:
module:
[
providers/template,
providers/adminer,
providers/applaunchpad,
providers/bytebase,
Expand Down
22 changes: 14 additions & 8 deletions controllers/account/controllers/account_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,22 @@ func (r *AccountReconciler) DeletePayment(ctx context.Context) error {
r.Logger.Error(err, "get payment handler failed")
return err
}
//expire session if it is necessary
err = payHandler.ExpireSession(payment.Status.TradeNO)
if err != nil {
r.Logger.Error(err, "cancel payment failed")
return err
}
//delete payment if it is exist for more than 5 minutes
if time.Since(payment.CreationTimestamp.Time) > time.Minute*5 {
err := r.Delete(ctx, &payment)
if err != nil {
if payment.Status.TradeNO != "" {
status, amount, err := payHandler.GetPaymentDetails(payment.Status.TradeNO)
if err != nil {
r.Logger.Error(err, "get payment details failed")
}
if status == pay.StatusSuccess {
r.Logger.Info("payment success, post delete payment cr", "payment", payment, "amount", amount)
}
// expire session
if err = payHandler.ExpireSession(payment.Status.TradeNO); err != nil {
r.Logger.Error(err, "cancel payment failed")
}
}
if err := r.Delete(ctx, &payment); err != nil {
return err
}
}
Expand Down
2 changes: 2 additions & 0 deletions controllers/account/controllers/debt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func newStatusConversion(debt *accountv1.Debt) bool {
debt.Status.AccountDebtStatus = accountv1.ImminentDeletionPeriod
case accountv1.RemovedPeriod:
debt.Status.AccountDebtStatus = accountv1.FinalDeletionPeriod
default:
debt.Status.AccountDebtStatus = accountv1.NormalPeriod
}
return true
}
Expand Down
5 changes: 1 addition & 4 deletions controllers/account/controllers/payment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package controllers

import (
"context"
"os"
"time"

"github.com/labring/sealos/pkg/pay"
Expand All @@ -29,8 +28,6 @@ import (
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"

"github.com/mdp/qrterminal"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -97,7 +94,7 @@ func (r *PaymentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
return ctrl.Result{}, err
}

qrterminal.Generate(codeURL, qrterminal.L, os.Stdout)
//qrterminal.Generate(codeURL, qrterminal.L, os.Stdout)
return ctrl.Result{}, nil
}

Expand Down
2 changes: 2 additions & 0 deletions controllers/account/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY registry registry
COPY manifests manifests

ENV DEFAULT_NAMESPACE account-system
ENV cloudDomain="cloud.sealos.io"
ENV port=""
ENV MONGO_URI "mongodb://mongo:27017/resources"

CMD ["( kubectl create ns $DEFAULT_NAMESPACE || true ) && ( kubectl create -f manifests/mongo-secret.yaml -n $DEFAULT_NAMESPACE || true ) && kubectl apply -f manifests/deploy.yaml -n $DEFAULT_NAMESPACE"]
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,10 @@ spec:
command:
- /manager
env:
- name: DOMAIN
value: {{ .cloudDomain }}
- name: PORT
value: {{ .port }}
- name: ACCOUNT_NAMESPACE
value: sealos-system
- name: NAMESPACE_NAME
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 7 additions & 125 deletions docs/4.0/docs/examples/ai-applications/install-fastgpt-on-desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,134 +4,16 @@ sidebar_position: 1

# Quick Installation of FastGpt AI Knowledge Base

FastGpt is recommended to deploy with Docker on Git, so it is also easy to deploy on Sealos conveniently. FastGpt relies on MongoDB and PostgreSQL. The following tutorial only describes how to deploy these two databases and the FastGpt image on Sealos. The environment variables and usage instructions of FastGpt will not be explained in details. For details, please refer to [FastGpt Git](https://github.com/c121914yu/FastGPT).
No server, no magic, no domain name, click to deploy 👇

## 1. Create Two Databases
[![](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg)](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dfastgpt)

Sealos provides a **database** tool that allows for visual deployment of databases.
The database needs to be deployed. After the deployment, you need to wait 2 to 4 minutes to access the database. The minimum configuration is used by default, and the first access is a little slow.

### 1.1 Open the Database App in the [Sealos](https://cloud.sealos.io) desktop environment
![](./imgs/sealos1.png)

![1. 打开 **数据库**](./images/open-dbprovider.png)
## Run

### 1.2 Create MongoDB database
Click on the [external address] provided by sealos to use it. The login user name is root, and the password is the newly set environment variable (1234 in the figure above)

![](./images/fast1.png)

Choose from three types of databases, and create a MongoDB first. It is recommended to choose a specification of 0.5C 512Mi or higher.

![](./images/fast2.png)

### 1.3 Create PostgreSQL database

![](./images/fast3.png)

Due to the need to store vector data in PostgreSQL, the required capacity is relatively large, and the initial capacity can be set to a larger size.

![](./images/fast4.png)

### 1.4 Check database connection parameters

Click the database details and check the connection parameters of each database, including host, port, username, password and connectionUrl.

![](./images/fast5.png)
![](./images/fast6.png)

## 2. Initialize PostgreSQL Database

### 2.1 Connect to PostgreSQL database

Connect to the database with one click in the PostgreSQL database details.

![](./images/fast7.png)

### 2.2 Execute init.sql

Copy and paste the following SQL into Terminal for execution. Paste using ctrl+shift+v. If there is an error with one-time paste, each SQL statement can be executed separately.

```sql
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS modelData (
id BIGSERIAL PRIMARY KEY,
vector VECTOR(1536) NOT NULL,
user_id VARCHAR(50) NOT NULL,
kb_id VARCHAR(50) NOT NULL,
source VARCHAR(100),
q TEXT NOT NULL,
a TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS modelData_userId_index ON modelData USING HASH (user_id);
CREATE INDEX IF NOT EXISTS modelData_kbId_index ON modelData USING HASH (kb_id);
CREATE INDEX IF NOT EXISTS idx_model_data_md5_q_a_user_id_kb_id ON modelData (md5(q), md5(a), user_id, kb_id);
CREATE INDEX IF NOT EXISTS vector_index ON modeldata USING ivfflat (vector vector_ip_ops) WITH (lists = 100);
SET ivfflat.probes = 10;
```

![](./images/fast8.png)

### 2.3 Verify initialization

Execute `\d modeldata` to check the details of the table to see if it is as expected.

![](./images/fast19.png)

## 3. Deploy FastGpt

Sealos provides **App Launchpad** that can quickly deploy single image services.

### 3.1 Open App Launchpad from Desktop

![](./images/fast9.png)

### 3.2 Click Create Application

![](./images/fast10.png)

### 3.3 Fill in the relevant parameters

![](./images/fast11.png)
![](./images/fast12.png)

| variable names | description |
| :----------------------- | ------------------------------------------------------------ |
| Application Name | such as: fastgpt |
| Image Name | Official image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest |
| CPU and Memory | Depends on user's demand |
| container exposed port | 3000 |
| Accessible to the Public | Open「Accessible to the Public」and the domain name is automatically assigned and can be used directly or customized. |
| Environment | Refer to [FastGpt docker-compose.yaml](https://github.com/c121914yu/FastGPT/blob/main/docs/deploy/fastgpt/docker-compose.yml) For some variables in the database, directly copy the content in [1.4]. |

The following is an environment variable without annotations, which can be directly copied, modified, and used.

```
QA_MAX_PROCESS=20
VECTOR_MAX_PROCESS=20
[email protected]
MAILE_CODE=mailcode
aliAccessKeyId=keyid
aliAccessKeySecret=secret
aliSignName=signname
aliTemplateCode=SMS_111
TOKEN_KEY=tokenkey
ROOT_KEY=rootkey
SENSITIVE_CHECK=1
MONGODB_URI=mongodb://root:[email protected]:27017
MONGODB_NAME=fastgpt
PG_USER=postgres
PG_PASSWORD=m8tkt57w
PG_HOST=fastgpt-pg-postgresql.ns-hti44k5d.svc
PG_PORT=5432
PG_DB_NAME=postgres
OPENAIKEY=sk-xxx
OPENAI_TRAINING_KEY=sk-xxx
GPT4KEY=sk-xxx
```

![](./images/fast15.png)

### 3.3 Access FastGpt

Access FastGpt through the external address or custom domain name provided by **App Launchpad**.

![](./images/fast17.png)
![](./images/fast18.png)
![](./imgs/sealos2.png)
4 changes: 2 additions & 2 deletions docs/4.0/docs/lifecycle-management/lifecycle-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Sealos offers features like cluster scaling, backup and recovery, and cluster re
Running a Kubernetes cluster with Sealos is straightforward. Just follow these steps:

```bash
$ curl -sfL https://raw.githubusercontent.com/labring/sealos/v4.2.0/scripts/install.sh \
| sh -s v4.2.0 labring/sealos
$ curl -sfL https://raw.githubusercontent.com/labring/sealos/v4.3.0/scripts/install.sh \
| sh -s v4.3.0 labring/sealos
# Create a cluster
$ sealos run labring/kubernetes:v1.25.0-4.2.0 labring/helm:v3.8.2 labring/calico:v3.24.1 \
--masters 192.168.64.2,192.168.64.22,192.168.64.20 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ spec:
- amd64
image:
- labring/kubernetes:v1.24.0
- labring/helm:v3.8.2
- labring/calico:v3.24.1
ssh:
passwd: xxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/latest | g

```bash
curl -sfL https://raw.githubusercontent.com/labring/sealos/${VERSION}/scripts/install.sh |
sh - ${VERSION} labring/sealos
sh -s ${VERSION} labring/sealos

```

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading

0 comments on commit fbc43a1

Please sign in to comment.