improve the accuracy of ids in the citations

This commit is contained in:
LUIS NOVO 2024-11-13 11:55:38 -03:00
parent a38fda4447
commit 281abdf01b
4 changed files with 8 additions and 15 deletions

View file

@ -89,6 +89,8 @@ async def provide_answer(state: SubGraphState, config: RunnableConfig) -> dict:
if len(results) == 0:
return {"answers": []}
payload["results"] = results
ids = [r["id"] for r in results]
payload["ids"] = ids
system_prompt = Prompter(prompt_template="ask/query_process").render(data=payload)
model = provision_langchain_model(
system_prompt,

View file

@ -1,6 +1,7 @@
import sqlite3
from typing import Annotated, Optional
from langchain_core.messages import SystemMessage
from langchain_core.runnables import (
RunnableConfig,
)
@ -24,7 +25,7 @@ class ThreadState(TypedDict):
def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict:
system_prompt = Prompter(prompt_template="chat").render(data=state)
payload = [system_prompt] + state.get("messages", [])
payload = [SystemMessage(content=system_prompt)] + state.get("messages", [])
model = provision_langchain_model(
str(payload),
config.get("configurable", {}).get("model_id"),

View file

@ -34,20 +34,6 @@ async def process_ask_query(question, strategy_model, answer_model, final_answer
):
yield (chunk)
# result = await ask_graph.ainvoke(
# dict(
# question=question,
# ),
# config=dict(
# configurable=dict(
# strategy_model=strategy_model.id,
# answer_model=answer_model.id,
# final_answer_model=final_answer_model.id,
# )
# ),
# )
# return result
def results_card(item):
score = item.get("relevance", item.get("similarity", item.get("score", 0)))

View file

@ -45,6 +45,10 @@ Please note, "note:iuiodadalknda" and "insight:adadadadadadad" are examples of d
- Do not assume or change the type prefix of any document ID. If a document ID is "note:xyz", use it exactly as "note:xyz". Do not change it to "source:xyz" or any other variation.
- **Use document IDs exactly as they are returned from the search tool. Do not add any prefixes or modify them in any way.**
## IDs PROVIDED IN THIS QUERY
You have been given the following content ids to work from: {{ids}}
So, if you are citing some document, it should be one of these.
# YOUR ANSWER