INNER CODE UNIT · JavaScript

existingLeaf

eugeneyan/obsidian-copilot · plugin/main.js:52

    const existingLeaf = this.app.workspace.getLeavesOfType("markdown").find((leaf) => leaf.view.file && leaf.view.file.path === file.path);
    if (existingLeaf) {
      existingLeaf.view.editor.setValue(content);
    } else {
      const leaf = this.app.workspace.getLeaf("split", "vertical");
      leaf.openFile(file);
    }
  }
  async queryLLM(messages, model, 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,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…