Skip to content

Commit

Permalink
feat: Implement a tutorial for beginners
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxie-crypto committed Nov 9, 2023
1 parent 7a8ecf1 commit d7f2a05
Show file tree
Hide file tree
Showing 266 changed files with 17,122 additions and 66,276 deletions.
92 changes: 46 additions & 46 deletions publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Name: agentcraft
Provider:
- 阿里云
Version: dev
Description: 快速构建agent 应用的中间层服务,兼容openai规范
Description: Serverless架构的LLMOps开发平台,快速交付知识库,Agent等LLM应用
HomePage: 项目首页地址
Tags: #标签详情
- 部署函数
Expand All @@ -17,14 +17,14 @@ Parameters:
# - REDIS_HOST # Redis地址
# - REDIS_PASSWORD #Redis密码
# - REDIS_USER #Redis用户名
- POSTGRES_HOST # Postgresql host
- POSTGRES_DATABASE # Postgresql 数据库
- POSTGRES_USER # Postgresql 用户名
- POSTGRES_PASSWORD # Postgresql 密码
# - POSTGRES_HOST # Postgresql host
# - POSTGRES_DATABASE # Postgresql 数据库
# - POSTGRES_USER # Postgresql 用户名
# - POSTGRES_PASSWORD # Postgresql 密码
- JWT_SECRET #后端服务的认证秘钥
- EMBEDDING_URL # embedding的访问地址
- EMBEDDING_TIMEOUT # embedding 服务访问超时时间
- EMBEDDING_DIM # embedding 向量维度
# - EMBEDDING_URL # embedding的访问地址
# - EMBEDDING_TIMEOUT # embedding 服务访问超时时间
# - EMBEDDING_DIM # embedding 向量维度
properties:
region:
title: 地域
Expand All @@ -34,12 +34,12 @@ Parameters:
enum:
- cn-beijing
- cn-hangzhou
- cn-shanghai
- cn-shenzhen
# - cn-shanghai
# - cn-shenzhen
serviceName:
title: 服务名
type: string
default: AgentCraftAll
default: FCAgentCraftAll
pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
description: 您可以根据需要设置不同的服务名,同一个服务会共享部分第三方云产品资源
# REDIS_HOST:
Expand All @@ -63,42 +63,42 @@ Parameters:
JWT_SECRET:
title: AgentCraft的JWT认证秘钥
type: string
default: ''
pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
description: AgentCraft访问API时作为JWT认证秘钥,可以随机设置
EMBEDDING_URL:
title: embedding服务地址
type: string
default:
pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
description: embedding服务地址,通过【开源Bert模型服务】https://fcnext.console.aliyun.com/applications/create?template=fc-embedding-api 应用模板获得
EMBEDDING_DIM:
title: 向量维度
type: int
default: 1024
description: 注意该维度跟模型算法以及数据库有关,创建后不可修改
POSTGRES_HOST:
title: postgresql 服务地址
type: string
default:
default: 'ag-${default-suffix}'
pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
description: postgresql 服务地址
POSTGRES_DATABASE:
title: postgresql 数据库名
type: string
default:
pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
description: postgresql 数据库名
POSTGRES_USER:
title: postgresql 用户名
type: string
default:
description: postgresql 用户名
POSTGRES_PASSWORD:
title: postgresql 数据密码
type: secret
default:
description: postgresql 数据库密码
description: AgentCraft访问API时作为JWT认证秘钥,可以随机设置,建议修改为自己的专属秘钥
# EMBEDDING_URL:
# title: embedding服务地址
# type: string
# default:
# pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
# description: embedding服务地址,通过【开源Bert模型服务】https://fcnext.console.aliyun.com/applications/create?template=fc-embedding-api 应用模板获得
# EMBEDDING_DIM:
# title: 向量维度
# type: int
# default: 1024
# description: 注意该维度跟模型算法以及数据库有关,创建后不可修改
# POSTGRES_HOST:
# title: postgresql 服务地址
# type: string
# default:
# pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
# description: postgresql 服务地址
# POSTGRES_DATABASE:
# title: postgresql 数据库名
# type: string
# default:
# pattern: "^[a-zA-Z_][a-zA-Z0-9-_:/.]{0,127}$"
# description: postgresql 数据库名
# POSTGRES_USER:
# title: postgresql 用户名
# type: string
# default:
# description: postgresql 用户名
# POSTGRES_PASSWORD:
# title: postgresql 数据密码
# type: secret
# default:
# description: postgresql 数据库密码
roleArn:
title: RAM 角色 ARN
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/agentcraft-all/agentcraft-be/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

