import { streamConfidentialChat } from "@/lib/confidential-chat";
import { createAtlsFetch } from "@phala/dcap-qvl-web";
// Create aTLS fetch with attestation verification
const atlasFetch = await createAtlsFetch({
attestationServiceUrl: "https://your-attestation-service.com",
verifyQuote: true,
});
// Stream chat completions
const stream = streamConfidentialChat(
{
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is Intel TDX?" },
],
model: "Qwen/Qwen2.5-32B-Instruct",
temperature: 0.7,
max_tokens: 4096,
stream: true,
},
{
provider: {
baseUrl: "https://your-provider.com",
apiKey: "your-bearer-token",
},
fetchImpl: atlasFetch, // Use aTLS fetch
}
);
// Process stream
for await (const chunk of stream) {
if (chunk.type === "delta") {
console.log(chunk.content);
} else if (chunk.type === "error") {
console.error("Error:", chunk.error);
} else if (chunk.type === "done") {
console.log("Complete:", chunk.content);
console.log("Finish reason:", chunk.finish_reason);
}
}