refactor(shipping-notice): 更新环境变量以及接口增强
This commit is contained in:
1 parent
ff7c227cc2
commit
d9b414b07b
8 files changed
+92
-14
No files matched your search
@@ -55,11 +55,11 @@ MINIO_SECRET_KEY=M3CLE928P8GavJBFZPhJO3RIHVZSRYlDouOMabasojfAGBlx
|
||||
MINIO_SECURE=false
|
||||
MINIO_PUBLIC_BASE_URL=http://192.168.100.192:9000
|
||||
|
||||
# 货代发货通知 Agent(见 docs/shipping_notice.md §1.2)
|
||||
# Tool API(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
|
||||
# 货代发货通知 Agent(见 docs/shipping_notice.md §1.2;Tool 基地址见 HXOPS_TOOL_API_BASE)
|
||||
# RoHS / 货代等 Dify Tool API 基地址(默认与 PUBLIC_BASE_URL 一致)
|
||||
HXOPS_TOOL_API_BASE=http://192.168.100.192:8890
|
||||
# Tool API Key(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
|
||||
SHIPPING_NOTICE_TOOL_API_KEY=I76mSQZQEPYU6TubMhjh-xLsCgWC0gSIg5MncJFHFCvqvVlg-gZ_BvwO_UEL2nh
|
||||
# OpenAPI / Dify Tool 调用基地址(默认等于 PUBLIC_BASE_URL + /api/shipping-notice)
|
||||
SHIPPING_NOTICE_TOOL_API_BASE=http://192.168.36.108:5052/
|
||||
|
||||
# 文件存储(相对 backend/ 根目录)
|
||||
SHIPPING_NOTICE_STORAGE_ROOT=data/shipping_notice
|
||||
|
||||
@@ -57,3 +57,6 @@ MINIO_SECRET_KEY=difyai123456
|
||||
MINIO_SECURE=false
|
||||
# MINIO_PUBLIC_BASE_URL:导出 Markdown 中图片链接,浏览器/外部系统可访问
|
||||
MINIO_PUBLIC_BASE_URL=http://ai.well-trust.com:9000
|
||||
|
||||
# RoHS / 货代等 Dify Tool API 基地址(默认与 PUBLIC_BASE_URL 一致)
|
||||
HXOPS_TOOL_API_BASE=http://192.168.100.230:8891
|
||||
@@ -74,6 +74,8 @@ WECOM_NOTIFY_EVENTS=permission_request_approved,permission_request_rejected,perm
|
||||
# Common integration defaults
|
||||
INTEGRATION_API_MODE=local
|
||||
DIFY_API_BASE=https://api.dify.ai/v1
|
||||
# HXOPS Tool API 对外基地址(RoHS / 货代等 Dify Chatflow、OpenAPI、签名下载链接;无尾斜杠;各环境 .env.* 覆盖)
|
||||
HXOPS_TOOL_API_BASE=
|
||||
|
||||
# MinIO:按环境配置见 .env.dev / .env.test / .env.prod
|
||||
# MINIO_KB_IMAGE_BUCKET — 知识库文档清洗图片托管(kb-worker / export)
|
||||
|
||||
@@ -59,11 +59,11 @@ MINIO_SECURE=false
|
||||
# MINIO_PUBLIC_BASE_URL:导出 Markdown 中图片链接,浏览器/外部系统可访问
|
||||
MINIO_PUBLIC_BASE_URL=http://192.168.100.192:9000
|
||||
|
||||
# 货代发货通知 Agent(见 docs/shipping_notice.md §1.2)
|
||||
# Tool API(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
|
||||
# 货代发货通知 Agent(见 docs/shipping_notice.md §1.2;Tool 基地址见 HXOPS_TOOL_API_BASE)
|
||||
# RoHS / 货代等 Dify Tool API 基地址(默认与 PUBLIC_BASE_URL 一致)
|
||||
HXOPS_TOOL_API_BASE=http://192.168.100.192:8890
|
||||
# Tool API Key(Dify / RPA 回调共用,可与 INTEGRATION_API_KEY 相同)
|
||||
SHIPPING_NOTICE_TOOL_API_KEY=I76mSQZQEPYU6TubMhjh-xLsCgWC0gSIg5MncJFHFCvqvVlg-gZ_BvwO_UEL2nh
|
||||
# OpenAPI / Dify Tool 调用基地址(默认等于 PUBLIC_BASE_URL + /api/shipping-notice)
|
||||
SHIPPING_NOTICE_TOOL_API_BASE=http://192.168.100.192:8890/
|
||||
|
||||
# 文件存储(相对 backend/ 根目录)
|
||||
SHIPPING_NOTICE_STORAGE_ROOT=data/shipping_notice
|
||||
|
||||
@@ -14,9 +14,8 @@ from app.services.shipping_notice.openapi_spec import build_dify_openapi_spec
|
||||
|
||||
def main() -> None:
|
||||
base = (
|
||||
os.getenv("SHIPPING_NOTICE_TOOL_API_BASE")
|
||||
os.getenv("HXOPS_TOOLS_API_BASE")
|
||||
or os.getenv("PUBLIC_BASE_URL")
|
||||
or os.getenv("HXOPS_PUBLIC_BASE_URL")
|
||||
or "http://127.0.0.1:5052"
|
||||
).rstrip("/")
|
||||
spec = build_dify_openapi_spec(base)
|
||||
@@ -30,3 +29,4 @@ def main() -> None:
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_shipping_notice_match_shortage_needs_human(app, client):
|
||||
|
||||
|
||||
def test_openapi_spec_public(app, client):
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_BASE"] = "http://tool-api.example.com"
|
||||
app.config["HXOPS_TOOLS_API_BASE"] = "http://tool-api.example.com"
|
||||
res = client.get("/api/shipping-notice/tools/openapi.json")
|
||||
assert res.status_code == 200
|
||||
spec = res.get_json()
|
||||
@@ -804,6 +804,71 @@ def test_confirm_parse_does_not_skip_inventory_match(app, client):
|
||||
assert task.match_status is None
|
||||
|
||||
|
||||
def test_parse_notice_auto_continue_hides_parse_confirmation_hint(app, client):
|
||||
headers = _tool_headers(app)
|
||||
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers=headers,
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
task_id = create_res.get_json()["task_id"]
|
||||
|
||||
parse_res = client.post(
|
||||
"/api/shipping-notice/tools/parse_notice",
|
||||
headers=headers,
|
||||
json={
|
||||
"task_id": task_id,
|
||||
"structured": {
|
||||
"customer_name": "ACME",
|
||||
"lines": [{"sku": "A001", "reservation_id": "R-1", "qty": 10, "uom": "EA"}],
|
||||
"confidence": 0.95,
|
||||
},
|
||||
},
|
||||
)
|
||||
parse_data = parse_res.get_json()
|
||||
assert "【发货通知解析确认】" in parse_data["message"]
|
||||
assert "回复「确认」进入库存检查" not in parse_data["message"]
|
||||
assert parse_data.get("checkpoint") != "parse_review"
|
||||
|
||||
|
||||
def test_submit_decision_confirm_during_waiting_inventory_is_not_failed(app, client, tmp_path):
|
||||
headers = _tool_headers(app)
|
||||
trigger = tmp_path / "inventory_triggers"
|
||||
trigger.mkdir()
|
||||
app.config["FREIGHT_RPA_INVENTORY_TRIGGER_DIR"] = str(trigger)
|
||||
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_task",
|
||||
headers=headers,
|
||||
json={"source_type": "manual"},
|
||||
)
|
||||
task_id = create_res.get_json()["task_id"]
|
||||
|
||||
parse_res = client.post(
|
||||
"/api/shipping-notice/tools/parse_notice",
|
||||
headers=headers,
|
||||
json={
|
||||
"task_id": task_id,
|
||||
"structured": {
|
||||
"customer_name": "ACME",
|
||||
"lines": [{"sku": "A001", "reservation_id": "R-1", "qty": 10, "uom": "EA"}],
|
||||
"confidence": 0.95,
|
||||
},
|
||||
},
|
||||
)
|
||||
assert parse_res.get_json()["status"] == "running"
|
||||
|
||||
confirm_res = client.post(
|
||||
"/api/shipping-notice/tools/submit_decision",
|
||||
headers=headers,
|
||||
json={"task_id": task_id, "decision": "confirm"},
|
||||
)
|
||||
confirm_data = confirm_res.get_json()
|
||||
assert confirm_data["status"] == "running"
|
||||
assert "RPA 库存导出" in confirm_data["message"]
|
||||
|
||||
|
||||
def test_submit_decision_by_conversation_id(app, client):
|
||||
headers = _tool_headers(app)
|
||||
|
||||
@@ -883,3 +948,4 @@ def test_chat_actions_empty_when_task_rejected(app):
|
||||
payload = build_chat_actions_payload(task)
|
||||
assert payload["checkpoint"] == "rejected"
|
||||
assert payload["action_buttons"] == []
|
||||
|
||||
@@ -153,9 +153,10 @@ export interface ShippingNoticeUploadResponse {
|
||||
human_options?: string[];
|
||||
}
|
||||
|
||||
export async function createWorkspaceShippingTaskFromNotice(file: File) {
|
||||
export async function createWorkspaceShippingTaskFromNotice(file: File, conversationId?: string) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
if (conversationId) form.append('conversation_id', conversationId);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch('/api/workspace/shipping-tasks/create-from-notice', {
|
||||
|
||||
@@ -2915,7 +2915,10 @@ const handleShippingAutoUploadFile = async (file: File) => {
|
||||
if (kind === 'inventory') {
|
||||
let taskId = getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
const created = await createWorkspaceShippingTask({ source_type: 'manual' });
|
||||
const created = await createWorkspaceShippingTask({
|
||||
source_type: 'manual',
|
||||
conversation_id: String(conversationId.value || '').trim() || undefined,
|
||||
});
|
||||
taskId = String(created.task_id || '').trim();
|
||||
if (!taskId) {
|
||||
msg.warning('自动创建发货任务失败');
|
||||
@@ -2928,7 +2931,10 @@ const handleShippingAutoUploadFile = async (file: File) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await createWorkspaceShippingTaskFromNotice(file);
|
||||
const result = await createWorkspaceShippingTaskFromNotice(
|
||||
file,
|
||||
String(conversationId.value || '').trim() || undefined,
|
||||
);
|
||||
const taskId = String(result.task_id || '').trim();
|
||||
if (taskId) resolvedShippingTaskId.value = taskId;
|
||||
const hint = String(result.message || '').trim();
|
||||
|
||||
Reference in new issue
Block a user