Skip to content

Commit

Permalink
Merge pull request #139 from Descendre/feature/#138
Browse files Browse the repository at this point in the history
update: custom prompt mode
  • Loading branch information
Hinata0607 authored Sep 5, 2024
2 parents 8851ca0 + c841d32 commit c0bba59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/hooks/context/useChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const useChat = (): UseChatProps => {
setIsLogSelect,
setSelectedContent,
characters,
isCustom,
customText,
} = context;

const handleGetChatRooms = async (): Promise<void> => {
Expand Down Expand Up @@ -224,6 +226,7 @@ export const useChat = (): UseChatProps => {
const messages = generateMessages({
content: content,
character: currentCharacter.name,
...(isCustom ? { custom: customText } : {}),
});
const chatGPTResponse = await handleChatGPT({
model: 'gpt-4o-mini',
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/utils/HenerateMessagesProps.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface HenerateMessagesProps {
content: string;
character: string;
custom?: string | null;
}

export interface GPTMessageRequestProps {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/generateMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ import { GPTMessageRequestProps, HenerateMessagesProps } from '@/interfaces';
export const generateMessages = ({
content,
character,
custom,
}: HenerateMessagesProps): GPTMessageRequestProps[] => {
const customContent = custom
? `
しかし以下の設定を優先的に守ってください。
${custom}
`
: '';

const messages = [
{
role: 'system',
content: `
基本設定は以下の通りです。
あなたはvoicevoxの${character}です。
記号や英語はあまり使わないように。
あまり長文にならないように。
喋り方も${character}のように振る舞うこと。
${customContent}
`,
},
{
Expand Down

0 comments on commit c0bba59

Please sign in to comment.