Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 3 |
from huggingface_hub import login
|
| 4 |
from transformers import pipeline
|
| 5 |
|
|
@@ -10,21 +10,26 @@ login(HF_TOKEN)
|
|
| 10 |
|
| 11 |
generator = pipeline('text-generation', model=model_name, token=HF_TOKEN)
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
from huggingface_hub import login
|
| 4 |
from transformers import pipeline
|
| 5 |
|
|
|
|
| 10 |
|
| 11 |
generator = pipeline('text-generation', model=model_name, token=HF_TOKEN)
|
| 12 |
|
| 13 |
+
# Function for generating Lean 4 code
|
| 14 |
+
def generate_lean4_code(prompt):
|
| 15 |
+
result = generator(prompt, max_length=1000, num_return_sequences=1)
|
| 16 |
+
return result[0]['generated_text']
|
| 17 |
|
| 18 |
+
# Gradio Interface
|
| 19 |
+
title = "Lean 4 Code Generation with TheoremLlama"
|
| 20 |
+
description = "Enter a natural language prompt to generate Lean 4 code."
|
| 21 |
|
| 22 |
+
interface = gr.Interface(
|
| 23 |
+
fn=generate_lean4_code,
|
| 24 |
+
inputs=gr.Textbox(
|
| 25 |
+
label="Prompt",
|
| 26 |
+
placeholder="Prove that the sum of two even numbers is even.",
|
| 27 |
+
lines=4
|
| 28 |
+
),
|
| 29 |
+
outputs=gr.Code(label="Generated Lean 4 Code", language="lean"),
|
| 30 |
+
title=title,
|
| 31 |
+
description=description
|
| 32 |
+
)
|
| 33 |
|
| 34 |
+
# Launch the Gradio app
|
| 35 |
+
interface.launch()
|