improve the accuracy of ids in the citations
This commit is contained in:
parent
a38fda4447
commit
281abdf01b
4 changed files with 8 additions and 15 deletions
|
|
@ -89,6 +89,8 @@ async def provide_answer(state: SubGraphState, config: RunnableConfig) -> dict:
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
return {"answers": []}
|
return {"answers": []}
|
||||||
payload["results"] = results
|
payload["results"] = results
|
||||||
|
ids = [r["id"] for r in results]
|
||||||
|
payload["ids"] = ids
|
||||||
system_prompt = Prompter(prompt_template="ask/query_process").render(data=payload)
|
system_prompt = Prompter(prompt_template="ask/query_process").render(data=payload)
|
||||||
model = provision_langchain_model(
|
model = provision_langchain_model(
|
||||||
system_prompt,
|
system_prompt,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from typing import Annotated, Optional
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
|
from langchain_core.messages import SystemMessage
|
||||||
from langchain_core.runnables import (
|
from langchain_core.runnables import (
|
||||||
RunnableConfig,
|
RunnableConfig,
|
||||||
)
|
)
|
||||||
|
|
@ -24,7 +25,7 @@ class ThreadState(TypedDict):
|
||||||
|
|
||||||
def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict:
|
def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict:
|
||||||
system_prompt = Prompter(prompt_template="chat").render(data=state)
|
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(
|
model = provision_langchain_model(
|
||||||
str(payload),
|
str(payload),
|
||||||
config.get("configurable", {}).get("model_id"),
|
config.get("configurable", {}).get("model_id"),
|
||||||
|
|
|
||||||
|
|
@ -34,20 +34,6 @@ async def process_ask_query(question, strategy_model, answer_model, final_answer
|
||||||
):
|
):
|
||||||
yield (chunk)
|
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):
|
def results_card(item):
|
||||||
score = item.get("relevance", item.get("similarity", item.get("score", 0)))
|
score = item.get("relevance", item.get("similarity", item.get("score", 0)))
|
||||||
|
|
|
||||||
|
|
@ -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.
|
- 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.**
|
- **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
|
# YOUR ANSWER
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue