HakanKilic01 commited on
Commit
add4b49
1 Parent(s): 77582ad

07/01/23-15:16

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -20,13 +20,16 @@ def generate_code(input_text,modelName):
20
  result = codeGenTokenizer.decode(generated_ids[0], skip_special_tokens=True)
21
  return extract_code(result)
22
  elif(modelName == "mistral-7b"):
23
- input_ids = mistralTokenizer(input_text, return_tensors="pt").input_ids
24
  generated_ids = mistralModel.generate(input_ids, max_length=128)
25
  result = mistralTokenizer.decode(generated_ids[0], skip_special_tokens=True)
26
  return result
27
  else:
28
  return None
29
 
 
 
 
30
 
31
  def respond(message, chat_history, additional_inputs):
32
  return f"Here's an example code:\n\n```python\n{generate_code(message,additional_inputs)}\n```"
 
20
  result = codeGenTokenizer.decode(generated_ids[0], skip_special_tokens=True)
21
  return extract_code(result)
22
  elif(modelName == "mistral-7b"):
23
+ input_ids = mistralTokenizer(generate_prompt_mistral(input_text), return_tensors="pt").input_ids
24
  generated_ids = mistralModel.generate(input_ids, max_length=128)
25
  result = mistralTokenizer.decode(generated_ids[0], skip_special_tokens=True)
26
  return result
27
  else:
28
  return None
29
 
30
+ def generate_prompt_mistral(text):
31
+ system_msg = "Below is an instruction that describes a programming task. Write a response code that appropriately completes the request.\n"
32
+ return f"<s>[INST] {system_msg}\n{text} [/INST]"
33
 
34
  def respond(message, chat_history, additional_inputs):
35
  return f"Here's an example code:\n\n```python\n{generate_code(message,additional_inputs)}\n```"