fbarrca_obsidian-inlineAI/src/api.ts
FBarrca 5562c50620 Made the connected InlineAI use the new Diff API
- Update TooltipWidget to accept app instance and replace selected text with API response
- Modify callApi to utilize fine-grained conflict generation
- Refactor cursorTooltipExtension to pass app instance for improved tooltip handling
2024-10-27 21:24:04 +01:00

29 lines
780 B
TypeScript

// api.ts
import ollama from "ollama";
import {
generateFineGrainedConflictWithinLine,
generateFineGrainedConflictWithinLineString,
} from "./helpers/conflictMarkers";
export async function callApi(
content: string,
context: string
): Promise<string> {
const response = await ollama.chat({
model: "llama3.2",
messages: [
{
role: "system",
content:
"Reply to the user request, do not add any intro messages or any alternative outputs, just do one example of what you are told",
},
{ role: "user", content: "```" + context + "\n" + content + "```" },
],
});
console.log(
generateFineGrainedConflictWithinLine(context, response.message.content)
);
return generateFineGrainedConflictWithinLineString(
context,
response.message.content
);
}