Files
Doctor_Patient_Summary/test_llm_call.js

45 lines
1.7 KiB
JavaScript

const fs = require('fs');
async function testLLM() {
const partText = "काय त्रास होतोय? नाही ऍक्च्युली डॉक्टर रेगन कडे स्पाइनची सर्जरी करायची आहे फिटनेस सर्टिफिकेट हवं बरं";
const DIARIZE_PROMPT = `You are an expert medical conversation diarizer.
TASK: Identify WHO said WHAT in this short segment of a doctor-patient conversation.
STRICT RULES:
1. Output ONLY a valid JSON array. No markdown, no explanations, no reasoning.
2. Each object must have "speaker" (either "Doctor" or "Patient") and "text" (the exact spoken words).
3. Do not translate. Keep the exact text.
Example Output:
[
{"speaker": "Doctor", "text": "काय त्रास होत आहे?"},
{"speaker": "Patient", "text": "डोके दुखत आहे."}
]
NOW DIARIZE THIS SEGMENT:
${partText}`;
console.log("Sending request to Sarvam...");
const diarizeResp = await fetch('https://api.sarvam.ai/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-subscription-key': 'sk_25ncib43_YUPtWHky8c1lSG2TOrVsdK8K'
},
body: JSON.stringify({
model: 'sarvam-105b',
temperature: 0.1,
max_tokens: 800,
messages: [
{ role: 'system', content: 'You are a helpful JSON API returning only valid JSON.' },
{ role: 'user', content: DIARIZE_PROMPT }
]
})
});
const data = await diarizeResp.json();
console.log(data?.choices?.[0]?.message?.content || JSON.stringify(data));
}
testLLM().catch(console.error);