Files
Doctor_Patient_Summary/test_diarize_llm.js

51 lines
2.3 KiB
JavaScript

require('dotenv').config();
async function test() {
const transcript = 'हा डॉक्टर बोलसेन इकडे हे गाठ आले त्या हे गाठ झाल्यानंतर मला मुलगा राहिला म्हणजे प्रेग्नेंसी राहिली प्रेग्नेंसी झाल्यानंतर एक चार पाच वर्षांनी पिशवी काढली म्हणजे गाठच झाली होती ती पिशवी वरती अशी हा मग पिशवी काढून टाकली आणि परत आता हे चार पाच वर्षांनी परत गाठ आली आहे.';
const prompt = `You are an expert medical conversation diarizer for Indian languages (Marathi, Hindi, English).
TASK: Identify WHO said WHAT in this doctor-patient conversation.
STRICT RULES:
1. Output ONLY plain text dialogue. No markdown, no explanation.
2. Format each line exactly as:
Doctor: <exact words>
Patient: <exact words>
3. "Doctor" = person who asks questions, examines, diagnoses, prescribes medicine.
4. "Patient" = person who describes symptoms, answers questions.
5. Group all consecutive sentences spoken by the same person into a single paragraph. Do not falsely alternate speakers.
6. Do NOT change, translate, summarize, or rephrase the original text. Keep the exact words.
EXAMPLE:
Input: "काय त्रास होत आहे? डोके दुखत आहे. किती दिवसांपासून? तीन दिवस."
Output:
Doctor: काय त्रास होत आहे?
Patient: डोके दुखत आहे.
Doctor: किती दिवसांपासून?
Patient: तीन दिवस.
NOW DIARIZE THIS:
${transcript}`;
const r = await fetch('https://api.sarvam.ai/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-subscription-key': process.env.SARVAM_API_KEY
},
body: JSON.stringify({
model: 'sarvam-105b',
temperature: 0.1,
max_tokens: 2000,
messages: [{role:'user', content:prompt}]
})
});
const data = await r.json();
console.log(JSON.stringify(data, null, 2));
}
test();