MCPcopy Create free account
hub / github.com/Hello-Application-XH/HelloGML / extractRefFileUrls

Function extractRefFileUrls

src/chat.ts:653–665  ·  view source on GitHub ↗
(messages: any[])

Source from the content-addressed store, hash-verified

651}
652
653function extractRefFileUrls(messages: any[]) {
654 const urls: string[] = [];
655 if (!messages.length) return urls;
656 const lastMessage = messages[messages.length - 1];
657 if (isArray(lastMessage.content)) {
658 lastMessage.content.forEach((v: any) => {
659 if (!isObject(v) || !["file", "image_url"].includes(v["type"])) return;
660 if (v["type"] == "file" && isObject(v["file_url"]) && isString(v["file_url"]["url"])) urls.push(v["file_url"]["url"]);
661 else if (v["type"] == "image_url" && isObject(v["image_url"]) && isString(v["image_url"]["url"])) urls.push(v["image_url"]["url"]);
662 });
663 }
664 return urls;
665}
666
667function messagesPrepare(messages: any[], refs: any[], isRefConv = false) {
668 let content: string;

Callers 2

createCompletionFunction · 0.85
createCompletionStreamFunction · 0.85

Calls 3

isArrayFunction · 0.90
isObjectFunction · 0.90
isStringFunction · 0.90

Tested by

no test coverage detected