Basic usage
Basic usage
Send a conversation to a model to generate text from text and audio
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('llava-hf/LLaVA-NeXT-Video-7B-hf');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this video"
},
{
"type": "video",
"url": "https://huggingface.co/datasets/raushan-testing-hf/videos-test/resolve/main/sample_demo_1.mp4"
}
]
}
];
// send to the model
const { error, output } = await model.run(input);
// observe the output
console.log({ error, output });
Add params
Add params
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('llava-hf/LLaVA-NeXT-Video-7B-hf');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this video"
},
{
"type": "video",
"url": "https://huggingface.co/datasets/raushan-testing-hf/videos-test/resolve/main/sample_demo_1.mp4"
}
]
}
];
// provide the model with params
const params = {
"temperature": 0
};
// send to the model
const { error, output } = await model.run(input, params);
// observe the output
console.log({ error, output });
Stream text
Stream text
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('llava-hf/LLaVA-NeXT-Video-7B-hf');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this video"
},
{
"type": "video",
"url": "https://huggingface.co/datasets/raushan-testing-hf/videos-test/resolve/main/sample_demo_1.mp4"
}
]
}
];
// send to the model
const { error, output } = await model.run(input);
// observe the output
console.log({ error, output });
Add params + Stream text
Add params + Stream text
Copy
import Bytez from 'bytez.js';
// insert your key
const sdk = new Bytez('BYTEZ_KEY');
// choose your model
const model = sdk.model('llava-hf/LLaVA-NeXT-Video-7B-hf');
// provide the model with input
const input = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this video"
},
{
"type": "video",
"url": "https://huggingface.co/datasets/raushan-testing-hf/videos-test/resolve/main/sample_demo_1.mp4"
}
]
}
];
// provide the model with params
const params = {
"temperature": 0
};
// set streaming to "true"
const stream = true;
// send to the model
const readStream = await model.run(messages, params, stream);
let text = '';
for await (const chunk of readStream) {
text += chunk;
console.log(chunk);
}
// observe the output
console.log({ text });