Skip to content

Commit

Permalink
feat: add setting for add specific tags to AI-generated content
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonn committed Apr 26, 2023
1 parent 2ac00e9 commit 9500e57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import settings, {
import { getBlockContent } from './utils';

function main() {
const { apiKey, model, customPrompts } = logseq.settings as unknown as ISettings;
const { apiKey, model, customPrompts, tag } =
logseq.settings as unknown as ISettings;
const prompts = [...Object.values(presetPrompts)];

if (customPrompts.enable) {
Expand Down Expand Up @@ -55,14 +56,19 @@ function main() {
case PromptOutputType.property:
await logseq.Editor.updateBlock(
uuid,
block?.content + `\n ${name.toLowerCase()}:: ${content}`,
block?.content +
` #${tag}\n ${name.toLowerCase()}:: ${content}`,
);
break;
case PromptOutputType.insert:
await logseq.Editor.updateBlock(
uuid,
block?.content + ` #${tag}`,
);
await logseq.Editor.insertBlock(uuid, content);
break;
case PromptOutputType.replace:
await logseq.Editor.updateBlock(uuid, content);
await logseq.Editor.updateBlock(uuid, `${content} #${tag}`);
break;
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IPromptOptions {
export interface ISettings {
apiKey: string;
model: string;
tag: string;
customPrompts: {
enable: boolean;
prompts: IPromptOptions[];
Expand All @@ -36,6 +37,13 @@ const settings: SettingSchemaDesc[] = [
description: 'Choose the OpenAI model (e.g., "gpt-3.5-turbo").',
default: 'gpt-3.5-turbo',
},
{
key: 'tag',
type: 'string',
title: 'Tag',
description: 'Add specific tags to AI-generated content',
default: '[[🤖]]'
},
{
key: 'customPrompts',
type: 'object',
Expand Down

0 comments on commit 9500e57

Please sign in to comment.