mirror of
https://github.com/fbarrca/obsidian-inlineAI.git
synced 2026-07-22 11:50:24 +00:00
- 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
29 lines
780 B
TypeScript
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
|
|
);
|
|
}
|