Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Usa CodeT5,
|
| 5 |
generator = pipeline('text2text-generation', model='Salesforce/codeT5-large')
|
| 6 |
|
| 7 |
# Funzione per generare il codice C
|
| 8 |
def genera_codice(input_text):
|
| 9 |
# Prompt migliorato per generare codice C
|
| 10 |
prompt = f"Scrivi un programma in C che risolva il problema seguente: {input_text}"
|
| 11 |
-
result = generator(prompt, max_length=
|
| 12 |
codice_generato = result[0]['generated_text']
|
| 13 |
return codice_generato
|
| 14 |
|
| 15 |
-
# Crea l'interfaccia utente
|
| 16 |
iface = gr.Interface(fn=genera_codice,
|
| 17 |
inputs="text", # Tipo di input: campo di testo
|
| 18 |
outputs="text", # Tipo di output: campo di testo
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Usa CodeT5, un modello più specializzato nella generazione di codice
|
| 5 |
generator = pipeline('text2text-generation', model='Salesforce/codeT5-large')
|
| 6 |
|
| 7 |
# Funzione per generare il codice C
|
| 8 |
def genera_codice(input_text):
|
| 9 |
# Prompt migliorato per generare codice C
|
| 10 |
prompt = f"Scrivi un programma in C che risolva il problema seguente: {input_text}"
|
| 11 |
+
result = generator(prompt, max_length=150, num_return_sequences=1)
|
| 12 |
codice_generato = result[0]['generated_text']
|
| 13 |
return codice_generato
|
| 14 |
|
| 15 |
+
# Crea l'interfaccia utente con Gradio
|
| 16 |
iface = gr.Interface(fn=genera_codice,
|
| 17 |
inputs="text", # Tipo di input: campo di testo
|
| 18 |
outputs="text", # Tipo di output: campo di testo
|