MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / get_history

Method get_history

utils/src/llms.py:323–337  ·  view source on GitHub ↗

Get the conversation history.

(self, similar: int, recent: int, prompt: str)

Source from the content-addressed store, hash-verified

321 self.output_tokens += 3
322
323 def get_history(self, similar: int, recent: int, prompt: str):
324 """
325 Get the conversation history.
326 """
327 history = self.history[-recent:] if recent > 0 else []
328 if similar > 0:
329 embedding = get_text_embedding(prompt, self.text_model)
330 history.sort(key=lambda x: cosine_similarity(embedding, x.embedding))
331 for turn in history:
332 if len(history) > similar + recent:
333 break
334 if turn not in history:
335 history.append(turn)
336 history.sort(key=lambda x: x.id)
337 return history
338
339 def save_history(self, output_dir: str):
340 """

Callers 1

__call__Method · 0.95

Calls 1

get_text_embeddingFunction · 0.90

Tested by

no test coverage detected