Modify the query based on what you know. Use this function when you need to modify the query to search for more relevant information. Args: what_you_know: The knowledge you have about the case. query_text: The original query. Returns: The modified query.
(what_you_know: str, query_text: str, **kwargs)
| 149 | @register_tool("modify_query") |
| 150 | @register_plugin_tool("modify_query") |
| 151 | def modify_query(what_you_know: str, query_text: str, **kwargs) -> str: |
| 152 | """ |
| 153 | Modify the query based on what you know. Use this function when you need to modify the query to search for more relevant information. |
| 154 | |
| 155 | Args: |
| 156 | what_you_know: The knowledge you have about the case. |
| 157 | query_text: The original query. |
| 158 | Returns: |
| 159 | The modified query. |
| 160 | """ |
| 161 | system_prompt = \ |
| 162 | f""" |
| 163 | |
| 164 | Assume you are an assistant searching for information. Now that you already know some knowledge ([What you know]), what sub-questions ([Modified query]) do you need to search for to help you answer the question ([Query]) you want to explore. |
| 165 | |
| 166 | Modify the query based on what you know, here is some example: |
| 167 | Example 1: |
| 168 | [What you know]: Alice and Bob have lunch together at 12:00 PM. |
| 169 | [Query]: What did Alice and Bob do after the lunch? |
| 170 | [Modified query]: What did Alice and Bob do after 12:00 PM? |
| 171 | |
| 172 | Example 2: |
| 173 | [What you know]: Alice and Bob went to the cinema yesterday. |
| 174 | [Query]: What did Alice and Bob do after the cinema? |
| 175 | [Modified query]: What did Alice and Bob do yesterday? |
| 176 | |
| 177 | Return only 1 modified query. |
| 178 | """ |
| 179 | |
| 180 | user_prompt = f""" |
| 181 | What you know: {what_you_know} |
| 182 | Query: {query_text} |
| 183 | Modified query: |
| 184 | """ |
| 185 | create_params = { |
| 186 | "model": "gpt-4o-mini", |
| 187 | "messages": [ |
| 188 | {"role": "system", "content": system_prompt}, |
| 189 | {"role": "user", "content": user_prompt} |
| 190 | ], |
| 191 | "stream": False, |
| 192 | } |
| 193 | response = completion(**create_params) |
| 194 | modified_query = response.choices[0].message.content |
| 195 | return f"The modified query is: {modified_query}. Now use function `query_db` to search the related information in the DataBase." |
| 196 | |
| 197 | |
| 198 |
nothing calls this directly
no outgoing calls
no test coverage detected