Fix/speech to text button (#947)

This commit is contained in:
zxhlyh
2023-08-22 14:55:20 +08:00
committed by GitHub
parent a3aba7a9aa
commit b185a70c21
8 changed files with 35 additions and 246 deletions

View File

@@ -38,7 +38,7 @@ const Config: FC = () => {
setSpeechToTextConfig,
} = useContext(ConfigContext)
const isChatApp = mode === AppType.chat
const { currentProvider } = useProviderContext()
const { speech2textDefaultModel } = useProviderContext()
const promptTemplate = modelConfig.configs.prompt_template
const promptVariables = modelConfig.configs.prompt_variables
@@ -90,7 +90,7 @@ const Config: FC = () => {
},
})
const hasChatConfig = isChatApp && (featureConfig.openingStatement || featureConfig.suggestedQuestionsAfterAnswer || (featureConfig.speechToText && currentProvider?.provider_name === 'openai'))
const hasChatConfig = isChatApp && (featureConfig.openingStatement || featureConfig.suggestedQuestionsAfterAnswer || (featureConfig.speechToText && !!speech2textDefaultModel))
const hasToolbox = false
const [showAutomatic, { setTrue: showAutomaticTrue, setFalse: showAutomaticFalse }] = useBoolean(false)
@@ -120,7 +120,7 @@ const Config: FC = () => {
isChatApp={isChatApp}
config={featureConfig}
onChange={handleFeatureChange}
showSpeechToTextItem={currentProvider?.provider_name === 'openai'}
showSpeechToTextItem={!!speech2textDefaultModel}
/>
)}
{showAutomatic && (
@@ -160,7 +160,7 @@ const Config: FC = () => {
}
}
isShowSuggestedQuestionsAfterAnswer={featureConfig.suggestedQuestionsAfterAnswer}
isShowSpeechText={featureConfig.speechToText && currentProvider?.provider_name === 'openai'}
isShowSpeechText={featureConfig.speechToText && !!speech2textDefaultModel}
/>
)
}

View File

@@ -52,7 +52,7 @@ const Debug: FC<IDebug> = ({
modelConfig,
completionParams,
} = useContext(ConfigContext)
const { currentProvider } = useProviderContext()
const { speech2textDefaultModel } = useProviderContext()
const [chatList, setChatList, getChatList] = useGetState<IChatItem[]>([])
const chatListDomRef = useRef<HTMLDivElement>(null)
useEffect(() => {
@@ -390,7 +390,7 @@ const Debug: FC<IDebug> = ({
}}
isShowSuggestion={doShowSuggestion}
suggestionList={suggestQuestions}
isShowSpeechToText={speechToTextConfig.enabled && currentProvider?.provider_name === 'openai'}
isShowSpeechToText={speechToTextConfig.enabled && !!speech2textDefaultModel}
/>
</div>
</div>