mindcraft/src/models/groq.js

37 lines
796 B
JavaScript
Raw Normal View History

2024-06-18 17:56:04 -07:00
const Groq = require('groq-sdk');
2024-06-18 17:56:49 -07:00
import { getKey } from '../utils/keys.js';
2024-06-18 17:56:04 -07:00
2024-06-18 18:04:21 -07:00
export class Mixtral {
constructor(model_name, url) {
this.model_name = model_name;
this.url = url;
this.groq = new Groq(getKey('GROQ_API_KEY'));
}
}
2024-06-18 17:56:04 -07:00
const groq = new Groq();
2024-06-18 18:04:21 -07:00
async function definitelynotmain() {
2024-06-18 17:56:04 -07:00
const chatCompletion = await groq.chat.completions.create({
"messages": [
{
"role": "system",
"content": "i like grapes"
},
{
"role": "user",
"content": ""
}
],
"model": "mixtral-8x7b-32768",
"temperature": 0.85,
"max_tokens": 8192,
"top_p": 1,
"stream": true,
"stop": null
});
for await (const chunk of chatCompletion) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}