Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Conversation

@ggordonhall
Copy link
Contributor

@ggordonhall ggordonhall commented Jul 25, 2023

This change set allows users to rephrase a query that they've already made and get a new answer. This is similar functionality to ChatGPT, but whereas they persist both the original and rephrased versions of a query (and their successive conversation states), we only store the state after query rephrasing, discarding everything else.

The approach is to add an additional parent_query_id parameter to /answer:

{
	"query": "...",
	"repo_ref": "...",
	"thread_id": "...",
	"parent_query_id": "..."
}

On receiving this payload the backend loads the Conversation by thread_id from SQLite. But, rather than using the entire history as context, we truncate Vec<Exchanges> at the point at which Exchange.id == parent_exchange_id. We only use the history up to parent_query_id as context.

To get this working a major refactor of answer.rs was in order:

  • I removed llm_history. This information is now reproducible from Vec<Exchange> using the history() method which iterates over exchanges and builds a linear sequence of Message
  • I moved paths and code_chunks into Exchange. Each Exchange in a conversation now stores the paths and code_chunks that were discovered by its functions. The conversation-level path and code_chunk state is now reproducible with code_chunks() and paths() methods on Agent. Code chunk canonicalisation now happens on the fly, but this shouldn't give a noticeable performance hit
  • New StartStep and EndStep update types. We use these to tell the frontend that a step has started, and that it's ended. EndStep adds the result of the function to the Exchange
  • Removed the Conversation struct. All functionality is now implemented on Agent.

Todo (this PR)

  • We shouldn't stream intermediate function results to the frontend @calyptobai
  • Implement the frontend logic, passing parent_query_id

Todo (future PR)

  • Move function implementation logic into separate classes
  • Move Agent out of webserver

@ggordonhall ggordonhall requested a review from calyptobai July 26, 2023 09:10
repoName: string;
isLoading?: boolean;
isHistory?: boolean;
onMessageEdit: (parentQueryId: string, i: number) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe some of this logic has changed: 047ccbf

ggordonhall and others added 2 commits July 27, 2023 13:54
This generally reduces response sizes, by removing information that the
front-end does not use.
@calyptobai calyptobai force-pushed the gabriel/blo-1297-rephrase-question branch from 5b80c46 to 4315133 Compare July 27, 2023 23:53
@ggordonhall ggordonhall marked this pull request as ready for review July 28, 2023 07:26
@ggordonhall ggordonhall changed the title Edit previous queries Backend for editing previous queries Aug 1, 2023
@ggordonhall ggordonhall merged commit 0903ad2 into main Aug 1, 2023
@ggordonhall ggordonhall deleted the gabriel/blo-1297-rephrase-question branch August 1, 2023 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants