Skip to content

Commit 6450a49

Browse files
feat: first version (V0) of the Workflow Management System (#3493)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## 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):
1 parent 1a3e03c commit 6450a49

File tree

4 files changed

+299
-141
lines changed

4 files changed

+299
-141
lines changed

core/quivr_core/llm_tools/web_search_tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def format_output(response: Any) -> List[Document]:
4545
page_content=d["content"],
4646
metadata={
4747
**metadata,
48-
"file_name": d["url"],
49-
"original_file_name": d["url"],
48+
"file_name": d["url"] if "url" in d else "",
49+
"original_file_name": d["url"] if "url" in d else "",
5050
},
5151
)
5252
for d in response

core/quivr_core/rag/entities/config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DefaultRerankers(str, Enum):
5959
def default_model(self) -> str:
6060
# Mapping of suppliers to their default models
6161
return {
62-
self.COHERE: "rerank-multilingual-v3.0",
62+
self.COHERE: "rerank-v3.5",
6363
self.JINA: "jina-reranker-v2-base-multilingual",
6464
# self.MIXEDBREAD: "rmxbai-rerank-large-v1",
6565
}[self]
@@ -220,7 +220,7 @@ def set_api_key(self, force_reset: bool = False):
220220
return
221221

222222
# Check if the corresponding API key environment variable is set
223-
if not self.env_variable_name:
223+
if force_reset or not self.env_variable_name:
224224
self.env_variable_name = (
225225
f"{normalize_to_env_variable_name(self.supplier)}_API_KEY"
226226
)
@@ -230,7 +230,9 @@ def set_api_key(self, force_reset: bool = False):
230230

231231
if not self.llm_api_key:
232232
logger.warning(f"The API key for supplier '{self.supplier}' is not set. ")
233-
logger.warning(f"Please set the environment variable: '{self.env_variable_name}'. ")
233+
logger.warning(
234+
f"Please set the environment variable: '{self.env_variable_name}'. "
235+
)
234236

235237
def set_llm_model_config(self):
236238
# Automatically set context_length and tokenizer_hub based on the supplier and model

core/quivr_core/rag/prompts.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ def _define_custom_prompts() -> CustomPromptsDict:
6161
"- If no preferred language is provided, answer in the same language as the language used by the user.\n"
6262
"- You must use ONLY the provided context to answer the question. "
6363
"Do not use any prior knowledge or external information, even if you are certain of the answer.\n"
64-
"- If you cannot provide an answer using ONLY the context provided, do not attempt to answer from your own knowledge."
65-
"Instead, inform the user that the answer isn't available in the context and suggest using the available tools {tools}.\n"
64+
# "- If you cannot provide an answer using ONLY the context provided, do not attempt to answer from your own knowledge."
65+
# "Instead, inform the user that the answer isn't available in the context and suggest using the available tools {tools}.\n"
6666
"- Do not apologize when providing an answer.\n"
6767
"- Don't cite the source id in the answer objects, but you can use the source to answer the question.\n\n"
6868
)
6969

7070
context_template = (
7171
"\n"
72-
"- You have access to the following internal reasoning to provide an answer: {reasoning}\n"
72+
# "- You have access to the following internal reasoning to provide an answer: {reasoning}\n"
7373
"- You have access to the following files to answer the user question (limited to first 20 files): {files}\n"
7474
"- You have access to the following context to answer the user question: {context}\n"
7575
"- Follow these user instruction when crafting the answer: {custom_instructions}\n"
7676
"- These user instructions shall take priority over any other previous instruction.\n"
77-
"- Remember: if you cannot provide an answer using ONLY the provided context and CITING the sources, "
78-
"inform the user that you don't have the answer and consider if any of the tools can help answer the question.\n"
79-
"- Explain your reasoning about the potentiel tool usage in the answer.\n"
80-
"- Only use binded tools to answer the question.\n"
77+
# "- Remember: if you cannot provide an answer using ONLY the provided context and CITING the sources, "
78+
# "inform the user that you don't have the answer and consider if any of the tools can help answer the question.\n"
79+
# "- Explain your reasoning about the potentiel tool usage in the answer.\n"
80+
# "- Only use binded tools to answer the question.\n"
8181
# "OFFER the user the possibility to ACTIVATE a relevant tool among "
8282
# "the tools which can be activated."
8383
# "Tools which can be activated: {tools}. If any of these tools can help in providing an answer "
@@ -88,6 +88,10 @@ def _define_custom_prompts() -> CustomPromptsDict:
8888
template_answer = (
8989
"Original task: {question}\n"
9090
"Rephrased and contextualized task: {rephrased_task}\n"
91+
"Remember, you shall answer ALL questions and tasks.\n"
92+
"Remember: if you cannot provide an answer using ONLY the provided context and CITING the sources, "
93+
"just answer that you don't have the answer.\n"
94+
"If the provided context contains contradictory or conflicting information, state so providing the conflicting information.\n"
9195
)
9296

9397
RAG_ANSWER_PROMPT = ChatPromptTemplate.from_messages(
@@ -207,8 +211,8 @@ def _define_custom_prompts() -> CustomPromptsDict:
207211
"just reformulate them if needed and otherwise return them as is.\n"
208212
"- Remember, you shall NOT suggest or generate new tasks.\n"
209213
"- As an example, the user input 'What is Apple? Who is its CEO? When was it founded?' "
210-
"shall be split into the questions 'What is Apple?', 'Who is the CEO of Apple?' and 'When was Apple founded?'.\n"
211-
"- If no tasks are found, return the user input as is in the task.\n"
214+
"shall be split into a list of tasks ['What is Apple?', 'Who is the CEO of Apple?', 'When was Apple founded?']\n"
215+
"- If no tasks are found, return the user input as is in the task list.\n"
212216
)
213217

214218
template_answer = "User input: {user_input}"

0 commit comments

Comments
 (0)