parrotmaker commited on
Commit
e545017
·
verified ·
1 Parent(s): 30cdc77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,12 +1,16 @@
1
  import gradio as gr
 
2
 
3
- # Minimal dummy interface with redirect
4
- gr.Interface(
5
- fn=lambda x: "",
6
- inputs=gr.Textbox(visible=False),
7
- outputs=gr.Textbox(visible=False),
8
- live=False
9
- ).launch(
 
 
 
10
  inline=False,
11
  server_name="0.0.0.0",
12
  server_port=7860
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the model
5
+ model = pipeline("text-generation", model="Salesforce/codegen-350M-multi", max_new_tokens=512)
6
+
7
+ # Define the function that gets called from JS
8
+ def generate(prompt):
9
+ result = model(f"# HTML/CSS/JS request: {prompt}\n")[0]["generated_text"]
10
+ return result
11
+
12
+ # Serve API endpoint at /generate
13
+ gr.Interface(fn=generate, inputs="text", outputs="text").launch(
14
  inline=False,
15
  server_name="0.0.0.0",
16
  server_port=7860