Skip to content

Commit

Permalink
Rename queryOpenAI to queryAI
Browse files Browse the repository at this point in the history
  • Loading branch information
justyns committed Jul 21, 2024
1 parent 10563db commit 4afab67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 5 additions & 11 deletions sbai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,25 +495,19 @@ export async function promptAndGenerateImage() {
/**
* Function for use in templates, doesn't stream responses or insert anything into the editor - just returns the response
*/
export async function queryOpenAI(
export async function queryAI(
userPrompt: string,
systemPrompt?: string,
): Promise<string> {
try {
await initIfNeeded();
const messages: ChatMessage[] = [];
const defaultSystemPrompt =
"You are an AI note assistant helping to render content for a note. Please follow user instructions and keep your response short and concise.";
messages.push({
role: "system",
content: systemPrompt || defaultSystemPrompt,
});
messages.push({ role: "user", content: userPrompt });

const response = await currentAIProvider.chatWithAI({
messages: messages,
stream: false,
});
const response = await currentAIProvider.singleMessageChat(
userPrompt,
systemPrompt || defaultSystemPrompt,
);
return response;
} catch (error) {
console.error("Error querying OpenAI:", error);
Expand Down
4 changes: 2 additions & 2 deletions silverbullet-ai.plug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ functions:
path: src/prompts.ts:aiPromptSlashComplete
events:
- slash:complete
queryOpenAI:
path: sbai.ts:queryOpenAI
queryAI:
path: sbai.ts:queryAI
reloadConfig:
path: sbai.ts:reloadConfig
events:
Expand Down

0 comments on commit 4afab67

Please sign in to comment.