Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
Here is an example of a Gradio interface code generation builder that meets your requirements:
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import CodeT5ForConditionalGeneration, CodeT5Tokenizer
|
| 5 |
|
|
@@ -47,18 +45,3 @@ def generate_code(input_code, upload_file, temperature, max_length):
|
|
| 47 |
# Launch the Gradio interface
|
| 48 |
demo.launch()
|
| 49 |
|
| 50 |
-
This code defines a Gradio interface that takes four inputs:
|
| 51 |
-
|
| 52 |
-
A text box for inputting code or prompts
|
| 53 |
-
A file uploader for uploading code files
|
| 54 |
-
A temperature slider to adjust the generation temperature
|
| 55 |
-
A max length slider to adjust the maximum generated code length
|
| 56 |
-
|
| 57 |
-
The interface returns two outputs:
|
| 58 |
-
|
| 59 |
-
A code box displaying the generated code
|
| 60 |
-
A text box displaying the conversation history (including the input code and generated code)
|
| 61 |
-
|
| 62 |
-
When the user interacts with the interface, the generate_code function is called, which preprocesses the input code and uploaded file, tokenizes the input code, generates code using CodeT5, and converts the output to a string. The conversation history is also updated accordingly.
|
| 63 |
-
|
| 64 |
-
Note that you need to install the transformers library and have the CodeT5 model and tokenizer downloaded for this code to work.
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import CodeT5ForConditionalGeneration, CodeT5Tokenizer
|
| 3 |
|
|
|
|
| 45 |
# Launch the Gradio interface
|
| 46 |
demo.launch()
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|