update JavaScript openai client to demonstrate both Hermes and Qwen with both streaming and non-streaming modes
This commit is contained in:
parent
df3d76738e
commit
8841bacb0b
1 changed files with 33 additions and 2 deletions
|
|
@ -21,13 +21,44 @@ const hermesResponse = await hermesClient.chat.completions.create({
|
|||
|
||||
console.log(`Response: ${hermesResponse.choices[0].message.content}\n`);
|
||||
|
||||
// Streaming chat with Qwen
|
||||
console.log('=== Streaming Chat (Qwen) ===');
|
||||
// Streaming chat with Hermes
|
||||
console.log('=== Streaming Chat (Hermes) ===');
|
||||
const hermesStream = await hermesClient.chat.completions.create({
|
||||
model: 'adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic',
|
||||
messages: [
|
||||
{ role: 'user', content: 'Explain quantum entanglement in one sentence.' }
|
||||
],
|
||||
temperature: 0.5,
|
||||
max_tokens: 150,
|
||||
stream: true
|
||||
});
|
||||
|
||||
process.stdout.write('Response: ');
|
||||
for await (const chunk of hermesStream) {
|
||||
process.stdout.write(chunk.choices[0]?.delta?.content || '');
|
||||
}
|
||||
console.log('\n');
|
||||
|
||||
// Non-streaming chat with Qwen
|
||||
console.log('=== Non-Streaming Chat (Qwen) ===');
|
||||
const qwenClient = new OpenAI({
|
||||
apiKey: 'dummy-key',
|
||||
baseURL: 'https://qwen.ai.unturf.com/v1'
|
||||
});
|
||||
|
||||
const qwenResponse = await qwenClient.chat.completions.create({
|
||||
model: 'hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M',
|
||||
messages: [
|
||||
{ role: 'user', content: 'Write a JavaScript function to check if a number is prime' }
|
||||
],
|
||||
temperature: 0.5,
|
||||
max_tokens: 150
|
||||
});
|
||||
|
||||
console.log(`Response: ${qwenResponse.choices[0].message.content}\n`);
|
||||
|
||||
// Streaming chat with Qwen
|
||||
console.log('=== Streaming Chat (Qwen) ===');
|
||||
const qwenStream = await qwenClient.chat.completions.create({
|
||||
model: 'hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M',
|
||||
messages: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue