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

feat: websearch, tool use, user intent, dynamic retrieval, multiple questions #3424

Merged
merged 26 commits into from
Oct 31, 2024

Conversation

jacopo-chevallard
Copy link
Collaborator

Description

This PR includes far too many new features:

  • detection of user intent (closes CORE-211)
  • treating multiple questions in parallel (closes CORE-212)
  • using the chat history when answering a question (closes CORE-213)
  • filtering of retrieved chunks by relevance threshold (closes CORE-217)
  • dynamic retrieval of chunks (closes CORE-218)
  • enabling web search via Tavily (closes CORE-220)
  • enabling agent / assistant to activate tools when relevant to complete the user task (closes CORE-224)

Also closes CORE-205

Checklist before requesting a review

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented hard-to-understand areas
  • I have ideally added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Screenshots (if appropriate):

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 24, 2024
@jacopo-chevallard jacopo-chevallard marked this pull request as draft October 24, 2024 14:36
@jacopo-chevallard jacopo-chevallard force-pushed the feat/edit_system_prompt_from_conversation_UPDATED branch from 27b1d1b to 5401c01 Compare October 24, 2024 14:46
…rompt_from_conversation branch.

commit fb6c4d5
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 9 12:06:23 2024 +0200

    feat: starting reorganizing modules for simpler maintenance and readability

commit 47130fc
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 9 11:12:30 2024 +0200

    feat: improving prompt

commit 4a42c7e
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 8 15:26:53 2024 +0200

    feat: forcing reasoning via structured output, starting refacto to simplify code logics and maintenability

commit d662bf1
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 8 15:24:15 2024 +0200

    fix: passing temperature parameter to the LLM constructors

commit ac372ed
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 8 15:23:32 2024 +0200

    feat: improving prompts

commit 27d4ca9
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Oct 7 18:35:56 2024 +0200

    feat: making some methods more generic, so that they can be applied to different types of tools

commit 53a6483
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Oct 7 18:34:58 2024 +0200

    feat: improving prompts

commit cdf4d49
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Oct 7 18:00:25 2024 +0200

    feat: using gpt-4o as the default model

commit 355835f
Author: Jacopo Chevallard <[email protected]>
Date:   Fri Oct 4 19:07:55 2024 +0200

    feat: typing the response for structured output

commit 564ee37
Author: Jacopo Chevallard <[email protected]>
Date:   Fri Oct 4 19:06:34 2024 +0200

    feat: progressing with the ability for the system to activate available tools to solve users' tasks

commit 0c9e224
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 16:37:47 2024 +0200

    feat: adding filename to the chunk formatting prompt

commit 60a3081
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 16:25:22 2024 +0200

    feat: simplifying tool categories handling and tools creation

commit 670092f
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 15:52:35 2024 +0200

    refacto: AnsweredQuestions --> TasksCompletion

commit e0b1d1a
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 15:52:07 2024 +0200

    feat: laying the ground to enable passing a list of available tools/nodes that can be activated by the user via prompting

commit 32cb677
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 14:41:09 2024 +0200

    feat: allowing arbitrary configuration keywords to be passed to the Tavily tool constructor

commit 22af59b
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 14:26:50 2024 +0200

    feat: correctly passing the api key for Tavily

commit 776919d
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 14:14:20 2024 +0200

    feat: better structuring the LLM tools configuration, instantiation and binding

commit c6af21d
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 10:58:56 2024 +0200

    feat: correctly parsing and combining citations and followup questions when multiple user questions (and thus multiple model answers) are present

commit f412fc3
Author: Jacopo Chevallard <[email protected]>
Date:   Thu Oct 3 10:57:51 2024 +0200

    feat: improving prompt for tasks/instructions splitting

commit 7242fe5
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 18:08:06 2024 +0200

    fix: fixing check presence of START node

commit 02675df
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 17:55:27 2024 +0200

    fix: including forgotten new module

commit 1937899
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 17:52:35 2024 +0200

    feat: improving prompts

commit ef05824
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 17:52:03 2024 +0200

    fix: fixing errors when the cited_answer tool is not present among the tools called

commit 5896f03
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 17:51:10 2024 +0200

    feat: laying the ground for a more flexible association of tools (and their configurations) to workflow nodes

commit 928f576
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 15:16:02 2024 +0200

    refactor: changing questions into tasks, as user inputs are not always questions

commit f732184
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 15:15:12 2024 +0200

    feat: merging the question/instructions routing prompt/node with the question rephrasing ones

commit e197a49
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 2 11:21:59 2024 +0200

    feat: improving prompt formatting

commit 7ebc410
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 17:20:49 2024 +0200

    fix: fixing nodes behaviours when no user questions / tasks are present (i.e., when the user is only providing system instructions)

commit 1627193
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 17:13:18 2024 +0200

    feat: improving prompts

commit 16f710c
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 16:38:19 2024 +0200

    feat: added nodes and routers for web search, based on Tavily

commit d0ac9b3
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 13:24:41 2024 +0200

    fix: fixing returned chunks (sources), whose list can be modified during the last step (generation) in order to fit into the user-defined maximum context window

commit 1732986
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 13:23:06 2024 +0200

    fix: fixing chat-with-llm mode

commit 42ed087
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 12:55:17 2024 +0200

    feat: introduced node for dynamic chunk retrieval; enforcing the context passed to the LLM for the final answer generation to be at most max_context_tokens

commit 1aa27e1
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Oct 1 12:50:00 2024 +0200

    feat: making the construction of env variable names more robust

commit 63657f4
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Sep 30 18:12:34 2024 +0200

    feat: enable filtering the reranked chunks by their relevance score

commit 31d91ec
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Sep 30 18:11:24 2024 +0200

    fix: ensuring that the signature of 'similarity_search' in CustomSupabaseVectorStore matches the signature of the same method in its parent class

commit 3d97994
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Sep 30 11:25:12 2024 +0200

    refacto: renaming max_input --> max_context_tokens (also in the db, SQL migration script is included)

commit d033772
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Sep 30 10:04:44 2024 +0200

    refactor: changing soruce to docs for clarity

commit 7acb034
Author: Jacopo Chevallard <[email protected]>
Date:   Fri Sep 27 12:27:46 2024 +0200

    feat: enabling questions/instructions identification, multi-question parallel retrieval, more robust outputs thanks to structured outputs

commit f5ff497
Author: Jacopo Chevallard <[email protected]>
Date:   Fri Sep 27 12:16:06 2024 +0200

    feat: improving prompts and adding chat history to RAG-generation prompt

commit 90635de
Author: Jacopo Chevallard <[email protected]>
Date:   Fri Sep 27 10:52:53 2024 +0200

    feat: dealing with the different types of conditional edges, where some conditional edges can exploit the new LangGraph Send API

commit d4bb94e
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Sep 25 17:00:28 2024 +0200

    feat: enabling the user to modify the system prompt during a conversation

commit cd5da57
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Sep 25 16:59:00 2024 +0200

    feat: dealing with the special LangGraph edges START and END within the Pydantic classes

commit 778e03e
Author: Jacopo Chevallard <[email protected]>
Date:   Tue Sep 24 14:31:30 2024 +0200

    feat: removing sync versions of several functions to simplify code maintenance and accelerate developments
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 9 12:06:23 2024 +0200

    feat: starting reorganizing modules for simpler maintenance and readability
Author: Jacopo Chevallard <[email protected]>
Date:   Wed Oct 9 12:06:23 2024 +0200

    feat: starting reorganizing modules for simpler maintenance and readability

commit 3d97994
Author: Jacopo Chevallard <[email protected]>
Date:   Mon Sep 30 11:25:12 2024 +0200

    refacto: renaming max_input --> max_context_tokens (also in the db, SQL migration script is included)
@jacopo-chevallard jacopo-chevallard marked this pull request as ready for review October 24, 2024 14:57
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Outdated Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
core/quivr_core/brain/brain.py Show resolved Hide resolved
@jacopo-chevallard
Copy link
Collaborator Author

@AmineDiro @StanGirard all tests are passing by now

core/pyproject.toml Outdated Show resolved Hide resolved
core/pyproject.toml Show resolved Hide resolved
core/quivr_core/rag/entities/chat.py Outdated Show resolved Hide resolved
core/quivr_core/rag/prompts.py Show resolved Hide resolved
core/quivr_core/rag/quivr_rag_langgraph.py Show resolved Hide resolved
core/quivr_core/rag/quivr_rag_langgraph.py Outdated Show resolved Hide resolved
core/quivr_core/rag/entities/config.py Show resolved Hide resolved
core/quivr_core/rag/entities/config.py Outdated Show resolved Hide resolved
core/quivr_core/llm/llm_endpoint.py Show resolved Hide resolved
core/quivr_core/llm_tools/web_search_tools.py Show resolved Hide resolved
Copy link
Collaborator

@AmineDiro AmineDiro left a comment

Choose a reason for hiding this comment

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

Nice work on the PR 💯 !

Here are some feedback on the design and current architecture of the classes:

  • I think that the QuivrQARAGLangGraph should get leaner: it has method that don't directly operate on self. It should offload to some node and only hold a the graph itself: how to build the graph, how to run the graph , how to print the graph ....
  • The state inside the graph should be typed. Coming from the outside It is very difficult to debug the state inside a node. Currently the state is passed as dict between nodes.
    One approach would be to use the TypeState pattern : The Object state can be generic over the some transitionStatte Type State<T> where T. Then on each transition we could have a new object State than is correctly typed and holds a list of predetermined attributes that are clear to the IDE, debugger etc ...
  • The tools interface should be cleanup a bit. IMO the registry pattern is the correct abstraction here but I think that some abstraction like ToolWrapper, Tools, create_tool_... are not necessary and could be simplified. We should have a common interface over Tools as some abstract class and then build each tool class internal to quiver as its own object that can be added to the registry if its key matches the config key.
  • The prompts interface should probably adhere to the registry pattern.

core/quivr_core/llm_tools/web_search_tools.py Show resolved Hide resolved
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 31, 2024
@AmineDiro AmineDiro merged commit 285fe5b into main Oct 31, 2024
5 checks passed
@AmineDiro AmineDiro deleted the feat/edit_system_prompt_from_conversation_UPDATED branch October 31, 2024 16:57
StanGirard added a commit that referenced this pull request Oct 31, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.0.23](core-0.0.22...core-0.0.23)
(2024-10-31)


### Features

* websearch, tool use, user intent, dynamic retrieval, multiple
questions ([#3424](#3424))
([285fe5b](285fe5b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants