@o-lang/llm-groq 1.0.2 → 1.0.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/index.js +30 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -40,12 +40,36 @@ async function summarize(prompt, context) {
|
|
|
40
40
|
return output;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// ✅ O-Lang Resolver Interface
|
|
43
44
|
module.exports = async (action, context) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// Only handle: "Ask llm-groq ..."
|
|
46
|
+
if (action.startsWith('Ask llm-groq ')) {
|
|
47
|
+
// Extract everything after "Ask llm-groq" (including quoted strings)
|
|
48
|
+
const prompt = action.replace(/^Ask\s+llm-groq\s+/i, '').trim();
|
|
49
|
+
|
|
50
|
+
// Remove surrounding quotes if present
|
|
51
|
+
const cleanPrompt = prompt.startsWith('"') && prompt.endsWith('"')
|
|
52
|
+
? prompt.slice(1, -1)
|
|
53
|
+
: prompt;
|
|
54
|
+
|
|
55
|
+
if (!cleanPrompt) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
return await summarize(cleanPrompt, context);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (context?.__verbose) {
|
|
63
|
+
console.error('💥 [GroqLLM] Error:', error.message);
|
|
64
|
+
}
|
|
65
|
+
// Re-throw to let workflow handle failure
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
49
68
|
}
|
|
50
|
-
|
|
69
|
+
|
|
70
|
+
// ✅ Critical: return undefined, not null
|
|
71
|
+
return undefined;
|
|
51
72
|
};
|
|
73
|
+
|
|
74
|
+
// ✅ Required for O-Lang allowlist policy
|
|
75
|
+
module.exports.resolverName = 'llm-groq';
|