@ynhcj/xiaoyi-channel 0.0.148-beta → 0.0.150-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Image Reading tool implementation
|
|
2
|
+
import { createHash } from "crypto";
|
|
2
3
|
import { XYFileUploadService } from "../file-upload.js";
|
|
3
4
|
import fetch from "node-fetch";
|
|
4
5
|
import fs from "fs/promises";
|
|
@@ -50,9 +51,9 @@ async function processImageInput(imageInput, uploadService) {
|
|
|
50
51
|
* Call image understanding API with streaming response
|
|
51
52
|
* Supports both single image and multiple images (imageUrls array)
|
|
52
53
|
*/
|
|
53
|
-
async function callImageUnderstandingAPI(imageUrls, text, apiKey, uid, fileUploadUrl) {
|
|
54
|
+
async function callImageUnderstandingAPI(imageUrls, text, apiKey, uid, fileUploadUrl, sessionId) {
|
|
54
55
|
const apiUrl = `${fileUploadUrl}/celia-claw/v1/sse-api/skill/execute`;
|
|
55
|
-
const traceId =
|
|
56
|
+
const traceId = `${createHash("sha256").update(uid).digest("hex").slice(0, 32)}_${Date.now()}`;
|
|
56
57
|
const headers = {
|
|
57
58
|
"Content-Type": "application/json",
|
|
58
59
|
"Accept": "text/event-stream",
|
|
@@ -67,7 +68,7 @@ async function callImageUnderstandingAPI(imageUrls, text, apiKey, uid, fileUploa
|
|
|
67
68
|
version: "1.0",
|
|
68
69
|
session: {
|
|
69
70
|
isNew: false,
|
|
70
|
-
sessionId
|
|
71
|
+
sessionId,
|
|
71
72
|
interactionId: 0,
|
|
72
73
|
},
|
|
73
74
|
endpoint: {
|
|
@@ -165,7 +166,7 @@ async function callImageUnderstandingAPI(imageUrls, text, apiKey, uid, fileUploa
|
|
|
165
166
|
* Supports both local file paths and remote URLs, up to 10 images at once.
|
|
166
167
|
*/
|
|
167
168
|
export function createImageReadingTool(ctx) {
|
|
168
|
-
const { config } = ctx;
|
|
169
|
+
const { config, sessionId } = ctx;
|
|
169
170
|
return {
|
|
170
171
|
name: "image_reading",
|
|
171
172
|
label: "Image Reading",
|
|
@@ -209,7 +210,7 @@ export function createImageReadingTool(ctx) {
|
|
|
209
210
|
allImageUrls.push(await processImageInput(imageInput, uploadService));
|
|
210
211
|
}
|
|
211
212
|
// Call image understanding API with all image URLs
|
|
212
|
-
const caption = await callImageUnderstandingAPI(allImageUrls, prompt, config.apiKey, config.uid, config.fileUploadUrl);
|
|
213
|
+
const caption = await callImageUnderstandingAPI(allImageUrls, prompt, config.apiKey, config.uid, config.fileUploadUrl, sessionId);
|
|
213
214
|
return {
|
|
214
215
|
content: [
|
|
215
216
|
{
|