Spaces:
Runtime error
Runtime error
root commited on
Commit ·
d7afe71
1
Parent(s): 64129bb
Updated doc prompt
Browse files
app.py
CHANGED
|
@@ -68,8 +68,8 @@ def generate_code(task_type: str, nl_input: str):
|
|
| 68 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:\n\n")[-1].strip()
|
| 69 |
# return single_function(response)
|
| 70 |
return _clean_csharp_output(response)
|
| 71 |
-
elif task_type=="Generate
|
| 72 |
-
prompt= f"### Instruction:\n\
|
| 73 |
inputs=tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 74 |
output=model.generate(**inputs,max_new_tokens=128, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.eos_token_id)
|
| 75 |
response = tokenizer.decode(output[0], skip_special_tokens=True).split("### Response:\n\n")[-1].strip()
|
|
@@ -79,7 +79,7 @@ def generate_code(task_type: str, nl_input: str):
|
|
| 79 |
demo = gr.Interface(
|
| 80 |
fn=generate_code,
|
| 81 |
inputs=[
|
| 82 |
-
gr.Dropdown(label="Select Task", choices=["NL to Java", "Java to C#", "End to End NL to C#", "Generate
|
| 83 |
gr.Textbox(label="Input")
|
| 84 |
],
|
| 85 |
outputs=gr.Code(label="Generated Code"),
|
|
|
|
| 68 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:\n\n")[-1].strip()
|
| 69 |
# return single_function(response)
|
| 70 |
return _clean_csharp_output(response)
|
| 71 |
+
elif task_type=="Generate Documentation":
|
| 72 |
+
prompt= f"### Instruction:\n\nGenerate documentation for the following code:\n\n{nl_input}\n\n### Response:\n\n"
|
| 73 |
inputs=tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 74 |
output=model.generate(**inputs,max_new_tokens=128, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.eos_token_id)
|
| 75 |
response = tokenizer.decode(output[0], skip_special_tokens=True).split("### Response:\n\n")[-1].strip()
|
|
|
|
| 79 |
demo = gr.Interface(
|
| 80 |
fn=generate_code,
|
| 81 |
inputs=[
|
| 82 |
+
gr.Dropdown(label="Select Task", choices=["NL to Java", "Java to C#", "End to End NL to C#", "Generate Documentation"], value="NL to Java"),
|
| 83 |
gr.Textbox(label="Input")
|
| 84 |
],
|
| 85 |
outputs=gr.Code(label="Generated Code"),
|