MCPcopy Create free account
hub / github.com/FreedomIntelligence/CMB / generate_fewshot_examples

Method generate_fewshot_examples

workers/base.py:239–249  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.45

Calls 1

Tested by

no test coverage detected