Skip to content

Commit

Permalink
update: integrate API
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Nov 1, 2024
1 parent 9a6b0a3 commit 02bd4fd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/llama-cpp-server/llama.cpp
Submodule llama.cpp updated 321 files
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export function AssistantMessageSection({
} = useContext(SearchContext)

const [isEditing, setIsEditing] = useState(false)

const [showMoreSource, setShowMoreSource] = useState(false)
const [relevantCodeHighlightIndex, setRelevantCodeHighlightIndex] = useState<
number | undefined
Expand Down Expand Up @@ -213,7 +212,6 @@ export function AssistantMessageSection({
const handleUpdateAssistantMessage = async (message: ConversationMessage) => {
const errorMessage = await onUpdateMessage(message)
if (errorMessage) {
// todo error handling
return errorMessage
} else {
setIsEditing(false)
Expand Down
36 changes: 28 additions & 8 deletions ee/tabby-ui/app/search/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,32 @@ export function Search() {
return activePathname.match(regex)?.[1]?.split('-').pop()
}, [activePathname])

const updateThreadMessage = useMutation(updateThreadMessageMutation)

const onUpdateMessage = async (message: ConversationMessage) => {
const messageIndex = messages.findIndex(o => o.id === message.id)
if (messageIndex > -1) {
// todo 1. call API
// 2. set messages
await setMessages(prev => {
const newMessages = [...prev]
newMessages[messageIndex] = message
return newMessages
if (messageIndex > -1 && threadId) {
const result = await updateThreadMessage({
input: {
threadId,
id: message.id,
content: message.content
}
})
console.log(result)
console.log(result?.data?.updateThreadMessage)
if (result?.data?.updateThreadMessage) {
// 2. set messages
await setMessages(prev => {
const newMessages = [...prev]
newMessages[messageIndex] = message
return newMessages
})
} else {
// FIXME error handling
return result?.error?.message || 'Failed to save'
}
} else {
// FIXME error handling
return 'Failed to save'
}
}
Expand Down Expand Up @@ -891,6 +905,12 @@ const setThreadPersistedMutation = graphql(/* GraphQL */ `
}
`)

const updateThreadMessageMutation = graphql(/* GraphQL */ `
mutation UpdateThreadMessage($input: UpdateMessageInput!) {
updateThreadMessage(input: $input)
}
`)

type HeaderProps = {
threadIdFromURL?: string
streamingDone?: boolean
Expand Down

0 comments on commit 02bd4fd

Please sign in to comment.