mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-30 17:34:23 +03:00
34 lines
913 B
TypeScript
34 lines
913 B
TypeScript
import { Button, Input } from '@affine/component';
|
|
import type { PluginUIAdapter } from '@toeverything/plugin-infra/type';
|
|
import { useAtom } from 'jotai';
|
|
import { useCallback } from 'react';
|
|
|
|
import { openAIApiKeyAtom } from '../core/hooks';
|
|
import { conversationHistoryDBName } from '../core/langchain/message-history';
|
|
|
|
export const DebugContent: PluginUIAdapter['debugContent'] = () => {
|
|
const [key, setKey] = useAtom(openAIApiKeyAtom);
|
|
return (
|
|
<div>
|
|
<span>OpenAI API Key:</span>
|
|
<Input
|
|
defaultValue={key ?? undefined}
|
|
onChange={useCallback(
|
|
(newValue: string) => {
|
|
setKey(newValue);
|
|
},
|
|
[setKey]
|
|
)}
|
|
/>
|
|
<Button
|
|
onClick={() => {
|
|
indexedDB.deleteDatabase(conversationHistoryDBName);
|
|
location.reload();
|
|
}}
|
|
>
|
|
Clean conversations
|
|
</Button>
|
|
</div>
|
|
);
|
|
};
|