INNER CODE UNIT · TypeScript
queryLLM
eugeneyan/obsidian-copilot · plugin/main.ts:49
private async queryLLM(messages: Array<any>, model: string, temperature = 0.7) {
return await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.settings.apiKey}`
},
body: JSON.stringify({
'model': model,
'temperature': temperature,
'messages': messages,
'stream': true
})
});
}
async onload() {
await this.loadSettings();