MCPcopy
hub / github.com/PromtEngineer/localGPT / _format_query_with_history

Method _format_query_with_history

rag_system/agent/loop.py:152–168  ·  view source on GitHub ↗

Formats the user query with conversation history for context.

(self, query: str, history: list)

Source from the content-addressed store, hash-verified

150 return None
151
152 def _format_query_with_history(self, query: str, history: list) -> str:
153 """Formats the user query with conversation history for context."""
154 if not history:
155 return query
156
157 formatted_history = "\n".join([f"User: {turn['query']}\nAssistant: {turn['answer']}" for turn in history])
158
159 prompt = f"""
160Given the following conversation history, answer the user's latest query. The history provides context for resolving pronouns or follow-up questions.
161
162--- Conversation History ---
163{formatted_history}
164---
165
166Latest User Query: "{query}"
167"""
168 return prompt
169
170 # ---------------- Asynchronous triage using Ollama ----------------
171 async def _triage_query_async(self, query: str, history: list) -> str:

Callers 2

_run_graph_queryMethod · 0.95
_run_asyncMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected