This commit is contained in:
2023-05-27 08:21:38 +08:00
parent 6f105e7f14
commit a5635f3540

243
README.md
View File

@@ -2,6 +2,17 @@
用戶: 用戶:
```go
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
```
- [x] GET [/api/users](/api/users) 用戶列表 - [x] GET [/api/users](/api/users) 用戶列表
- [x] POST [/api/users](/api/users) 創建用戶 - [x] POST [/api/users](/api/users) 創建用戶
- [x] GET [/api/users](/api/users) 查詢指定用戶 - [x] GET [/api/users](/api/users) 查詢指定用戶
@@ -9,9 +20,15 @@
- [x] DELETE [/api/users/{id}](/api/users/{id}) 刪除指定用戶 - [x] DELETE [/api/users/{id}](/api/users/{id}) 刪除指定用戶
會話: 會話:
```go
type Session struct {
Email string `json:"email"`
Password string `json:"password"`
}
```
- [x] GET [/api/sessions](/api/sessions) 會話列表 - [x] GET [/api/sessions](/api/sessions) 會話列表
- [x] POST [/api/sessions](/api/sessions) 登錄賬戶(創建會話) - [x] POST [/api/sessions](/api/sessions) 登錄賬戶(創建會話)
- [x] GET [/api/sessions/{id}](/api/sessions/{id}) 查詢會話詳情 - [x] GET [/api/sessions/{id}](/api/sessions/{id}) 查詢會話詳情
@@ -21,6 +38,12 @@
數據集: 數據集:
```go
type Dataset struct {
Images []string `json:"images"`
}
```
- [x] GET [/api/datasets](/api/datasets) 數據集列表 - [x] GET [/api/datasets](/api/datasets) 數據集列表
- [x] POST [/api/datasets](/api/datasets) 創建數據集 - [x] POST [/api/datasets](/api/datasets) 創建數據集
- [x] GET [/api/datasets/{id}](/api/datasets/{id}) 查詢指定數據集 - [x] GET [/api/datasets/{id}](/api/datasets/{id}) 查詢指定數據集
@@ -30,6 +53,15 @@
標籤: 標籤:
```go
type Tag struct {
ID int `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
```
- [x] GET [/api/tags](/api/tags) 標籤列表(全部) - [x] GET [/api/tags](/api/tags) 標籤列表(全部)
- [x] POST [/api/tags](/api/tags) 創建標籤 - [x] POST [/api/tags](/api/tags) 創建標籤
- [x] GET [/api/tags/{id}](/api/tags/{id}) 標籤詳情 - [x] GET [/api/tags/{id}](/api/tags/{id}) 標籤詳情
@@ -39,6 +71,24 @@
模型: 模型:
```go
type Model struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // (lora|ckp|hyper|ti)
TriggerWords string `json:"trigger_words"` // 觸發詞
BaseModel string `json:"base_model"` // (SD1.5|SD2)
ModelPath string `json:"model_path"` // 模型路徑
Status string `json:"status"` // (initial|ready|waiting|running|success|error)
Progress int `json:"progress"` // (0-100)
Image string `json:"image"` // 封面圖片實際地址
Tags string `json:"tags"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
```
- [x] GET [/api/models](/api/models) 模型列表(全部) - [x] GET [/api/models](/api/models) 模型列表(全部)
- [x] GET [/api/models?user_id=xxx](/api/models?user_id=xxx) 模型列表(指定用戶的) - [x] GET [/api/models?user_id=xxx](/api/models?user_id=xxx) 模型列表(指定用戶的)
- [x] GET [/api/models?tag=動物](/api/models?tag=xxx) 模型列表(指定標籤的) - [x] GET [/api/models?tag=動物](/api/models?tag=xxx) 模型列表(指定標籤的)
@@ -51,6 +101,25 @@
圖像: 圖像:
```go
type Image struct {
ID int `json:"id"`
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Prompt string `json:"prompt"` // 描述詞
NegativePrompt string `json:"negative_prompt"` // 排除描述詞
NumInferenceSteps int `json:"num_inference_steps"` // (1~500)
GuidanceScale float32 `json:"guidance_scale"` // (1~20)
Scheduler string `json:"scheduler"` // (DDIM|K_EULER|DPMSolverMultistep|K_EULER_ANCESTRAL|PNDM|KLMS)
Seed int `json:"seed"` // 隨機數種子
FromImage string `json:"from_image"` // 圖片地址(以圖繪圖)
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
```
- [x] GET [/api/images](/api/images) 圖片列表(全部) - [x] GET [/api/images](/api/images) 圖片列表(全部)
- [x] GET [/api/images?user_id=xxx](/api/images?user_id=xxx) 圖片列表(指定用戶的) - [x] GET [/api/images?user_id=xxx](/api/images?user_id=xxx) 圖片列表(指定用戶的)
- [x] GET [/api/images?tag=xxx](/api/images?tag=xxx) 圖片列表(指定標籤的) - [x] GET [/api/images?tag=xxx](/api/images?tag=xxx) 圖片列表(指定標籤的)
@@ -58,12 +127,31 @@
任務: 任務:
```go
type Task struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // 任務類型(訓練|推理)
Status string `json:"status"` // 任務狀態(initial|ready|waiting|running|success|error)
Progress int `json:"progress"` // 任務進度(0-100)
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
```
- [x] GET [/api/tasks](/api/tasks) 任務列表(全部任務) - [x] GET [/api/tasks](/api/tasks) 任務列表(全部任務)
- [x] POST [/api/tasks](/api/tasks) 創建任務 - [x] POST [/api/tasks](/api/tasks) 創建任務
參數: 參數:
```go
type Param struct {
// 字段不固定
}
```
- [x] GET [/api/params](/api/params) 參數列表(全部參數) - [x] GET [/api/params](/api/params) 參數列表(全部參數)
- [x] GET [/api/params/model](/api/params/model) 模型參數 - [x] GET [/api/params/model](/api/params/model) 模型參數
@@ -71,15 +159,40 @@
賬戶: 賬戶:
```go
type Account struct {
// 同 user
}
```
- [x] GET [/api/account](/api/account) 當前賬戶信息 - [x] GET [/api/account](/api/account) 當前賬戶信息
- [x] GET [/api/account](/api/account) 當前賬戶信息 - [x] GET [/api/account](/api/account) 當前賬戶信息
服務器: 服務器:
```go
type Server struct {
IP string `json:"ip"`
}
```
- [x] GET [/api/servers](/api/servers) 服務器列表 - [x] GET [/api/servers](/api/servers) 服務器列表
列表模型:
```go
type ListView struct {
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 分頁大小
Total int `json:"total"` // 數據總量
Next bool `json:"next"` // 可否翻頁
List []interface{} `json:"list"` // 數據列表
}
```
----------------------------------------------------------- -----------------------------------------------------------
@@ -97,15 +210,6 @@ POST | /api/{name} | 篩選:創建新對象
* 選取條件有多個的,以逗號分隔(並集) * 選取條件有多個的,以逗號分隔(並集)
* 過濾條件有多個的,複寫query(交集) * 過濾條件有多個的,複寫query(交集)
詳情接口:
- [ ] /api/tags/{tag_id} [#標籤詳情](#標籤詳情)
- [ ] /api/users/{user_id} [#用戶詳情](#用戶詳情)
- [ ] /api/tasks/{task_id} [#任務詳情](#任務詳情)
- [ ] /api/models/{model_id} [#模型詳情](#模型詳情)
- [ ] /api/images/{image_id} [#圖片詳情](#圖片詳情)
- [ ] /api/params/{params_id} [#參數詳情](#參數詳情)
- [ ] /api/server/{server_id} [#服務詳情](#服務詳情)
詳情接口-請求方式: 詳情接口-請求方式:
@@ -124,125 +228,6 @@ WS | /api/{name}/{item_id} | Websocket 連接對象
----------------------------------------------------------- -----------------------------------------------------------
對象模型:
```go
type ListView struct {
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 分頁大小
Total int `json:"total"` // 數據總量
Next bool `json:"next"` // 可否翻頁
List []interface{} `json:"list"` // 數據列表
}
type Model struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // (lora|ckp|hyper|ti)
TriggerWords string `json:"trigger_words"` // 觸發詞
BaseModel string `json:"base_model"` // (SD1.5|SD2)
ModelPath string `json:"model_path"` // 模型路徑
Status string `json:"status"` // (initial|ready|waiting|running|success|error)
Progress int `json:"progress"` // (0-100)
Image string `json:"image"` // 封面圖片實際地址
Tags string `json:"tags"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
type Task struct {
ID int `json:"id"`
Name string `json:"name"`
Type string `json:"type"` // 任務類型(訓練|推理)
Status string `json:"status"` // 任務狀態(initial|ready|waiting|running|success|error)
Progress int `json:"progress"` // 任務進度(0-100)
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
type Image struct {
ID int `json:"id"`
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Prompt string `json:"prompt"` // 描述詞
NegativePrompt string `json:"negative_prompt"` // 排除描述詞
NumInferenceSteps int `json:"num_inference_steps"` // (1~500)
GuidanceScale float32 `json:"guidance_scale"` // (1~20)
Scheduler string `json:"scheduler"` // (DDIM|K_EULER|DPMSolverMultistep|K_EULER_ANCESTRAL|PNDM|KLMS)
Seed int `json:"seed"` // 隨機數種子
FromImage string `json:"from_image"` // 圖片地址(以圖繪圖)
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
UserID int `json:"user_id"`
}
type Tag struct {
ID int `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type Param struct {
// 字段不固定
}
```
```javascript
// ListView 列表分頁
{
page: 1,
pageSize: 20,
next: true,
list: []
}
// Image 圖片對象
{
id: 1234, // 原图ID
width: 512, // 原图宽度
height: 512, // 原图高度
createdAt: '', // 創建時間
updatedAt: '', // 更新時間
user: { // 来源用户
id: 1234,
user_name: 'LAST',
createdAt: '',
updatedAt: '',
},
article: { // 来源文章
id: 1234,
title: 'GAMEX',
}
}
// Task 任務對象
{
id: 'xxxxx', // 任務ID
name: 'xxx', // 任務名稱
status: 'xxx', // 任務狀態(waiting|running|success|error)
progress: 100, // 任務進度(0~100)
type: '', // 任務類型(train|Inference)
data: { // 任務數據
id: '', // 模型ID
... // 其它參數
},
createdAt: '', // 創建時間
updatedAt: '', // 更新時間
}
```
---------------------------------------------------------------
### 圖片列表 ### 圖片列表
GET /api/images GET /api/images