MCPcopy
hub / github.com/obsidianmd/obsidian-help / callLLM

Function callLLM

scripts/translate-locale.ts:392–415  ·  view source on GitHub ↗
(config: LLMConfig, systemPrompt: string, userMessage: string)

Source from the content-addressed store, hash-verified

390};
391
392async function callLLM(config: LLMConfig, systemPrompt: string, userMessage: string): Promise<string> {
393 const response = await fetch(config.apiEndpoint, {
394 method: "POST",
395 headers: {
396 "Content-Type": "application/json",
397 "x-api-key": config.apiKey,
398 "anthropic-version": "2023-06-01",
399 },
400 body: JSON.stringify({
401 model: config.model,
402 max_tokens: 16384,
403 system: systemPrompt,
404 messages: [{ role: "user", content: userMessage }],
405 }),
406 });
407
408 if (!response.ok) {
409 const err = await response.text();
410 throw new Error(`LLM API error ${response.status}: ${err}`);
411 }
412
413 const result = await response.json() as { content: Array<{ text: string }> };
414 return result.content[0].text;
415}
416
417const LANGUAGE_NOTES: Record<string, string> = {
418 de: "Use informal 'du' (not formal 'Sie') throughout. This matches the voice used on the Obsidian main website. Use 'du/dir/dein/deine' for second-person address, and informal verb conjugations (e.g. 'kannst du', 'klicke', 'wähle', 'öffne'). Never use 'Sie/Ihnen/Ihr/Ihre'. Target register: calm, practical documentation voice — direct and clear, not chatty or formal.",

Callers 3

translateFileFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected