shivansarora commited on
Commit
0e23081
Β·
verified Β·
1 Parent(s): 4996f90

Update cefr_utils.py

Browse files
Files changed (1) hide show
  1. cefr_utils.py +3 -0
cefr_utils.py CHANGED
@@ -7,6 +7,9 @@ description = {
7
  "A1": "Can interact in a simple way but communication is totally dependent on repetition at a slower rate, rephrasing and repair. Can ask and answer simple questions, initiate and respond to simple statements in areas of immediate need or on very familiar topics."
8
  }
9
 
 
 
 
10
  def get_messages(instruction, item, apply_chat_template, system_msg, next_speaker="A"):
11
  item['messages'] = [{"role": "system", "content": f"Only output {next_speaker}'s response."}] if system_msg else []
12
  item['messages'] += [{"role": "user", "content": f"{instruction}\nDialog:\n{format_context(item['context'])}\n"}]
 
7
  "A1": "Can interact in a simple way but communication is totally dependent on repetition at a slower rate, rephrasing and repair. Can ask and answer simple questions, initiate and respond to simple statements in areas of immediate need or on very familiar topics."
8
  }
9
 
10
+ def format_context(context):
11
+ return os.linesep.join([("A" if (i%2==0) else "B") + ": " + turn["text"] for i, turn in enumerate(context)])
12
+
13
  def get_messages(instruction, item, apply_chat_template, system_msg, next_speaker="A"):
14
  item['messages'] = [{"role": "system", "content": f"Only output {next_speaker}'s response."}] if system_msg else []
15
  item['messages'] += [{"role": "user", "content": f"{instruction}\nDialog:\n{format_context(item['context'])}\n"}]