CREATE_TABLES= #是否初始化表格,示例 0表示不初始化 1表示初始化
CREATE_TABLES=1 #是否初始化表格,示例 0表示不初始化 1表示初始化
EMBEDDING_URL= #embedding服务地址 示例 服务创建的地址https://fcnext.console.aliyun.com/applications/create?template=fc-embedding-api
EMBEDDING_DIM=1024 #embedding维度
EMBEDDING_TIMEOUT=600 #embedding服务调用超时时间
Expand Down
9 changes: 6 additions & 3 deletions src/agentcraft-all/agentcraft-be/app/apps/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ async def list_apps(page: int, limit: int, token: JWTData = Depends(validate_tok
}


@router.post('/add', response_model=BasicResponse)
@router.post('/add', response_model=DictResponse)
async def add_app(req: UpsertAppRequest, token: JWTData = Depends(validate_token)):
"""添加应用"""
service.add_app(user_id=token.user_id, **vars(req))
id = service.add_app(user_id=token.user_id, **vars(req))
return {
"code": 201,
"code": 200,
"msg": "success",
"data": {
"id": id
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/agentcraft-all/agentcraft-be/app/apps/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def list_apps(user_id: int, page: int, limit: int):

def add_app(**kwargs):
"""增加应用"""
database.add_app(**kwargs)
return database.add_app(**kwargs)


def delete_app(app_id: int, user_id: int):
Expand Down
1 change: 1 addition & 0 deletions src/agentcraft-all/agentcraft-be/app/database/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def add_app(**kwargs):
app = App(**kwargs)
session.add(app)
session.commit()
return app.id


def get_app(app_id: int, user_id: int) -> App:
Expand Down
1 change: 1 addition & 0 deletions src/agentcraft-all/agentcraft-be/app/database/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def add_dataset(**kwargs):
dataset = Dataset(**kwargs)
session.add(dataset)
session.commit()
return dataset.id


def update_dataset(dataset_id: int, user_id: int, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions src/agentcraft-all/agentcraft-be/app/database/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def add_model(**kwargs):
model = Model(**kwargs)
session.add(model)
session.commit()
return model.id


def get_model(model_id: int, user_id: int) -> Model:
Expand Down
7 changes: 4 additions & 3 deletions src/agentcraft-all/agentcraft-be/app/dataset/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ async def list_datasets(page: int, limit: int, dataset_type: int | None = None,
}


@router.post('/add', response_model=BasicResponse)
@router.post('/add', response_model=DictResponse)
async def add_dataset(req: UpsertDatasetRequest, token: JWTData = Depends(validate_token)):
"""添加数据集"""
service.add_dataset(user_id=token.user_id, **vars(req))
id = service.add_dataset(user_id=token.user_id, **vars(req))
return {
"code": 201,
"code": 200,
"msg": "success",
"data": {"id":id}
}


Expand Down
2 changes: 1 addition & 1 deletion src/agentcraft-all/agentcraft-be/app/dataset/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def list_datasets(user_id: int, page: int, limit: int, dataset_type: int = None)

def add_dataset(**kwargs):
"""增加数据集"""
database.add_dataset(**kwargs)
return database.add_dataset(**kwargs)

def update_dataset(**kwargs):
"""修改数据集"""
Expand Down
7 changes: 5 additions & 2 deletions src/agentcraft-all/agentcraft-be/app/model/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ async def list_models(page: int, limit: int, token: JWTData = Depends(validate_t
}


@router.post('/add', response_model=BasicResponse)
@router.post('/add', response_model=DictResponse)
async def add_model(req: UpsertModelRequest, token: JWTData = Depends(validate_token)):
"""添加模型"""
service.add_model(user_id=token.user_id, **vars(req))
id = service.add_model(user_id=token.user_id, **vars(req))
return {
"code": 201,
"msg": "success",
"data": {
"id": id
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/agentcraft-all/agentcraft-be/app/model/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def list_models(user_id: int, page: int, limit: int):

def add_model(**kwargs):
"""添加模型"""
database.add_model(**kwargs)
return database.add_model(**kwargs)


def delete_model(model_id: int, user_id: int):
Expand Down
4 changes: 3 additions & 1 deletion src/agentcraft-all/agentcraft-fe/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ baseUrl=http://localhost:8000
MAIN_ACCOUNT_ID=
AK=
SK=
Region=cn-hangzhou
Region=cn-hangzhou
beServiceName=FCAgentCraftAll
beFunctionName=agentcraft-backend
1 change: 1 addition & 0 deletions src/agentcraft-all/agentcraft-fe/.next/BUILD_ID
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VdPi82T2mXCrUFqZf_MLQ
Loading

0 comments on commit d7f2a05

Please sign in to comment.