Formats the user query with conversation history for context.
(self, query: str, history: list)
| 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""" |
| 160 | Given 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 | |
| 166 | Latest 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: |
no outgoing calls
no test coverage detected