intention-coding 0.5.2 → 0.5.3
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.
- package/dist/index.cjs +251 -4
- package/dist/services/image-analysis/analyzer.d.ts +4 -0
- package/dist/services/image-analysis/analyzer.d.ts.map +1 -1
- package/dist/services/image-analysis/index.d.ts.map +1 -1
- package/dist/services/image-converter/index.d.ts +2 -2
- package/dist/utils/dify.d.ts +24 -2
- package/dist/utils/dify.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4684,6 +4684,202 @@ ${requirementSection}
|
|
|
4684
4684
|
}
|
|
4685
4685
|
}
|
|
4686
4686
|
const openAIService = new OpenAIService();
|
|
4687
|
+
async function invokeFlow(params, streamCb) {
|
|
4688
|
+
const { appid = 'app-ESTcrkOPOmkxdrO0120mE4s1', data, timeout = 1800000 } = params;
|
|
4689
|
+
const controller = new AbortController();
|
|
4690
|
+
const signal = controller.signal;
|
|
4691
|
+
if ('undefined' == typeof ReadableStream) throw new Error('ReadableStream is not supported in this environment');
|
|
4692
|
+
const fetchData = async (retryCount = 0)=>{
|
|
4693
|
+
try {
|
|
4694
|
+
const fetchOptions = {
|
|
4695
|
+
method: 'POST',
|
|
4696
|
+
headers: {
|
|
4697
|
+
Authorization: `Bearer ${appid}`,
|
|
4698
|
+
'Content-Type': 'application/json'
|
|
4699
|
+
},
|
|
4700
|
+
body: JSON.stringify({
|
|
4701
|
+
inputs: data,
|
|
4702
|
+
response_mode: 'streaming',
|
|
4703
|
+
user: "aico-mcp"
|
|
4704
|
+
}),
|
|
4705
|
+
signal
|
|
4706
|
+
};
|
|
4707
|
+
const res = await fetch('http://11.0.166.20:9199/v1/workflows/run', fetchOptions);
|
|
4708
|
+
if (!res.ok) {
|
|
4709
|
+
if (retryCount < 3) {
|
|
4710
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
4711
|
+
return fetchData(retryCount + 1);
|
|
4712
|
+
}
|
|
4713
|
+
const errorResponse = await res.text();
|
|
4714
|
+
throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
|
|
4715
|
+
}
|
|
4716
|
+
if (res.ok) if (res.body) {
|
|
4717
|
+
const reader = res.body.getReader();
|
|
4718
|
+
const decoder = new TextDecoder('utf-8');
|
|
4719
|
+
if (streamCb) return void new ReadableStream({
|
|
4720
|
+
start (controller) {
|
|
4721
|
+
let buffer = '';
|
|
4722
|
+
function push() {
|
|
4723
|
+
reader.read().then(({ done, value })=>{
|
|
4724
|
+
if (done) {
|
|
4725
|
+
const lines = buffer.split('\n');
|
|
4726
|
+
for (const line of lines)handleLine(line, controller);
|
|
4727
|
+
if (streamCb) streamCb({
|
|
4728
|
+
isEnd: true
|
|
4729
|
+
});
|
|
4730
|
+
controller.close();
|
|
4731
|
+
return;
|
|
4732
|
+
}
|
|
4733
|
+
const chunkText = decoder.decode(value, {
|
|
4734
|
+
stream: true
|
|
4735
|
+
});
|
|
4736
|
+
buffer += chunkText;
|
|
4737
|
+
const lines = buffer.split('\n');
|
|
4738
|
+
for(let i = 0; i < lines.length - 1; i++)handleLine(lines[i], controller);
|
|
4739
|
+
buffer = lines[lines.length - 1];
|
|
4740
|
+
push();
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
function handleLine(line, controller) {
|
|
4744
|
+
line = line.trim();
|
|
4745
|
+
if (line.startsWith('data:')) {
|
|
4746
|
+
const dataStr = line.slice(5).trim();
|
|
4747
|
+
if ('' === dataStr) return;
|
|
4748
|
+
try {
|
|
4749
|
+
const jsonData = JSON.parse(dataStr);
|
|
4750
|
+
if (jsonData.data?.text) {
|
|
4751
|
+
const wrappedData = {
|
|
4752
|
+
content: jsonData.data.text.toString(),
|
|
4753
|
+
controller
|
|
4754
|
+
};
|
|
4755
|
+
if (streamCb) streamCb(wrappedData);
|
|
4756
|
+
}
|
|
4757
|
+
} catch (e) {
|
|
4758
|
+
console.error("\u89E3\u6790JSON\u5931\u8D25:", e);
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
push();
|
|
4763
|
+
}
|
|
4764
|
+
});
|
|
4765
|
+
{
|
|
4766
|
+
let buffer = '';
|
|
4767
|
+
let accumulatedText = '';
|
|
4768
|
+
let isResponseEnded = false;
|
|
4769
|
+
const readAll = async ()=>{
|
|
4770
|
+
const { done, value } = await reader.read();
|
|
4771
|
+
if (done) {
|
|
4772
|
+
if (!isResponseEnded) throw new Error("\u54CD\u5E94\u63D0\u524D\u7ED3\u675F");
|
|
4773
|
+
return accumulatedText;
|
|
4774
|
+
}
|
|
4775
|
+
const chunkText = decoder.decode(value, {
|
|
4776
|
+
stream: true
|
|
4777
|
+
});
|
|
4778
|
+
buffer += chunkText;
|
|
4779
|
+
const lines = buffer.split('\n');
|
|
4780
|
+
for(let i = 0; i < lines.length - 1; i++){
|
|
4781
|
+
const line = lines[i].trim();
|
|
4782
|
+
if (!line.startsWith('data:')) continue;
|
|
4783
|
+
const dataStr = line.slice(5).trim();
|
|
4784
|
+
if ('' !== dataStr) try {
|
|
4785
|
+
const jsonData = JSON.parse(dataStr);
|
|
4786
|
+
switch(jsonData.event){
|
|
4787
|
+
case 'message':
|
|
4788
|
+
case 'agent_message':
|
|
4789
|
+
case 'text_chunk':
|
|
4790
|
+
{
|
|
4791
|
+
const content = 'text_chunk' === jsonData.event ? jsonData.data.text : jsonData.answer;
|
|
4792
|
+
accumulatedText += content;
|
|
4793
|
+
break;
|
|
4794
|
+
}
|
|
4795
|
+
case 'workflow_finished':
|
|
4796
|
+
accumulatedText = jsonData.data;
|
|
4797
|
+
isResponseEnded = true;
|
|
4798
|
+
break;
|
|
4799
|
+
case 'message_end':
|
|
4800
|
+
isResponseEnded = true;
|
|
4801
|
+
break;
|
|
4802
|
+
case 'error':
|
|
4803
|
+
throw new Error(`\u{670D}\u{52A1}\u{5668}\u{9519}\u{8BEF}: ${jsonData.code}, ${jsonData.message}`);
|
|
4804
|
+
default:
|
|
4805
|
+
break;
|
|
4806
|
+
}
|
|
4807
|
+
} catch (e) {
|
|
4808
|
+
throw new Error("\u89E3\u6790JSON\u5931\u8D25: " + e.message);
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
buffer = lines[lines.length - 1];
|
|
4812
|
+
return readAll();
|
|
4813
|
+
};
|
|
4814
|
+
return readAll();
|
|
4815
|
+
}
|
|
4816
|
+
} else throw new Error("\u54CD\u5E94\u4F53\u4E3A\u7A7A");
|
|
4817
|
+
{
|
|
4818
|
+
const errorResponse = await res.text();
|
|
4819
|
+
throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
|
|
4820
|
+
}
|
|
4821
|
+
} catch (error) {
|
|
4822
|
+
if ('AbortError' === error.name) throw new Error("\u8BF7\u6C42\u5DF2\u88AB\u4E2D\u6B62\uFF0C\u8D85\u65F6");
|
|
4823
|
+
throw error;
|
|
4824
|
+
}
|
|
4825
|
+
};
|
|
4826
|
+
try {
|
|
4827
|
+
const result = await Promise.race([
|
|
4828
|
+
fetchData(),
|
|
4829
|
+
new Promise((_, reject)=>{
|
|
4830
|
+
setTimeout(()=>{
|
|
4831
|
+
controller.abort();
|
|
4832
|
+
reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
|
|
4833
|
+
}, timeout);
|
|
4834
|
+
})
|
|
4835
|
+
]);
|
|
4836
|
+
if (streamCb) return;
|
|
4837
|
+
return result;
|
|
4838
|
+
} catch (error) {
|
|
4839
|
+
controller.abort();
|
|
4840
|
+
throw error;
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
async function uploadFile(params) {
|
|
4844
|
+
const { appid, filePath, user = 'aico-mcp' } = params;
|
|
4845
|
+
try {
|
|
4846
|
+
const fileBuffer = await external_fs_default().promises.readFile(filePath);
|
|
4847
|
+
const fileName = external_path_default().basename(filePath);
|
|
4848
|
+
const fileExtension = external_path_default().extname(filePath).toLowerCase().slice(1);
|
|
4849
|
+
const mimeTypes = {
|
|
4850
|
+
png: 'image/png',
|
|
4851
|
+
jpeg: 'image/jpeg',
|
|
4852
|
+
jpg: 'image/jpeg',
|
|
4853
|
+
webp: 'image/webp',
|
|
4854
|
+
gif: 'image/gif'
|
|
4855
|
+
};
|
|
4856
|
+
const mimeType = mimeTypes[fileExtension] || 'application/octet-stream';
|
|
4857
|
+
const formData = new FormData();
|
|
4858
|
+
formData.append('file', new Blob([
|
|
4859
|
+
fileBuffer.buffer
|
|
4860
|
+
], {
|
|
4861
|
+
type: mimeType
|
|
4862
|
+
}), fileName);
|
|
4863
|
+
formData.append('user', user);
|
|
4864
|
+
const response = await fetch('http://11.0.166.20:9199/v1/files/upload', {
|
|
4865
|
+
method: 'POST',
|
|
4866
|
+
headers: {
|
|
4867
|
+
Authorization: `Bearer ${appid}`
|
|
4868
|
+
},
|
|
4869
|
+
body: formData
|
|
4870
|
+
});
|
|
4871
|
+
if (!response.ok) {
|
|
4872
|
+
const errorText = await response.text();
|
|
4873
|
+
throw new Error(`\u{6587}\u{4EF6}\u{4E0A}\u{4F20}\u{5931}\u{8D25}: ${response.status} ${response.statusText} - ${errorText}`);
|
|
4874
|
+
}
|
|
4875
|
+
const result = await response.json();
|
|
4876
|
+
if (!result.id || !result.name) throw new Error("\u65E0\u6548\u7684\u6587\u4EF6\u4E0A\u4F20\u54CD\u5E94\u683C\u5F0F");
|
|
4877
|
+
return result;
|
|
4878
|
+
} catch (error) {
|
|
4879
|
+
if (error instanceof Error) throw new Error(`\u{6587}\u{4EF6}\u{4E0A}\u{4F20}\u{5931}\u{8D25}: ${error.message}`);
|
|
4880
|
+
throw new Error("\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25: \u672A\u77E5\u9519\u8BEF");
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4687
4883
|
var types_AnalysisType = /*#__PURE__*/ function(AnalysisType) {
|
|
4688
4884
|
AnalysisType["GENERAL"] = "general";
|
|
4689
4885
|
AnalysisType["OBJECTS"] = "objects";
|
|
@@ -4782,15 +4978,13 @@ ${requirementSection}
|
|
|
4782
4978
|
const analysisContent = this.parseAIResponse(aiResponse);
|
|
4783
4979
|
return analysisContent;
|
|
4784
4980
|
} catch (error) {
|
|
4785
|
-
logger.
|
|
4981
|
+
logger.warn("\u4E3BAI\u5206\u6790\u5931\u8D25\uFF0C\u5C1D\u8BD5Dify\u515C\u5E95\u5206\u6790", {
|
|
4786
4982
|
error,
|
|
4787
4983
|
params: {
|
|
4788
4984
|
image_path: imagePath
|
|
4789
4985
|
}
|
|
4790
4986
|
});
|
|
4791
|
-
|
|
4792
|
-
originalError: error
|
|
4793
|
-
});
|
|
4987
|
+
return await this.fallbackToDifyAnalysis(imagePath, context);
|
|
4794
4988
|
}
|
|
4795
4989
|
}
|
|
4796
4990
|
buildAnalysisPrompt(imagePath, basicInfo, context) {
|
|
@@ -5055,6 +5249,59 @@ ${context}
|
|
|
5055
5249
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
5056
5250
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
5057
5251
|
}
|
|
5252
|
+
async fallbackToDifyAnalysis(imagePath, context) {
|
|
5253
|
+
logger.info("\u5F00\u59CBDify\u515C\u5E95\u56FE\u7247\u5206\u6790", {
|
|
5254
|
+
imagePath: imagePath,
|
|
5255
|
+
context: context
|
|
5256
|
+
});
|
|
5257
|
+
try {
|
|
5258
|
+
const uploadResult = await uploadFile({
|
|
5259
|
+
appid: 'app-AvlLh0nfN4l9oz1MSW4sEAQ6',
|
|
5260
|
+
filePath: imagePath,
|
|
5261
|
+
user: 'aico-mcp'
|
|
5262
|
+
});
|
|
5263
|
+
logger.info("\u6587\u4EF6\u4E0A\u4F20\u6210\u529F\uFF0C\u6587\u4EF6ID:", uploadResult.id);
|
|
5264
|
+
const workflowData = {
|
|
5265
|
+
imagePath: {
|
|
5266
|
+
type: 'image',
|
|
5267
|
+
transfer_method: 'local_file',
|
|
5268
|
+
upload_file_id: uploadResult.id
|
|
5269
|
+
},
|
|
5270
|
+
context: context || "\u8BF7\u5206\u6790\u8FD9\u5F20\u56FE\u7247\u7684\u5185\u5BB9"
|
|
5271
|
+
};
|
|
5272
|
+
const workflowResponse = await invokeFlow({
|
|
5273
|
+
appid: 'app-AvlLh0nfN4l9oz1MSW4sEAQ6',
|
|
5274
|
+
data: workflowData
|
|
5275
|
+
});
|
|
5276
|
+
logger.info("Dify\u5DE5\u4F5C\u6D41\u8C03\u7528\u6210\u529F", {
|
|
5277
|
+
response: workflowResponse
|
|
5278
|
+
});
|
|
5279
|
+
if (workflowResponse?.status === 'failed') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{6267}\u{884C}\u{5931}\u{8D25}: ${workflowResponse.error || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5280
|
+
if (workflowResponse?.status !== 'succeeded') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{72B6}\u{6001}\u{5F02}\u{5E38}: ${workflowResponse?.status}`);
|
|
5281
|
+
let summary = "\u5206\u6790\u5B8C\u6210";
|
|
5282
|
+
if ('string' == typeof workflowResponse) summary = workflowResponse;
|
|
5283
|
+
else if (workflowResponse?.data?.text) summary = workflowResponse.data.text;
|
|
5284
|
+
else if (workflowResponse?.answer) summary = workflowResponse.answer;
|
|
5285
|
+
else if (workflowResponse?.outputs?.text) summary = workflowResponse.outputs.text;
|
|
5286
|
+
return {
|
|
5287
|
+
summary: summary,
|
|
5288
|
+
details: {
|
|
5289
|
+
dify_response: workflowResponse,
|
|
5290
|
+
fallback_used: true
|
|
5291
|
+
},
|
|
5292
|
+
tags: [
|
|
5293
|
+
'dify-fallback'
|
|
5294
|
+
]
|
|
5295
|
+
};
|
|
5296
|
+
} catch (error) {
|
|
5297
|
+
logger.error("Dify\u670D\u52A1\u8C03\u7528\u5931\u8D25", {
|
|
5298
|
+
error: error instanceof Error ? error.message : String(error),
|
|
5299
|
+
imagePath: imagePath,
|
|
5300
|
+
context: context
|
|
5301
|
+
});
|
|
5302
|
+
throw new ImageAnalysisError(`\u{56FE}\u{7247}\u{5206}\u{6790}\u{670D}\u{52A1}\u{8C03}\u{7528}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`, types_AnalysisErrorCodes.AI_SERVICE_ERROR);
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5058
5305
|
}
|
|
5059
5306
|
const ImageAnalysisParamsSchema = objectType({
|
|
5060
5307
|
image_path: stringType().min(1).describe("\u56FE\u7247\u6587\u4EF6\u8DEF\u5F84"),
|
|
@@ -51,5 +51,9 @@ export declare class ImageAnalyzer {
|
|
|
51
51
|
private extractNonFunctionalRequirements;
|
|
52
52
|
private extractUserStories;
|
|
53
53
|
private formatFileSize;
|
|
54
|
+
/**
|
|
55
|
+
* Dify兜底分析 - 当所有现有分析方法失败时调用
|
|
56
|
+
*/
|
|
57
|
+
private fallbackToDifyAnalysis;
|
|
54
58
|
}
|
|
55
59
|
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/analyzer.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,cAAc,EAQf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAmDhF;;OAEG;YACW,iBAAiB;IAgC/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAwB3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;YACW,iBAAiB;IAyB/B;;OAEG;YACW,aAAa;IAsC3B;;OAEG;YACW,cAAc;IA0B5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,6BAA6B;IA2BrC,OAAO,CAAC,gCAAgC;IAqBxC,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,cAAc;IAUtB;;OAEG;YACW,sBAAsB;CAiFrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/image-analysis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,QAAA,MAAM,yBAAyB;;;;;;;;;EAI3B,CAAC;AAEL,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;oBASH;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;CAqD/D,CAAC;AAGF,eAAO,MAAM,iBAAiB;;;;;;;oBAxDN;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;CAwDjB,CAAC;AA4GhD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
@@ -9,7 +9,7 @@ declare const ImageConversionParamsSchema: z.ZodObject<{
|
|
|
9
9
|
output_directory: z.ZodOptional<z.ZodString>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
input_paths: string | string[];
|
|
12
|
-
output_format: "
|
|
12
|
+
output_format: "png" | "jpeg" | "jpg" | "webp" | "gif" | "bmp" | "tiff" | "ico";
|
|
13
13
|
maintain_aspect_ratio: boolean;
|
|
14
14
|
width?: number | undefined;
|
|
15
15
|
height?: number | undefined;
|
|
@@ -17,7 +17,7 @@ declare const ImageConversionParamsSchema: z.ZodObject<{
|
|
|
17
17
|
output_directory?: string | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
input_paths: string | string[];
|
|
20
|
-
output_format: "
|
|
20
|
+
output_format: "png" | "jpeg" | "jpg" | "webp" | "gif" | "bmp" | "tiff" | "ico";
|
|
21
21
|
width?: number | undefined;
|
|
22
22
|
height?: number | undefined;
|
|
23
23
|
quality?: number | undefined;
|
package/dist/utils/dify.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ReadableStreamController } from "stream/web";
|
|
2
1
|
interface Params {
|
|
3
2
|
appid?: string;
|
|
4
3
|
data: any;
|
|
@@ -6,9 +5,18 @@ interface Params {
|
|
|
6
5
|
}
|
|
7
6
|
type StreamCallback = (data: {
|
|
8
7
|
content?: string;
|
|
9
|
-
controller?:
|
|
8
|
+
controller?: any;
|
|
10
9
|
isEnd?: boolean;
|
|
11
10
|
}) => void;
|
|
11
|
+
interface DifyFileUploadResponse {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
size: number;
|
|
15
|
+
extension: string;
|
|
16
|
+
mime_type: string;
|
|
17
|
+
created_by: number;
|
|
18
|
+
created_at: number;
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* 调用工作流
|
|
14
22
|
*
|
|
@@ -27,5 +35,19 @@ export declare function invokeFlow(params: Params, streamCb?: StreamCallback): P
|
|
|
27
35
|
* @returns 移除代码块后的内容
|
|
28
36
|
*/
|
|
29
37
|
export declare function removeCodeBlock(content: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* 上传文件到Dify API
|
|
40
|
+
*
|
|
41
|
+
* @param params 上传参数
|
|
42
|
+
* @param params.appid 应用ID
|
|
43
|
+
* @param params.filePath 本地文件路径
|
|
44
|
+
* @param params.user 用户标识
|
|
45
|
+
* @returns Promise<DifyFileUploadResponse> 文件上传响应
|
|
46
|
+
*/
|
|
47
|
+
export declare function uploadFile(params: {
|
|
48
|
+
appid?: string;
|
|
49
|
+
filePath: string;
|
|
50
|
+
user?: string;
|
|
51
|
+
}): Promise<DifyFileUploadResponse>;
|
|
30
52
|
export {};
|
|
31
53
|
//# sourceMappingURL=dify.d.ts.map
|
package/dist/utils/dify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dify.d.ts","sourceRoot":"","sources":["../../src/utils/dify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dify.d.ts","sourceRoot":"","sources":["../../src/utils/dify.ts"],"names":[],"mappings":"AAGA,UAAU,MAAM;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,KAAK,IAAI,CAAC;AAGX,UAAU,sBAAsB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAwNxF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,UAY9C;AAGD;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAyDlC"}
|