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

Feature: Follow-up Prompts #3280

Merged
merged 47 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
adf051b
Add migrations - add follow up prompts column to chatflow and chat me…
0xi4o Sep 27, 2024
0cde2d0
Add configuration tab for follow-up prompts
0xi4o Sep 27, 2024
e597de7
Add follow up prompts functionality
0xi4o Sep 27, 2024
75b9f0a
Pin zod version in components - this was causing a type error with st…
0xi4o Sep 27, 2024
15faddc
Generate follow up prompts if enabled and return it in stream, respon…
0xi4o Sep 27, 2024
5f6f3ea
Show follow up prompts after getting response
0xi4o Sep 27, 2024
7cc2df4
Add google gen ai for generating follow up prompts and fix issues
0xi4o Sep 30, 2024
592d344
Add config for google gen ai and update model options
0xi4o Sep 30, 2024
72778f7
Update follow-up prompts ui and styles
0xi4o Sep 30, 2024
34c73fe
Release/2.1.0 (#3204)
HenryHengZJ Sep 17, 2024
3118de6
Chore/update flowise embed version to 2.0.0 (#3205)
HenryHengZJ Sep 17, 2024
11b85bb
Bugfix/CodeInterpreter E2B Credential (#3206)
HenryHengZJ Sep 17, 2024
24d164b
Release/2.1.0 (#3207)
HenryHengZJ Sep 17, 2024
14f4589
Bugfix/Add artifacts migration script to other database types (#3210)
HenryHengZJ Sep 17, 2024
1e28a71
Release/2.1.1 (#3213)
HenryHengZJ Sep 18, 2024
c538ee9
Bugfix/Add header to allow sse on nginx (#3214)
HenryHengZJ Sep 18, 2024
ca287c9
Bugfix/remove invalid markdown (#3219)
HenryHengZJ Sep 19, 2024
a01df37
Correct "as" casing (#3216)
dillfrescott Sep 19, 2024
2cb7352
chore: update unstructured API url and doc reference (#3224)
cragwolfe Sep 20, 2024
79031bf
Feature/add ability to specify dynamic metadata to jsonlines (#3238)
HenryHengZJ Sep 23, 2024
d64e8c0
Bugfix/Buffer Memory for Anthropic (#3242)
HenryHengZJ Sep 24, 2024
1ae4a1c
Added env vars to ui and api URL (#3141)
patrickreinan Sep 24, 2024
bd542e5
Added 1-click deployment link for Alibaba Cloud. (#3251)
yehanyh Sep 25, 2024
d2577e5
Chore/Groq Llama3.2 (#3255)
HenryHengZJ Sep 25, 2024
a80ba4b
Bugfix/Prevent streaming of chatflow tool and chain tool (#3257)
HenryHengZJ Sep 25, 2024
7f82587
Bugfix/Enable Custom Tool Optional Input Schema (#3258)
HenryHengZJ Sep 26, 2024
a264b12
Bugfix/Searxng tool not working (#3263)
HenryHengZJ Sep 26, 2024
2a64343
LunaryAI automatic Thread and User tracking (#3233)
vincelwt Sep 26, 2024
e4e7de5
feat: enable autofocus to the `new chatflow title` to improve usabili…
rhumbertgz Sep 26, 2024
3723a76
feat: save a new Chatflow when the `ENTER` key is pressed (#3261)
rhumbertgz Sep 26, 2024
1e2d480
feat: save Chatflow title when the `ENTER` key is pressed or discard …
rhumbertgz Sep 26, 2024
81a4095
feat: enable autofocus to the `edit chatflow title` field to improve …
rhumbertgz Sep 26, 2024
6e45410
feat: add search keyboard shortcut based on the current platform (#3267)
rhumbertgz Sep 26, 2024
4470608
feat: highlight valid/invalid connection between nodes (#3266)
rhumbertgz Sep 26, 2024
a565da5
Bugfix/add fixes for search of view header (#3271)
HenryHengZJ Sep 26, 2024
788f807
fix: warning when passing a boolean to border property of a Card (#3275)
rhumbertgz Sep 27, 2024
8e30669
feat: add shortcut text hint to the search field (#3269)
rhumbertgz Sep 27, 2024
78f55df
fix: warning when a non-boolean values was used to set `checked` prop…
rhumbertgz Sep 27, 2024
4c138dc
Bugfix/Throw error to prevent SSE from retrying (#3281)
HenryHengZJ Sep 28, 2024
4c672a4
Pin zod version in components - this was causing a type error with st…
0xi4o Sep 27, 2024
9f36932
Fix conflicts in pnpm lock
0xi4o Sep 30, 2024
8c9d2a9
Fix conflicts
0xi4o Sep 30, 2024
a3f9783
Merge branch 'main' into feature/follow-up-prompts
HenryHengZJ Sep 30, 2024
90aadd9
fix ui changes for follow up prompts
HenryHengZJ Oct 2, 2024
3e1d1bb
Fix button disable state in follow-up prompts configuration
0xi4o Oct 3, 2024
596c7ff
Fix follow-up prompts not showing up for agent flows
0xi4o Oct 3, 2024
73a8994
Show follow up prompts if last message is apiMessage and follow up pr…
0xi4o Oct 3, 2024
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
Prev Previous commit
Next Next commit
Show follow up prompts after getting response
0xi4o committed Sep 27, 2024
commit 5f6f3eae258537865d30e1d384933239f6d6dc63
2 changes: 1 addition & 1 deletion packages/server/src/utils/SSEStreamer.ts
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ export class SSEStreamer implements IServerSideEventStreamer {
metadataJson['memoryType'] = apiResponse.memoryType
}
if (apiResponse.followUpPrompts) {
metadataJson['followUpPrompts'] = apiResponse.followUpPrompts
metadataJson['followUpPrompts'] = JSON.parse(apiResponse.followUpPrompts)
}
if (Object.keys(metadataJson).length > 0) {
this.streamCustomEvent(chatId, 'metadata', metadataJson)
26 changes: 26 additions & 0 deletions packages/ui/src/ui-component/cards/FollowUpPromptsCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Box from '@mui/material/Box'
import PropTypes from 'prop-types'
import { Chip } from '@mui/material'
import './StarterPromptsCard.css'

const FollowUpPromptsCard = ({ isGrid, followUpPrompts, sx, onPromptClick }) => {
return (
<Box
className={'button-container'}
sx={{ width: '100%', maxWidth: isGrid ? 'inherit' : '400px', p: 1.5, display: 'flex', gap: 1, ...sx }}
>
{followUpPrompts.map((fp, index) => (
<Chip label={fp} className={'button'} key={index} onClick={(e) => onPromptClick(fp, e)} />
))}
</Box>
)
}

FollowUpPromptsCard.propTypes = {
isGrid: PropTypes.bool,
followUpPrompts: PropTypes.array,
sx: PropTypes.object,
onPromptClick: PropTypes.func
}

export default FollowUpPromptsCard
31 changes: 31 additions & 0 deletions packages/ui/src/views/chatmessage/ChatMessage.jsx
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackba
// Utils
import { isValidURL, removeDuplicateURL, setLocalStorageChatflow, getLocalStorageChatflow } from '@/utils/genericHelper'
import useNotifier from '@/utils/useNotifier'
import FollowUpPromptsCard from '@/ui-component/cards/FollowUpPromptsCard'

const messageImageStyle = {
width: '128px',
@@ -202,6 +203,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
const [isLeadSaving, setIsLeadSaving] = useState(false)
const [isLeadSaved, setIsLeadSaved] = useState(false)

// follow-up prompts
const [followUpPromptsStatus, setFollowUpPromptsStatus] = useState(false)
const [followUpPrompts, setFollowUpPrompts] = useState([])

// drag & drop and file input
const imgUploadRef = useRef(null)
const fileUploadRef = useRef(null)
@@ -627,6 +632,12 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
handleSubmit(undefined, promptStarterInput)
}

const handleFollowUpPromptClick = async (promptStarterInput) => {
setUserInput(promptStarterInput)
setFollowUpPrompts([])
handleSubmit(undefined, promptStarterInput)
}

const handleActionClick = async (elem, action) => {
setUserInput(elem.label)
setMessages((prevMessages) => {
@@ -664,6 +675,11 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
return allMessages
})
}

if (data.followUpPrompts) {
const followUpPrompts = JSON.parse(data.followUpPrompts)
setFollowUpPrompts(followUpPrompts)
}
}

// Handle form submission
@@ -1012,6 +1028,10 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
})
}
}

if (config.followUpPrompts) {
setFollowUpPromptsStatus(config.followUpPrompts.status)
}
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1969,6 +1989,17 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
</div>
)}

{messages && messages.length > 2 && followUpPromptsStatus && followUpPrompts.length > 0 && (
<div style={{ position: 'relative' }}>
<FollowUpPromptsCard
sx={{ bottom: previews && previews.length > 0 ? 70 : 0 }}
followUpPrompts={followUpPrompts || []}
onPromptClick={handleFollowUpPromptClick}
isGrid={isDialog}
/>
</div>
)}

<Divider sx={{ width: '100%' }} />

<div className='center'>