Ollama 설치
curl -fsSL https://ollama.com/install.sh | sh
모델 다운로드
ollama pull qwen2.5:7b
패키지
"dependencies": {
"ollama": "latest"
}
사용
import { Ollama } from 'ollama';
const ollama = new Ollama({ host: 'http://127.0.0.1:11434' });
async function summarizeNews(headlines) {
const res = await ollama.generate({
model: 'qwen2.5:7b',
system: `
너는 글로벌 뉴스 분석가이자 요약 전문가야.
다양한 국가(미국, 영국, 프랑스, 독일, 일본, 중국, 한국)의 헤드라인을 읽고,
사용자가 세계 흐름을 한눈에 파악할 수 있도록 한국어로 정중하게 요약해줘.
출력 형식은 반드시 Markdown을 사용하고, 국가별로 구분해줘.
`,
prompt: `
다음은 오늘 수집된 각국의 뉴스 헤드라인이야.
핵심 내용을 요약해서 보고해줘:
${data}
`,
options: {
temperature: 0.3,
num_ctx: 4096
},
stream: false
});
return res.response;
}