feat: Support for Chat Flow & Agent Support for binding a single chat flow (#765)
Co-authored-by: Yu Yang <72337138+tomasyu985@users.noreply.github.com> Co-authored-by: zengxiaohui <csu.zengxiaohui@gmail.com> Co-authored-by: lijunwen.gigoo <lijunwen.gigoo@bytedance.com> Co-authored-by: lvxinyu.1117 <lvxinyu.1117@bytedance.com> Co-authored-by: liuyunchao.0510 <liuyunchao.0510@bytedance.com> Co-authored-by: haozhenfei <37089575+haozhenfei@users.noreply.github.com> Co-authored-by: July <jiangxujin@bytedance.com> Co-authored-by: tecvan-fe <fanwenjie.fe@bytedance.com>
This commit is contained in:
@@ -32,6 +32,7 @@ type CreateApiKey struct {
|
||||
Name string `json:"name"`
|
||||
Expire int64 `json:"expire"`
|
||||
UserID int64 `json:"user_id"`
|
||||
AkType AkType `json:"ak_type"`
|
||||
}
|
||||
|
||||
type DeleteApiKey struct {
|
||||
|
||||
24
backend/domain/openauth/openapiauth/entity/consts.go
Normal file
24
backend/domain/openauth/openapiauth/entity/consts.go
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package entity
|
||||
|
||||
type AkType int32
|
||||
|
||||
const (
|
||||
AkTypeCustomer AkType = 0
|
||||
AkTypeTemporary AkType = 1
|
||||
)
|
||||
@@ -72,6 +72,7 @@ func (a *ApiKeyDAO) doToPo(ctx context.Context, do *entity.CreateApiKey) (*model
|
||||
Name: do.Name,
|
||||
ExpiredAt: do.Expire,
|
||||
UserID: do.UserID,
|
||||
AkType: int32(do.AkType),
|
||||
CreatedAt: time.Now().Unix(),
|
||||
}
|
||||
return po, nil
|
||||
@@ -119,7 +120,7 @@ func (a *ApiKeyDAO) FindByKey(ctx context.Context, key string) (*model.APIKey, e
|
||||
|
||||
func (a *ApiKeyDAO) List(ctx context.Context, userID int64, limit int, page int) ([]*model.APIKey, bool, error) {
|
||||
do := a.dbQuery.APIKey.WithContext(ctx).Where(a.dbQuery.APIKey.UserID.Eq(userID))
|
||||
|
||||
do = do.Where(a.dbQuery.APIKey.AkType.Eq(int32(entity.AkTypeCustomer)))
|
||||
do = do.Offset((page - 1) * limit).Limit(limit + 1)
|
||||
|
||||
list, err := do.Order(a.dbQuery.APIKey.CreatedAt.Desc()).Find()
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
@@ -17,6 +33,7 @@ type APIKey struct {
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
LastUsedAt int64 `gorm:"column:last_used_at;not null;comment:Used Time in Milliseconds" json:"last_used_at"` // Used Time in Milliseconds
|
||||
AkType int32 `gorm:"column:ak_type;not null;comment:api key type" json:"ak_type"` // api key type
|
||||
}
|
||||
|
||||
// TableName APIKey's table name
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
@@ -36,6 +52,7 @@ func newAPIKey(db *gorm.DB, opts ...gen.DOOption) aPIKey {
|
||||
_aPIKey.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_aPIKey.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
||||
_aPIKey.LastUsedAt = field.NewInt64(tableName, "last_used_at")
|
||||
_aPIKey.AkType = field.NewInt32(tableName, "ak_type")
|
||||
|
||||
_aPIKey.fillFieldMap()
|
||||
|
||||
@@ -56,6 +73,7 @@ type aPIKey struct {
|
||||
CreatedAt field.Int64 // Create Time in Milliseconds
|
||||
UpdatedAt field.Int64 // Update Time in Milliseconds
|
||||
LastUsedAt field.Int64 // Used Time in Milliseconds
|
||||
AkType field.Int32 // api key type
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -81,6 +99,7 @@ func (a *aPIKey) updateTableName(table string) *aPIKey {
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
a.UpdatedAt = field.NewInt64(table, "updated_at")
|
||||
a.LastUsedAt = field.NewInt64(table, "last_used_at")
|
||||
a.AkType = field.NewInt32(table, "ak_type")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
@@ -97,7 +116,7 @@ func (a *aPIKey) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (a *aPIKey) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 9)
|
||||
a.fieldMap = make(map[string]field.Expr, 10)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["api_key"] = a.APIKey
|
||||
a.fieldMap["name"] = a.Name
|
||||
@@ -107,6 +126,7 @@ func (a *aPIKey) fillFieldMap() {
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["last_used_at"] = a.LastUsedAt
|
||||
a.fieldMap["ak_type"] = a.AkType
|
||||
}
|
||||
|
||||
func (a aPIKey) clone(db *gorm.DB) aPIKey {
|
||||
|
||||
Reference in New Issue
Block a user