Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/Follow up prompts status #3341

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bugfixes of follow up prompts status, unauthroized error message and …
…rate limit ui
  • Loading branch information
HenryHengZJ committed Oct 11, 2024
commit 4c12846114efaebf2d61a08b9ef44f0983fba0c3
2 changes: 2 additions & 0 deletions packages/components/src/followUpPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const generateFollowUpPrompts = async (
options: ICommonObject
) => {
if (followUpPromptsConfig) {
if (!followUpPromptsConfig.status) return undefined
const providerConfig = followUpPromptsConfig[followUpPromptsConfig.selectedProvider]
if (!providerConfig) return undefined
const credentialId = providerConfig.credentialId as string
const credentialData = await getCredentialData(credentialId ?? '', options)
const followUpPromptsPrompt = providerConfig.prompt.replace('{history}', apiMessageContent)
Expand Down
8 changes: 7 additions & 1 deletion packages/server/src/controllers/predictions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction)
throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Chatflow ${req.params.id} not found`)
}
let isDomainAllowed = true
let unauthorizedOriginError = 'This site is not allowed to access this chatbot'
logger.info(`[server]: Request originated from ${req.headers.origin || 'UNKNOWN ORIGIN'}`)
if (chatflow.chatbotConfig) {
const parsedConfig = JSON.parse(chatflow.chatbotConfig)
// check whether the first one is not empty. if it is empty that means the user set a value and then removed it.
const isValidAllowedOrigins = parsedConfig.allowedOrigins?.length && parsedConfig.allowedOrigins[0] !== ''
unauthorizedOriginError = parsedConfig.allowedOriginsError || 'This site is not allowed to access this chatbot'
if (isValidAllowedOrigins && req.headers.origin) {
const originHeader = req.headers.origin
const origin = new URL(originHeader).host
Expand Down Expand Up @@ -81,7 +83,11 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction)
return res.json(apiResponse)
}
} else {
throw new InternalFlowiseError(StatusCodes.UNAUTHORIZED, `This site is not allowed to access this chatbot`)
const isStreamingRequested = req.body.streaming === 'true' || req.body.streaming === true
if (isStreamingRequested) {
return res.status(StatusCodes.FORBIDDEN).send(unauthorizedOriginError)
}
throw new InternalFlowiseError(StatusCodes.FORBIDDEN, unauthorizedOriginError)
}
} catch (error) {
next(error)
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/ui-component/extended/RateLimit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RateLimit = () => {
const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))

const [rateLimitStatus, setRateLimitStatus] = useState(false)
const [rateLimitStatus, setRateLimitStatus] = useState(apiConfig?.rateLimit?.status !== undefined ? apiConfig.rateLimit.status : false)
const [limitMax, setLimitMax] = useState(apiConfig?.rateLimit?.limitMax ?? '')
const [limitDuration, setLimitDuration] = useState(apiConfig?.rateLimit?.limitDuration ?? '')
const [limitMsg, setLimitMsg] = useState(apiConfig?.rateLimit?.limitMsg ?? '')
Expand Down
Loading