fix: copilot not working (#3425)

This commit is contained in:
Alex Yang
2023-07-27 17:28:21 -07:00
committed by GitHub
parent aa69a7cad2
commit f9929ebd61
11 changed files with 165 additions and 181 deletions

View File

@@ -1,6 +1,4 @@
import { Button, FlexWrapper, Input } from '@affine/component';
import { SettingRow } from '@affine/component/setting-components';
import { SettingWrapper } from '@affine/component/setting-components';
import { useAtom } from 'jotai';
import { type ReactElement, useCallback } from 'react';
@@ -9,43 +7,28 @@ import { conversationHistoryDBName } from '../core/langchain/message-history';
export const DebugContent = (): ReactElement => {
const [key, setKey] = useAtom(openAIApiKeyAtom);
const desc = (
<>
<span>You can get your API key from </span>
<a
target="_blank"
rel="noreferrer"
href="https://beta.openai.com/account/api-keys"
>
here.
</a>
</>
);
return (
<div>
<SettingWrapper title={'Ai Copilot'}>
<SettingRow name={'openAI API key'} desc={desc}></SettingRow>
<FlexWrapper justifyContent="space-between">
<Input
defaultValue={key ?? undefined}
onChange={useCallback(
(newValue: string) => {
setKey(newValue);
},
[setKey]
)}
/>
<Button
size="large"
onClick={() => {
indexedDB.deleteDatabase(conversationHistoryDBName);
location.reload();
}}
>
{'Clean conversations'}
</Button>
</FlexWrapper>
</SettingWrapper>
<FlexWrapper justifyContent="space-between">
<Input
defaultValue={key ?? undefined}
onChange={useCallback(
(newValue: string) => {
setKey(newValue);
},
[setKey]
)}
/>
<Button
size="large"
onClick={() => {
indexedDB.deleteDatabase(conversationHistoryDBName);
location.reload();
}}
>
{'Clean conversations'}
</Button>
</FlexWrapper>
</div>
);
};