Skip to content

Commit

Permalink
fix(rag): messages type.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrckd committed Oct 2, 2024
1 parent 2f1e03f commit 52e584a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/core_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def generate(self, model: str, messages: list[dict], **sampling_params) -> str:
answer = result.choices[0].message.content
return answer

def make_rag_prompt(self, model_embedding: str, messages: list[dict]):
def make_rag_prompt(self, model_embedding: str, messages: list[dict]) -> list[dict]:
system_prompt = "Tu es Albert, un bot de l'état français en charge d'informer les agents."
messages = [
{
Expand All @@ -105,8 +105,9 @@ def make_rag_prompt(self, model_embedding: str, messages: list[dict]):
collections = [c["id"] for c in self.fetch_collections().values() if c["type"] == "public"]
query = messages[-1]["content"]
chunks = self.semantic_search(model_embedding, query, limit, collections)
answer = self.format_albert_template(query, chunks)
return answer
prompt = self.format_albert_template(query, chunks)
messages[-1]["content"] = prompt
return prompt

def semantic_search(
self, model: str, query: str, limit: int, collections: list[str]
Expand Down

0 comments on commit 52e584a

Please sign in to comment.