Skip to content

Commit

Permalink
HW10
Browse files Browse the repository at this point in the history
  • Loading branch information
C10H8Nai committed Jun 6, 2024
1 parent dc6108e commit db0ee9c
Show file tree
Hide file tree
Showing 2,301 changed files with 682,364 additions and 10 deletions.
154 changes: 154 additions & 0 deletions html/groq/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions html/groq/groq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
let key = "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";

async function groqChat(q) {
const chatCompletion = await fetch("https://api.groq.com/openai/v1/chat/completions",
{
body: JSON.stringify({
"messages": [
{
"role": "user",
"content": q
}
],
"model": "llama3-70b-8192",
"temperature": 1,
"max_tokens": 1024,
"top_p": 1,
"stream": false,
"stop": null
}),
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${key}`,
}
});

const chatData = await chatCompletion.json()
console.log(chatData.choices[0].message.content);
return chatData.choices[0].message.content;
}


async function chat() {
let q = document.getElementById('question');
let a = document.getElementById('answer');
q.innerText = '詢問llama3-70b中,請稍等幾秒鐘...';
let answer = await groqChat(q.value);
a.innerText = answer;
};

Empty file.
1 change: 1 addition & 0 deletions html/groq/node_modules/.deno/.deno.lock.poll

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added html/groq/node_modules/.deno/.setup-cache.bin
Binary file not shown.
Empty file.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db0ee9c

Please sign in to comment.