Generate a fewshot prompt given a list of data. Note that the roles are already in the fewshot examples. Be careful not to add any extra roles in the final query that is input to an LLM.
(self, data: list[dict], use_cot=False)
| 237 | return user, gpt |
| 238 | |
| 239 | def generate_fewshot_examples(self, data: list[dict], use_cot=False): |
| 240 | """ |
| 241 | Generate a fewshot prompt given a list of data. |
| 242 | Note that the roles are already in the fewshot examples. |
| 243 | Be careful not to add any extra roles in the final query that is input to an LLM. |
| 244 | """ |
| 245 | prompt = self.fewshot_prompt |
| 246 | for item in data: |
| 247 | user, gpt = self.format_fewshot_user_and_gpt(item, use_cot) |
| 248 | prompt += self.fewshot_template.format(user=user, gpt=gpt) + self.fewshot_separator |
| 249 | return prompt |
| 250 | |
| 251 | |
| 252 |
no test coverage detected