mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
mess
This commit is contained in:
parent
1de106be19
commit
a6359afa8a
1 changed files with 53 additions and 17 deletions
|
@ -7,27 +7,63 @@ export class Mixtral {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.groq = new Groq(getKey('GROQ_API_KEY'));
|
this.groq = new Groq(getKey('GROQ_API_KEY'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendRequest(turns, systemMessage, stop_seq="***") {
|
||||||
|
let messages = [{"role": "system", "content": systemMessage}].concat(turns);
|
||||||
|
let res = null;
|
||||||
|
try {
|
||||||
|
console.log("Awaiting Groq response...");
|
||||||
|
let completion = await this.groq.chat.completions.create({
|
||||||
|
"messages": messages,
|
||||||
|
"model": this.model_name || "mixtral-8x7b-32768",
|
||||||
|
"temperature": 0.85,
|
||||||
|
"max_tokens": 8192,
|
||||||
|
"top_p": 1,
|
||||||
|
"stream": true,
|
||||||
|
"stop": stop_seq
|
||||||
|
});
|
||||||
|
|
||||||
|
let temp_res = "";
|
||||||
|
for await (const chunk of completion) {
|
||||||
|
temp_res += chunk.choices[0]?.delta?.content || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
res = temp_res;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
res = "My brain just kinda stopped working. Try again.";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
async embed(text) {
|
||||||
|
/* GPT's embed:
|
||||||
|
const embedding = await this.openai.embeddings.create({
|
||||||
|
model: this.model_name || "text-embedding-ada-002",
|
||||||
|
input: text,
|
||||||
|
encoding_format: "float",
|
||||||
|
});
|
||||||
|
return embedding.data[0].embedding;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// lol no embeddings for u
|
||||||
|
// l
|
||||||
|
console.log("big oof, embeds on groq dont is not thing");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const groq = new Groq();
|
|
||||||
async function definitelynotmain() {
|
async function definitelynotmain() {
|
||||||
const chatCompletion = await groq.chat.completions.create({
|
const chatCompletion = await groq.chat.completions.create({
|
||||||
"messages": [
|
"messages": "",
|
||||||
{
|
|
||||||
"role": "system",
|
|
||||||
"content": "i like grapes"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": ""
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"model": "mixtral-8x7b-32768",
|
"model": "mixtral-8x7b-32768",
|
||||||
"temperature": 0.85,
|
"temperature": 0.85,
|
||||||
"max_tokens": 8192,
|
"max_tokens": 8192,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"stream": true,
|
"stream": true,
|
||||||
"stop": null
|
"stop": "***"
|
||||||
});
|
});
|
||||||
|
|
||||||
for await (const chunk of chatCompletion) {
|
for await (const chunk of chatCompletion) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue