Compare commits
2 Commits
8e10300e54
...
5382e3c998
| Author | SHA1 | Date |
|---|---|---|
|
|
5382e3c998 | |
|
|
f21bd8f6b9 |
|
|
@ -5,13 +5,13 @@
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "mastra dev",
|
"dev:mastra": "mastra dev",
|
||||||
"build": "mastra build",
|
"build:mastra": "mastra build",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"build:vite": "vite build",
|
"build": "vite build",
|
||||||
"generate": "pnpx tsx ./src/scripts/index.ts",
|
"generate": "pnpx tsx ./src/scripts/index.ts",
|
||||||
"server:dev": "cross-env NODE_ENV=development tsx watch src/server/index.ts",
|
"server:dev": "cross-env NODE_ENV=development tsx watch src/server/index.ts",
|
||||||
"server:vite:dev": "vite",
|
"dev": "vite",
|
||||||
"server:vite:start": "node dist/index.cjs"
|
"server:vite:start": "node dist/index.cjs"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import { Agent } from "@mastra/core/agent";
|
import { Agent } from "@mastra/core/agent";
|
||||||
import {
|
import {
|
||||||
calculatorTool,
|
|
||||||
goodsTool,
|
goodsTool,
|
||||||
|
cabinetTool,
|
||||||
|
shopTool,
|
||||||
|
dynamicInfoTool,
|
||||||
} from "../tools";
|
} from "../tools";
|
||||||
import { createDeepSeek } from '@ai-sdk/deepseek';
|
import { createDeepSeek } from '@ai-sdk/deepseek';
|
||||||
import { createOpenAI } from '@ai-sdk/openai';
|
import { createOpenAI } from '@ai-sdk/openai';
|
||||||
|
|
@ -39,8 +41,18 @@ export const multiFunctionAgent = new Agent({
|
||||||
content: `
|
content: `
|
||||||
你是一个具有内存功能的多功能助手,具备以下能力:
|
你是一个具有内存功能的多功能助手,具备以下能力:
|
||||||
|
|
||||||
1. **计算器**:执行基本算术运算(加、减、乘、除)。
|
1. **商品查询**:使用商品工具查询商品信息,支持分页查询商品列表或根据商品ID获取单个商品详情。
|
||||||
2. **商品查询**:使用商品工具查询商品信息,支持分页查询商品列表或根据商品ID获取单个商品详情。
|
2. **柜机查询**:使用柜机工具查询智能柜信息,支持查询柜机详情。
|
||||||
|
3. **门店查询**:使用门店工具查询门店相关信息,支持查询门店列表、模式列表。
|
||||||
|
4. **借还动态查询**:使用借还动态工具查询商品借还记录,支持按商品ID、格口ID、状态、动态类型筛选,可查询借出和归还记录。
|
||||||
|
|
||||||
|
各个概念层级关系如下:
|
||||||
|
- 模式(mode):表示门店和智能柜的运行模式,(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式 5-暂存模式)。
|
||||||
|
- 归属类型(belongType 0-借还柜 1-固资通),表示智能柜的归属类型,固资通只能运行耗材模式,借还柜可以运行其他模式。
|
||||||
|
- 门店(shop):表示具体的门店实体,每个门店都有唯一的ID和名称、一个或多个智能柜、一种运行模式。
|
||||||
|
- 智能柜(cabinet):表示具体的智能柜实体,每个智能柜都有唯一的ID和名称,属于某个门店。
|
||||||
|
- 格口(cell):表示智能柜中的一个具体位置,每个格口都有唯一的ID和名称,属于某个智能柜,格口中可以存放商品,也可以用于租赁或暂存个人物品。
|
||||||
|
- 商品(goods):表示具体的商品实体,每个商品都有唯一的ID和名称、价格、库存数量等信息。
|
||||||
|
|
||||||
请始终礼貌、乐于助人。如果用户询问超出你能力范围的事情,请礼貌解释你能做什么。
|
请始终礼貌、乐于助人。如果用户询问超出你能力范围的事情,请礼貌解释你能做什么。
|
||||||
你可以记住之前的对话和用户偏好。
|
你可以记住之前的对话和用户偏好。
|
||||||
|
|
@ -55,7 +67,9 @@ export const multiFunctionAgent = new Agent({
|
||||||
model: deepseek.chat('mimo-v2-flash'),
|
model: deepseek.chat('mimo-v2-flash'),
|
||||||
memory: memory,
|
memory: memory,
|
||||||
tools: {
|
tools: {
|
||||||
calculatorTool,
|
|
||||||
goodsTool,
|
goodsTool,
|
||||||
|
cabinetTool,
|
||||||
|
shopTool,
|
||||||
|
dynamicInfoTool,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
import { request } from '../axios'
|
||||||
|
import type {
|
||||||
|
CabinetDetailResponse,
|
||||||
|
RentingCabinetDetailDTO,
|
||||||
|
AvailableStorageCellDTO,
|
||||||
|
StoreItemToCellCommand,
|
||||||
|
OpenCellByPasswordCommand,
|
||||||
|
ResetCellByPasswordCommand,
|
||||||
|
CabinetCellEntity,
|
||||||
|
UpdateCellRemarkDTO
|
||||||
|
} from './type'
|
||||||
|
import { OpenCabinetApiData } from '../shop/type'
|
||||||
|
import { ResponseData } from '../type'
|
||||||
|
|
||||||
|
/** 获取智能柜详情接口 */
|
||||||
|
export function getCabinetDetailApi(shopId: number) {
|
||||||
|
return request<CabinetDetailResponse>({
|
||||||
|
url: 'cabinet/detail',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
shopId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取出租中的智能柜详情接口 */
|
||||||
|
export function getRentingCabinetDetailApi(shopId: number) {
|
||||||
|
return request<ResponseData<RentingCabinetDetailDTO[]>>({
|
||||||
|
url: 'cabinet/detail/renting',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
shopId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取自己租用中的智能柜详情接口 */
|
||||||
|
export function getUserRentedCabinetListApi(corpid:string, ab98UserId: number) {
|
||||||
|
return request<ResponseData<RentingCabinetDetailDTO[]>>({
|
||||||
|
url: 'cabinet/detail/user',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
corpid,
|
||||||
|
ab98UserId
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function openCabinet(cabinetId: number, pinNo: number, data: OpenCabinetApiData) {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/openCabinet/${cabinetId}/${pinNo}`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const configureGoodsCellsStock = (cellId: number, goodsId: number, stock: number) => {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/configureGoodsCellsStock/${cellId}/${goodsId}/${stock}`,
|
||||||
|
method: 'put'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const changeGoodsCellsStock = (cellId: number, stock: number) => {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/changeGoodsCellsStock/${cellId}/${stock}`,
|
||||||
|
method: 'put'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const clearGoodsCells = (cellId: number) => {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/clearGoodsCells/${cellId}`,
|
||||||
|
method: 'put'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resetCellById = (cellId: number) => {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/reset/${cellId}`,
|
||||||
|
method: 'put'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 临时:更新格口备注 */
|
||||||
|
export const updateCellRemark = (data: UpdateCellRemarkDTO) => {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `cabinet/cell`,
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 获取可用暂存柜格口列表 */
|
||||||
|
export function availableStorageCells(shopId: number) {
|
||||||
|
return request<ResponseData<AvailableStorageCellDTO[]>>({
|
||||||
|
url: 'cabinet/availableStorageCells',
|
||||||
|
method: 'get',
|
||||||
|
params: { shopId }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 存入物品分配格口 */
|
||||||
|
export function storeItemApi(command: StoreItemToCellCommand) {
|
||||||
|
return request<ResponseData<CabinetCellEntity>>({
|
||||||
|
url: 'cabinet/storeItem',
|
||||||
|
method: 'post',
|
||||||
|
data: command
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据密码开启格口 */
|
||||||
|
export function openByPassword(command: OpenCellByPasswordCommand) {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: 'cabinet/openByPassword',
|
||||||
|
method: 'post',
|
||||||
|
data: command
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置格口状态 */
|
||||||
|
export function resetByPassword(command: ResetCellByPasswordCommand) {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: 'cabinet/resetByPassword',
|
||||||
|
method: 'post',
|
||||||
|
data: command
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,189 @@
|
||||||
|
import { ResponseData } from "../type"
|
||||||
|
|
||||||
|
export interface CabinetDetailDTO {
|
||||||
|
/** 柜机ID */
|
||||||
|
cabinetId: number
|
||||||
|
/** 柜机名称 */
|
||||||
|
cabinetName: string
|
||||||
|
/** 锁控编号 */
|
||||||
|
lockControlNo: number
|
||||||
|
/** 格口列表 */
|
||||||
|
cells: CellInfoDTO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 租用中的智能柜详情DTO */
|
||||||
|
export interface RentingCabinetDetailDTO {
|
||||||
|
/** 柜机ID */
|
||||||
|
cabinetId: number
|
||||||
|
/** 柜机名称 */
|
||||||
|
cabinetName: string
|
||||||
|
/** 锁控编号 */
|
||||||
|
lockControlNo: number
|
||||||
|
/** 柜格列表 */
|
||||||
|
cells: RentingCellEntity[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RentingCellEntity extends CabinetCellEntity {
|
||||||
|
/** 订单ID */
|
||||||
|
orderId: number;
|
||||||
|
/** 订单商品ID */
|
||||||
|
orderGoodsId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 智能柜格口实体类 */
|
||||||
|
export interface CabinetCellEntity {
|
||||||
|
/** 格口唯一ID */
|
||||||
|
cellId: number
|
||||||
|
/** 关联柜机ID */
|
||||||
|
cabinetId: number
|
||||||
|
/** 主板ID */
|
||||||
|
mainboardId?: number
|
||||||
|
/** 格口号 */
|
||||||
|
cellNo: number
|
||||||
|
/** 针脚序号 */
|
||||||
|
pinNo: number
|
||||||
|
/** 库存数量 */
|
||||||
|
stock: number
|
||||||
|
/** 格口价格 */
|
||||||
|
cellPrice?: number
|
||||||
|
/** 是否已租用:0-未租用,1-已租用 */
|
||||||
|
isRented: number
|
||||||
|
/** 格口类型(1小格 2中格 3大格 4超大格) */
|
||||||
|
cellType: number
|
||||||
|
/** 使用状态:1空闲 2已占用 */
|
||||||
|
usageStatus: number
|
||||||
|
/** 可用状态:1正常 2故障 */
|
||||||
|
availableStatus: number
|
||||||
|
/** 商品ID */
|
||||||
|
goodsId?: number
|
||||||
|
/** 密码 */
|
||||||
|
password?: string
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CellInfoDTO {
|
||||||
|
/** 格口唯一ID */
|
||||||
|
cellId: number
|
||||||
|
/** 格口号 */
|
||||||
|
cellNo: number
|
||||||
|
/** 针脚序号 */
|
||||||
|
pinNo: number
|
||||||
|
/** 库存数量 */
|
||||||
|
stock: number
|
||||||
|
/** 密码 */
|
||||||
|
password?: string
|
||||||
|
/** 商品信息 */
|
||||||
|
product?: ProductInfoDTO
|
||||||
|
/** 使用状态:1空闲 2已占用 */
|
||||||
|
usageStatus: number
|
||||||
|
/** 格口类型(1小格 2中格 3大格 4超大格) */
|
||||||
|
cellType: number
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProductInfoDTO {
|
||||||
|
goodsId: number
|
||||||
|
goodsName: string
|
||||||
|
price: number
|
||||||
|
coverImg: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CabinetDetailResponse = ResponseData<CabinetDetailDTO[]>
|
||||||
|
|
||||||
|
/** 可用暂存格口DTO - 用于返回可使用的暂存柜格口列表 */
|
||||||
|
export interface AvailableStorageCellDTO {
|
||||||
|
/** 格口ID */
|
||||||
|
cellId: number
|
||||||
|
/** 关联柜机ID */
|
||||||
|
cabinetId: number
|
||||||
|
/** 柜子名称 */
|
||||||
|
cabinetName: string
|
||||||
|
/** 关联主板ID */
|
||||||
|
mainboardId: number
|
||||||
|
/** 格口号 */
|
||||||
|
cellNo: number
|
||||||
|
/** 针脚序号 */
|
||||||
|
pinNo: number
|
||||||
|
/** 库存数量 */
|
||||||
|
stock: number
|
||||||
|
/** 格口租用价格 */
|
||||||
|
cellPrice: number
|
||||||
|
/** 是否已租用 */
|
||||||
|
isRented: number
|
||||||
|
/** 格口类型 */
|
||||||
|
cellType: number
|
||||||
|
/** 使用状态 */
|
||||||
|
usageStatus: number
|
||||||
|
/** 可用状态 */
|
||||||
|
availableStatus: number
|
||||||
|
/** 是否有密码 */
|
||||||
|
hasPassword: boolean
|
||||||
|
/** 关联商品ID */
|
||||||
|
goodsId: number
|
||||||
|
/** 商品名称 */
|
||||||
|
goodsName: string
|
||||||
|
/** 商品价格 */
|
||||||
|
price: number
|
||||||
|
/** 封面图URL */
|
||||||
|
coverImg: string
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 存入物品分配格口请求参数 */
|
||||||
|
export interface StoreItemToCellCommand {
|
||||||
|
/** 店铺ID */
|
||||||
|
shopId: number
|
||||||
|
/** 格口类型(1小格 2中格 3大格 4超大格) */
|
||||||
|
cellType: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据密码开启格口请求参数 */
|
||||||
|
export interface OpenCellByPasswordCommand {
|
||||||
|
/** 店铺ID */
|
||||||
|
shopId: number
|
||||||
|
/** 格口密码 */
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置格口状态请求参数 */
|
||||||
|
export interface ResetCellByPasswordCommand {
|
||||||
|
/** 店铺ID */
|
||||||
|
shopId: number
|
||||||
|
/** 格口密码 */
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新格口备注请求参数(cellId 必需,其他字段可选) */
|
||||||
|
export interface UpdateCellRemarkDTO {
|
||||||
|
/** 格口唯一ID */
|
||||||
|
cellId: number
|
||||||
|
/** 关联柜机ID */
|
||||||
|
cabinetId?: number
|
||||||
|
/** 主板ID */
|
||||||
|
mainboardId?: number
|
||||||
|
/** 格口号 */
|
||||||
|
cellNo?: number
|
||||||
|
/** 针脚序号 */
|
||||||
|
pinNo?: number
|
||||||
|
/** 库存数量 */
|
||||||
|
stock?: number
|
||||||
|
/** 格口价格 */
|
||||||
|
cellPrice?: number
|
||||||
|
/** 是否已租用:0-未租用,1-已租用 */
|
||||||
|
isRented?: number
|
||||||
|
/** 格口类型(1小格 2中格 3大格 4超大格) */
|
||||||
|
cellType?: number
|
||||||
|
/** 使用状态:1空闲 2已占用 */
|
||||||
|
usageStatus?: number
|
||||||
|
/** 可用状态:1正常 2故障 */
|
||||||
|
availableStatus?: number
|
||||||
|
/** 商品ID */
|
||||||
|
goodsId?: number
|
||||||
|
/** 密码 */
|
||||||
|
password?: string
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
import type { PageDTO, ResponseData } from "../type"
|
||||||
|
import { request } from "../axios"
|
||||||
|
|
||||||
|
/** 借还动态查询参数 */
|
||||||
|
export interface SearchBorrowReturnDynamicQuery {
|
||||||
|
/** 商品ID,精确筛选 */
|
||||||
|
goodsId?: number
|
||||||
|
/** 格口ID,精确筛选 */
|
||||||
|
cellId?: number
|
||||||
|
/** 状态筛选(仅对归还记录有效) */
|
||||||
|
status?: number
|
||||||
|
/** 动态类型筛选 */
|
||||||
|
dynamicType?: number
|
||||||
|
/** 页码(默认1) */
|
||||||
|
pageNum?: number
|
||||||
|
/** 每页大小(默认10) */
|
||||||
|
pageSize?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 借还动态响应数据 */
|
||||||
|
export interface BorrowReturnDynamicDTO {
|
||||||
|
/** 订单商品ID */
|
||||||
|
orderGoodsId: number
|
||||||
|
/** 动态类型(0-借出 1-归还) */
|
||||||
|
dynamicType: number
|
||||||
|
/** 动态类型描述 */
|
||||||
|
dynamicTypeStr: string
|
||||||
|
/** 订单ID */
|
||||||
|
orderId: number
|
||||||
|
/** 订单创建时间/借出时间 */
|
||||||
|
orderTime: string
|
||||||
|
/** 商品ID */
|
||||||
|
goodsId: number
|
||||||
|
/** 商品名称 */
|
||||||
|
goodsName: string
|
||||||
|
/** 商品封面图片 */
|
||||||
|
coverImg: string
|
||||||
|
/** 商品单价 */
|
||||||
|
goodsPrice: number
|
||||||
|
/** 数量 */
|
||||||
|
quantity: number
|
||||||
|
/** 支付方式 */
|
||||||
|
paymentMethod: string
|
||||||
|
/** 订单姓名 */
|
||||||
|
orderName: string
|
||||||
|
/** 订单手机号 */
|
||||||
|
orderMobile: string
|
||||||
|
/** 格口ID */
|
||||||
|
cellId: number
|
||||||
|
/** 格口号 */
|
||||||
|
cellNo: number
|
||||||
|
/** 柜机ID */
|
||||||
|
cabinetId: number
|
||||||
|
/** 柜机名称 */
|
||||||
|
cabinetName: string
|
||||||
|
/** 归还/审批时间(归还记录时有效) */
|
||||||
|
operateTime?: string
|
||||||
|
/** 审批ID(归还记录时有效) */
|
||||||
|
approvalId?: number
|
||||||
|
/** 审批状态(归还记录时有效) */
|
||||||
|
status: number
|
||||||
|
/** 状态描述 */
|
||||||
|
statusStr: string
|
||||||
|
/** 审批人(归还记录时有效) */
|
||||||
|
auditName?: string
|
||||||
|
/** 审核说明(归还记录时有效) */
|
||||||
|
auditRemark?: string
|
||||||
|
/** 归还图片(归还记录时有效) */
|
||||||
|
images?: string
|
||||||
|
/** 审核图片(归还记录时有效) */
|
||||||
|
auditImages?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getBorrowReturnDynamicApi(query: SearchBorrowReturnDynamicQuery) {
|
||||||
|
return request<ResponseData<PageDTO<BorrowReturnDynamicDTO>>>({
|
||||||
|
url: "order/borrow-return-dynamic",
|
||||||
|
method: "get",
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
import { request } from "../axios"
|
||||||
|
import { ResponseData } from "../type";
|
||||||
|
import { GetBalanceResponse, GetOrdersByOpenIdDTO, OpenCabinetApiData, QyLoginDTO, QyLoginRequestParams, SearchGoodsDO, ShopEntity, ShopGoodsEntity, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type'
|
||||||
|
import { GetOpenIdRequestParams } from './type'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** 获取商品列表 */
|
||||||
|
export function getShopGoodsListApi(corpid: string, belongType: number) {
|
||||||
|
return request<ResponseData<SearchGoodsDO[]>>({
|
||||||
|
url: "shop/goods/list",
|
||||||
|
method: "get",
|
||||||
|
params: { corpid, belongType }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getShopGoodsApi(shopId: number|null) {
|
||||||
|
return request<ShopGoodsResponseData>({
|
||||||
|
url: "shop/goods",
|
||||||
|
method: "get",
|
||||||
|
params: {
|
||||||
|
shopId: shopId ? shopId : undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交订单接口 */
|
||||||
|
export function submitOrderApi(data: SubmitOrderRequestData) {
|
||||||
|
return request<SubmitOrderResponseData>({
|
||||||
|
url: "order/submit",
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取微信openid */
|
||||||
|
export function getOpenIdApi(params: GetOpenIdRequestParams) {
|
||||||
|
return request<ResponseData<string>>({
|
||||||
|
url: "payment/getOpenId",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/** 企业微信登录 */
|
||||||
|
export function qyLogin(params: QyLoginRequestParams) {
|
||||||
|
return request<ResponseData<QyLoginDTO>>({
|
||||||
|
url: "payment/login/qy",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function fakeQyLoginApi(params: {corpid: string, userid: string}) {
|
||||||
|
return request<ResponseData<QyLoginDTO>>({
|
||||||
|
url: "payment/login/qy/fake",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据openid获取用户订单信息 */
|
||||||
|
export function getOrdersByOpenIdApi(corpid: string, openid: string, hasReturn: number) {
|
||||||
|
return request<ResponseData<GetOrdersByOpenIdDTO>>({
|
||||||
|
url: `order/user/${openid}`,
|
||||||
|
method: "get",
|
||||||
|
params: { corpid, hasReturn }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据openid获取用户订单信息 */
|
||||||
|
export function getOrdersByQyUserIdApi(qyUserId: number, hasReturn: number) {
|
||||||
|
return request<ResponseData<GetOrdersByOpenIdDTO>>({
|
||||||
|
url: `order/user/qy/${qyUserId}`,
|
||||||
|
method: "get",
|
||||||
|
params: { hasReturn }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开储物柜接口 */
|
||||||
|
export function openCabinetApi(orderId: number, orderGoodsId: number, data: OpenCabinetApiData) {
|
||||||
|
return request<ResponseData<void>>({
|
||||||
|
url: `order/openCabinet/${orderId}/${orderGoodsId}`,
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取用户余额接口 */
|
||||||
|
export function getBalanceApi(corpid: string, openid: string) {
|
||||||
|
return request<ResponseData<GetBalanceResponse>>({
|
||||||
|
url: "payment/getBalance",
|
||||||
|
method: "get",
|
||||||
|
params: { corpid, openid }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function getBalanceByQyUserid(corpid: string, userid: string) {
|
||||||
|
return request<ResponseData<GetBalanceResponse>>({
|
||||||
|
url: "payment/getBalanceByQyUserid",
|
||||||
|
method: "get",
|
||||||
|
params: { corpid, userid }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetShopListParams {
|
||||||
|
corpid: string;
|
||||||
|
mode?: number;
|
||||||
|
eqMode?: number;
|
||||||
|
modeList?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getShopListApi(params: GetShopListParams) {
|
||||||
|
return request<ResponseData<ShopEntity[]>>({
|
||||||
|
url: "shop/list",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取模式列表 */
|
||||||
|
export function getModeListApi() {
|
||||||
|
return request<ResponseData<number[]>>({
|
||||||
|
url: "shop/mode/list",
|
||||||
|
method: "get"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,256 @@
|
||||||
|
import { ResponseData } from "../type";
|
||||||
|
|
||||||
|
export type Goods = {
|
||||||
|
goodsId: number,
|
||||||
|
goodsName: string,
|
||||||
|
categoryId: number,
|
||||||
|
price: number,
|
||||||
|
stock: number,
|
||||||
|
status: number,
|
||||||
|
coverImg: string,
|
||||||
|
goodsDetail: string,
|
||||||
|
usageInstruction: string,
|
||||||
|
cellId: number,
|
||||||
|
belongType: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopGoodsEntity {
|
||||||
|
/** 商品唯一ID */
|
||||||
|
goodsId: number;
|
||||||
|
/** 商品名称 */
|
||||||
|
goodsName: string;
|
||||||
|
/** 商品分类ID */
|
||||||
|
categoryId: number;
|
||||||
|
/** 外部归属类型的商品ID */
|
||||||
|
externalGoodsId?: number;
|
||||||
|
/** 企业微信id */
|
||||||
|
corpid?: string;
|
||||||
|
/** 每人每月限购数量 */
|
||||||
|
monthlyPurchaseLimit?: number;
|
||||||
|
/** 销售价格 */
|
||||||
|
price: number;
|
||||||
|
/** 库存数量 */
|
||||||
|
stock: number;
|
||||||
|
/** 商品状态(1上架 2下架) */
|
||||||
|
status: number;
|
||||||
|
/** 免审批(0否 1是) */
|
||||||
|
autoApproval?: number;
|
||||||
|
/** 封面图URL */
|
||||||
|
coverImg?: string;
|
||||||
|
/** 商品详情(支持2000汉字+10个图片链接) */
|
||||||
|
goodsDetail?: string;
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string;
|
||||||
|
/** 商品使用说明 */
|
||||||
|
usageInstruction?: string;
|
||||||
|
/** 归属类型(0-借还柜 1-固资通) */
|
||||||
|
belongType?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type category = {
|
||||||
|
categoryId: number,
|
||||||
|
categoryName: string,
|
||||||
|
sort: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SubmitOrderRequestData {
|
||||||
|
/** 微信用户唯一标识 */
|
||||||
|
openid: string;
|
||||||
|
/** 系统用户ID */
|
||||||
|
userid: string;
|
||||||
|
/** 汇邦云用户ID */
|
||||||
|
ab98UserId: number;
|
||||||
|
/** 企业ID */
|
||||||
|
corpid: string;
|
||||||
|
/** 支付类型 wechat:微信 balance:余额 */
|
||||||
|
paymentType: 'wechat' | 'balance' | "approval";
|
||||||
|
/** 联系电话 */
|
||||||
|
mobile: string;
|
||||||
|
/** 用户姓名 */
|
||||||
|
name: string;
|
||||||
|
/** 企业微信用户ID或汇邦云用户ID */
|
||||||
|
qyUserid: string;
|
||||||
|
/** 是否内部订单 0否 1汇邦云用户 2企业微信用户 */
|
||||||
|
isInternal: number;
|
||||||
|
applyRemark: string;
|
||||||
|
/** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式) */
|
||||||
|
mode: number;
|
||||||
|
/** 订单商品明细列表 */
|
||||||
|
goodsList: Array<{
|
||||||
|
goodsId?: number
|
||||||
|
quantity: number
|
||||||
|
cellId: number
|
||||||
|
/** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式) */
|
||||||
|
mode: number;
|
||||||
|
}>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SubmitOrderResponseData = ResponseData<{
|
||||||
|
orderId: number
|
||||||
|
totalAmount: number
|
||||||
|
newBalance: number
|
||||||
|
paymentInfo: WxJsApiPreCreateResponse
|
||||||
|
}>
|
||||||
|
|
||||||
|
export type ShopGoodsResponseData = ResponseData<{
|
||||||
|
goodsList: Goods[],
|
||||||
|
categoryList: category[]
|
||||||
|
}>
|
||||||
|
|
||||||
|
export interface WxJsApiPreCreateResponse {
|
||||||
|
appId: string
|
||||||
|
timeStamp: string
|
||||||
|
nonceStr: string
|
||||||
|
package: string
|
||||||
|
signType: string
|
||||||
|
paySign: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOpenIdRequestParams {
|
||||||
|
code: string
|
||||||
|
}
|
||||||
|
export interface QyLoginRequestParams {
|
||||||
|
corpid: string
|
||||||
|
code: string
|
||||||
|
state?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopOrderEntity {
|
||||||
|
orderId: number
|
||||||
|
openid: string
|
||||||
|
totalAmount: number
|
||||||
|
status: number
|
||||||
|
payStatus: number
|
||||||
|
paymentMethod: string
|
||||||
|
payTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopOrderGoodsEntity {
|
||||||
|
/** 订单商品唯一ID */
|
||||||
|
orderGoodsId: number
|
||||||
|
/** 关联订单ID */
|
||||||
|
orderId: number
|
||||||
|
/** 审批ID */
|
||||||
|
approvalId: number
|
||||||
|
/** 关联商品ID */
|
||||||
|
goodsId: number
|
||||||
|
/** 关联格口ID */
|
||||||
|
cellId: number
|
||||||
|
/** 购买数量 */
|
||||||
|
quantity: number
|
||||||
|
/** 购买时单价 */
|
||||||
|
price: number
|
||||||
|
/** 商品总金额 */
|
||||||
|
totalAmount: number
|
||||||
|
/** 商品名称 */
|
||||||
|
goodsName: string
|
||||||
|
/** 封面图URL */
|
||||||
|
coverImg: string
|
||||||
|
/** 商品状态(1正常 2已退货 3已换货 4已完成 5审核中 6退货未通过) */
|
||||||
|
status: number
|
||||||
|
/** 企业微信id */
|
||||||
|
corpid: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOrdersByOpenIdDTO {
|
||||||
|
orders: ShopOrderEntity[]
|
||||||
|
orderGoods: ShopOrderGoodsEntity[]
|
||||||
|
goods: Goods[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetBalanceResponse {
|
||||||
|
userid: string
|
||||||
|
corpid: string
|
||||||
|
/** 剩余借呗 */
|
||||||
|
balance: number
|
||||||
|
/** 已用借呗 */
|
||||||
|
useBalance: number
|
||||||
|
/** 借呗总额 */
|
||||||
|
balanceLimit: number
|
||||||
|
ab98User: ab98UserDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QyLoginDTO {
|
||||||
|
userid: string;
|
||||||
|
openid: string;
|
||||||
|
isCabinetAdmin: number;
|
||||||
|
qyUserId: number;
|
||||||
|
name: string;
|
||||||
|
ab98User: ab98UserDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ab98UserDTO {
|
||||||
|
/** 主键ID */
|
||||||
|
ab98UserId?: number;
|
||||||
|
/** openid */
|
||||||
|
openid?: string;
|
||||||
|
/** 汇邦云用户唯一ID */
|
||||||
|
userid?: string;
|
||||||
|
/** 真实姓名 */
|
||||||
|
name?: string;
|
||||||
|
/** 手机号码 */
|
||||||
|
tel?: string;
|
||||||
|
/** 身份证号码 */
|
||||||
|
idnum?: string;
|
||||||
|
/** 性别(男 女) */
|
||||||
|
sex?: string;
|
||||||
|
/** 人脸照片地址 */
|
||||||
|
faceImg?: string;
|
||||||
|
/** 身份证正面地址 */
|
||||||
|
idcardFront?: string;
|
||||||
|
/** 身份证背面地址 */
|
||||||
|
idcardBack?: string;
|
||||||
|
/** 身份证登记地址 */
|
||||||
|
address?: string;
|
||||||
|
/** 是否已注册(0未注册 1已注册) */
|
||||||
|
registered?: boolean;
|
||||||
|
/** 借呗余额 单位分 */
|
||||||
|
ab98Balance?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OpenCabinetApiData {
|
||||||
|
// 格口ID
|
||||||
|
cellId?: number
|
||||||
|
// 用户ID
|
||||||
|
userid: string
|
||||||
|
// 是否内部用户(0否 1汇邦云用户 2企业微信用户)
|
||||||
|
isInternal: number
|
||||||
|
// 姓名
|
||||||
|
name: string
|
||||||
|
// 联系电话
|
||||||
|
mobile: string
|
||||||
|
// 操作类型(1用户 2管理员)
|
||||||
|
operationType: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopEntity {
|
||||||
|
/** 主键ID */
|
||||||
|
shopId: number;
|
||||||
|
/** 商店名称 */
|
||||||
|
shopName: string;
|
||||||
|
/** 企业微信id */
|
||||||
|
corpid: string;
|
||||||
|
/** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式) */
|
||||||
|
mode?: number;
|
||||||
|
/** 借呗支付(1-正常使用 0-禁止使用) */
|
||||||
|
balanceEnable?: number;
|
||||||
|
/** 封面图URL */
|
||||||
|
coverImg?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchGoodsDO extends ShopGoodsEntity {
|
||||||
|
/** 分类名称 */
|
||||||
|
categoryName?: string;
|
||||||
|
/** 柜子ID */
|
||||||
|
cabinetId?: number;
|
||||||
|
/** 柜子名称 */
|
||||||
|
cabinetName?: string;
|
||||||
|
/** 商店名称字符串 */
|
||||||
|
shopNameStr?: string;
|
||||||
|
/** 格口编号 */
|
||||||
|
cellNo?: number;
|
||||||
|
/** 格口编号字符串 */
|
||||||
|
cellNoStr?: string;
|
||||||
|
/** 已分配库存 */
|
||||||
|
totalStock?: number;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { createTool } from "@mastra/core/tools";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { getCabinetDetailApi } from "../api/cabinet";
|
||||||
|
|
||||||
|
export const cabinetTool = createTool({
|
||||||
|
id: "cabinet",
|
||||||
|
description: "查询智能柜详情",
|
||||||
|
|
||||||
|
inputSchema: z.object({
|
||||||
|
shopId: z.number().describe("门店ID"),
|
||||||
|
}),
|
||||||
|
|
||||||
|
outputSchema: z.object({
|
||||||
|
success: z.boolean(),
|
||||||
|
message: z.string(),
|
||||||
|
data: z.any().optional(),
|
||||||
|
}),
|
||||||
|
|
||||||
|
execute: async ({ context }) => {
|
||||||
|
try {
|
||||||
|
const { shopId } = context;
|
||||||
|
|
||||||
|
if (!shopId) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "shopId参数为必填",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await getCabinetDetailApi(shopId);
|
||||||
|
return {
|
||||||
|
success: response.code === 0,
|
||||||
|
message: response.msg || "查询成功",
|
||||||
|
data: response.data,
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `查询失败: ${error.message || "未知错误"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
import { createTool } from "@mastra/core/tools";
|
|
||||||
import { z } from "zod";
|
|
||||||
|
|
||||||
export const calculatorTool = createTool({
|
|
||||||
id: "calculator",
|
|
||||||
description: "执行基本算术运算",
|
|
||||||
inputSchema: z.object({
|
|
||||||
operation: z.enum(["add", "subtract", "multiply", "divide"]).describe("要执行的算术运算"),
|
|
||||||
a: z.number().describe("第一个数字"),
|
|
||||||
b: z.number().describe("第二个数字"),
|
|
||||||
}),
|
|
||||||
outputSchema: z.object({
|
|
||||||
result: z.number(),
|
|
||||||
operation: z.string(),
|
|
||||||
}),
|
|
||||||
execute: async ({ context }) => {
|
|
||||||
const { operation, a, b } = context;
|
|
||||||
let result: number;
|
|
||||||
switch (operation) {
|
|
||||||
case "add":
|
|
||||||
result = a + b;
|
|
||||||
break;
|
|
||||||
case "subtract":
|
|
||||||
result = a - b;
|
|
||||||
break;
|
|
||||||
case "multiply":
|
|
||||||
result = a * b;
|
|
||||||
break;
|
|
||||||
case "divide":
|
|
||||||
if (b === 0) throw new Error("Division by zero");
|
|
||||||
result = a / b;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unknown operation: ${operation}`);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
result,
|
|
||||||
operation: `${a} ${operation} ${b}`,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { createTool } from "@mastra/core/tools";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { getBorrowReturnDynamicApi } from "../api/manage/dynamicInfo";
|
||||||
|
|
||||||
|
export const dynamicInfoTool = createTool({
|
||||||
|
id: "dynamicInfo",
|
||||||
|
description: "查询商品借还动态记录,支持借出和归还记录的查询",
|
||||||
|
|
||||||
|
inputSchema: z.object({
|
||||||
|
goodsId: z.number().optional().describe("商品ID,精确筛选"),
|
||||||
|
cellId: z.number().optional().describe("格口ID,精确筛选"),
|
||||||
|
status: z.number().optional().describe("状态筛选(仅对归还记录有效)"),
|
||||||
|
dynamicType: z.number().optional().describe("动态类型筛选(0-借出 1-归还)"),
|
||||||
|
pageNum: z.number().optional().describe("页码,默认1"),
|
||||||
|
pageSize: z.number().optional().describe("每页大小,默认10"),
|
||||||
|
}),
|
||||||
|
|
||||||
|
outputSchema: z.object({
|
||||||
|
success: z.boolean(),
|
||||||
|
message: z.string(),
|
||||||
|
data: z.array(z.any()).optional(),
|
||||||
|
total: z.number().optional(),
|
||||||
|
pageNum: z.number().optional(),
|
||||||
|
pageSize: z.number().optional(),
|
||||||
|
}),
|
||||||
|
|
||||||
|
execute: async ({ context }) => {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
goodsId,
|
||||||
|
cellId,
|
||||||
|
status,
|
||||||
|
dynamicType,
|
||||||
|
pageNum = 1,
|
||||||
|
pageSize = 10,
|
||||||
|
} = context;
|
||||||
|
|
||||||
|
const response = await getBorrowReturnDynamicApi({
|
||||||
|
goodsId,
|
||||||
|
cellId,
|
||||||
|
status,
|
||||||
|
dynamicType,
|
||||||
|
pageNum,
|
||||||
|
pageSize,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: response.code === 0,
|
||||||
|
message: response.msg || "查询成功",
|
||||||
|
data: response.data?.rows || [],
|
||||||
|
total: response.data?.total || 0,
|
||||||
|
pageNum,
|
||||||
|
pageSize,
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `查询失败: ${error.message || "未知错误"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
export { calculatorTool } from "./calculator-tool";
|
|
||||||
export { goodsTool } from "./goods-tool";
|
export { goodsTool } from "./goods-tool";
|
||||||
|
export { cabinetTool } from "./cabinet-tool";
|
||||||
|
export { shopTool } from "./shop-tool";
|
||||||
|
export { dynamicInfoTool } from "./dynamic-info-tool";
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
import { createTool } from "@mastra/core/tools";
|
||||||
|
import { z } from "zod";
|
||||||
|
import {
|
||||||
|
getShopListApi,
|
||||||
|
getModeListApi,
|
||||||
|
GetShopListParams
|
||||||
|
} from "../api/shop";
|
||||||
|
|
||||||
|
export const shopTool = createTool({
|
||||||
|
id: "shop",
|
||||||
|
description: "查询门店相关信息,支持查询门店列表、模式列表",
|
||||||
|
|
||||||
|
inputSchema: z.object({
|
||||||
|
queryType: z.enum(["shopList", "modeList"]).describe(
|
||||||
|
"查询类型:'shopList'表示获取门店列表,'modeList'表示获取模式列表"
|
||||||
|
),
|
||||||
|
corpid: z.string().optional().describe("企业微信ID(查询门店列表时必填)"),
|
||||||
|
mode: z.number().optional().describe("需要排除的运行模式(查询门店列表时可选,该参数表示不查询该运行模式的门店,默认值为-1)"),
|
||||||
|
eqMode: z.number().optional().describe("运行模式(查询门店列表时可选)"),
|
||||||
|
modeList: z.string().optional().describe("模式列表字符串(查询门店列表时可选)"),
|
||||||
|
}),
|
||||||
|
|
||||||
|
outputSchema: z.object({
|
||||||
|
success: z.boolean(),
|
||||||
|
message: z.string(),
|
||||||
|
data: z.any().optional(),
|
||||||
|
}),
|
||||||
|
|
||||||
|
execute: async ({ context }) => {
|
||||||
|
try {
|
||||||
|
const { queryType, corpid, mode, eqMode, modeList } = context;
|
||||||
|
|
||||||
|
if (queryType === "shopList") {
|
||||||
|
if (!corpid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "查询门店列表时,corpid参数为必填",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const params: GetShopListParams = {
|
||||||
|
corpid,
|
||||||
|
mode,
|
||||||
|
eqMode,
|
||||||
|
modeList,
|
||||||
|
};
|
||||||
|
const response = await getShopListApi(params);
|
||||||
|
return {
|
||||||
|
success: response.code === 0,
|
||||||
|
message: response.msg || "查询成功",
|
||||||
|
data: response.data,
|
||||||
|
};
|
||||||
|
} else if (queryType === "modeList") {
|
||||||
|
const response = await getModeListApi();
|
||||||
|
return {
|
||||||
|
success: response.code === 0,
|
||||||
|
message: response.msg || "查询成功",
|
||||||
|
data: response.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "未知的查询类型",
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: `查询失败: ${error.message || "未知错误"}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -40,6 +40,7 @@ router.post('/generate', validateBody(generateRequestSchema), async (req, res) =
|
||||||
message: response.text,
|
message: response.text,
|
||||||
toolCalls: response.toolCalls,
|
toolCalls: response.toolCalls,
|
||||||
usage: response.usage,
|
usage: response.usage,
|
||||||
|
response: JSON.stringify(response)
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error generating response:', JSON.stringify(error));
|
console.error('Error generating response:', JSON.stringify(error));
|
||||||
|
|
@ -85,22 +86,6 @@ router.post('/test-tools', async (req, res) => {
|
||||||
|
|
||||||
const testResults = [];
|
const testResults = [];
|
||||||
|
|
||||||
// Test calculator tool
|
|
||||||
try {
|
|
||||||
const calcResponse = await agent.generate('Calculate 15 * 3');
|
|
||||||
testResults.push({
|
|
||||||
tool: 'calculatorTool',
|
|
||||||
success: true,
|
|
||||||
response: calcResponse.text.substring(0, 100) + '...',
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
testResults.push({
|
|
||||||
tool: 'calculatorTool',
|
|
||||||
success: false,
|
|
||||||
error: error instanceof Error ? error.message : 'Unknown error',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test goods tool
|
// Test goods tool
|
||||||
try {
|
try {
|
||||||
const goodsResponse = await agent.generate('Query product list with page 1');
|
const goodsResponse = await agent.generate('Query product list with page 1');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue