diff --git a/backend-python/routes/completion.py b/backend-python/routes/completion.py index 99a7bc7..b36a10c 100644 --- a/backend-python/routes/completion.py +++ b/backend-python/routes/completion.py @@ -25,7 +25,7 @@ class ChatCompletionBody(ModelConfigBody): messages: List[Message] model: str = "rwkv" stream: bool = False - stop: str | List[str] = None + stop: Union[str, List[str]] = None class Config: schema_extra = { @@ -47,7 +47,7 @@ class CompletionBody(ModelConfigBody): prompt: Union[str, List[str]] model: str = "rwkv" stream: bool = False - stop: str | List[str] = None + stop: Union[str, List[str]] = None class Config: schema_extra = { diff --git a/backend-python/utils/rwkv.py b/backend-python/utils/rwkv.py index 955fa19..8e4ccae 100644 --- a/backend-python/utils/rwkv.py +++ b/backend-python/utils/rwkv.py @@ -3,7 +3,7 @@ import os import pathlib import copy import re -from typing import Dict, Iterable, List, Tuple +from typing import Dict, Iterable, List, Tuple, Union from utils.log import quick_log from fastapi import HTTPException from pydantic import BaseModel, Field @@ -213,7 +213,7 @@ class AbstractRWKV(ABC): return state[0].tolist(), token_len def generate( - self, prompt: str, stop: str | List[str] = None + self, prompt: str, stop: Union[str, List[str]] = None ) -> Iterable[Tuple[str, str, int, int]]: quick_log(None, None, "Generation Prompt:\n" + prompt) cache = None diff --git a/frontend/src/pages/Composition.tsx b/frontend/src/pages/Composition.tsx index 32a865c..333ffc2 100644 --- a/frontend/src/pages/Composition.tsx +++ b/frontend/src/pages/Composition.tsx @@ -72,7 +72,7 @@ const CompositionPanel: FC = observer(() => { const setSoundFont = async () => { let soundUrl: string; - if (params.useLocalSoundFont) + if (commonStore.compositionParams.useLocalSoundFont) soundUrl = 'assets/sound-font'; else soundUrl = !commonStore.settings.giteeUpdatesSource ? @@ -117,7 +117,7 @@ const CompositionPanel: FC = observer(() => { 'Content-Type': 'application/json' }, body: JSON.stringify({ - 'text': params.prompt.replaceAll(/||/g, '').replaceAll(' ', '').trim() + 'text': commonStore.compositionParams.prompt.replaceAll(/||/g, '').replaceAll(' ', ' ').trim() }) }).then(r => { r.arrayBuffer().then(midi => { @@ -168,7 +168,7 @@ const CompositionPanel: FC = observer(() => { scrollToBottom(); if (e.data.trim() === '[DONE]') { commonStore.setCompositionGenerating(false); - generateNs(params.autoPlay); + generateNs(commonStore.compositionParams.autoPlay); return; } let data;