@o-lang/llm-groq 1.0.0
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 +36 -0
- package/npmignore +7 -0
- package/package.json +18 -0
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @o-lang/llm-groq
|
|
2
|
+
try { require('dotenv').config(); } catch {}
|
|
3
|
+
|
|
4
|
+
const Groq = require('groq-sdk');
|
|
5
|
+
const GROQ_API_KEY = process.env.GROQ_API_KEY;
|
|
6
|
+
const groq = GROQ_API_KEY ? new Groq({ apiKey: GROQ_API_KEY }) : null;
|
|
7
|
+
|
|
8
|
+
async function summarize(prompt) {
|
|
9
|
+
if (!groq) {
|
|
10
|
+
throw new Error('GROQ_API_KEY is required but not set');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const response = await groq.chat.completions.create({
|
|
14
|
+
messages: [{ role: 'user', content: prompt }],
|
|
15
|
+
model: 'llama-3.1-8b-instant',
|
|
16
|
+
temperature: 0.3,
|
|
17
|
+
max_tokens: 250,
|
|
18
|
+
top_p: 0.9
|
|
19
|
+
});
|
|
20
|
+
return response.choices[0].message.content.trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = async (action, context) => {
|
|
24
|
+
if (action.startsWith('Ask ')) {
|
|
25
|
+
const toIndex = action.indexOf(' to "');
|
|
26
|
+
if (toIndex === -1) return null;
|
|
27
|
+
|
|
28
|
+
const start = toIndex + 5;
|
|
29
|
+
const end = action.lastIndexOf('"');
|
|
30
|
+
if (end <= start) return null;
|
|
31
|
+
|
|
32
|
+
let prompt = action.slice(start, end).replace(/\\n/g, '\n');
|
|
33
|
+
return await summarize(prompt);
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
package/npmignore
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@o-lang/llm-groq",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "O-Lang resolver for Groq (Llama 3.1) LLM",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"keywords": ["olang", "groq", "llm", "resolver", "ai", "agent", "governance"],
|
|
8
|
+
"author": "O-lang team <info@workfily.com.com>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/o-lang/resolver-llm-groq.git"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"groq-sdk": "^0.5.0",
|
|
16
|
+
"dotenv": "^16.4.5"
|
|
17
|
+
}
|
|
18
|
+
}
|