Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ if not API_KEY:
|
|
11 |
API_URL = "https://api-inference.huggingface.co/models/Salesforce/codegen-350M-mono"
|
12 |
headers = {"Authorization": f"Bearer {API_KEY}"}
|
13 |
|
14 |
-
def generate_response(prompt, max_length=
|
15 |
data = {
|
16 |
"inputs": prompt,
|
17 |
"parameters": {
|
@@ -26,7 +26,7 @@ def generate_response(prompt, max_length=200, temperature=0.5):
|
|
26 |
else:
|
27 |
return f"Error: {response.status_code}\n{response.text}"
|
28 |
|
29 |
-
def main(prompt, max_length=
|
30 |
response = generate_response(prompt, max_length, temperature)
|
31 |
return response
|
32 |
|
@@ -45,7 +45,7 @@ def format_code(code):
|
|
45 |
return formatted_code
|
46 |
|
47 |
# Adding interactive elements
|
48 |
-
def interactive_elements(prompt, max_length=
|
49 |
# Provide interactive feedback and formatting
|
50 |
feedback = real_time_feedback(prompt)
|
51 |
code = main(prompt, max_length, temperature)
|
@@ -57,7 +57,7 @@ interactive_iface = gr.Interface(
|
|
57 |
fn=interactive_elements,
|
58 |
inputs=[
|
59 |
gr.Textbox(label="Enter your prompt", placeholder="Enter your prompt here...", lines=5),
|
60 |
-
gr.Slider(label="Max Length", minimum=50, maximum=
|
61 |
gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.5, step=0.1)
|
62 |
],
|
63 |
outputs=[
|
|
|
11 |
API_URL = "https://api-inference.huggingface.co/models/Salesforce/codegen-350M-mono"
|
12 |
headers = {"Authorization": f"Bearer {API_KEY}"}
|
13 |
|
14 |
+
def generate_response(prompt, max_length=500, temperature=0.5):
|
15 |
data = {
|
16 |
"inputs": prompt,
|
17 |
"parameters": {
|
|
|
26 |
else:
|
27 |
return f"Error: {response.status_code}\n{response.text}"
|
28 |
|
29 |
+
def main(prompt, max_length=500, temperature=0.5):
|
30 |
response = generate_response(prompt, max_length, temperature)
|
31 |
return response
|
32 |
|
|
|
45 |
return formatted_code
|
46 |
|
47 |
# Adding interactive elements
|
48 |
+
def interactive_elements(prompt, max_length=500, temperature=0.5):
|
49 |
# Provide interactive feedback and formatting
|
50 |
feedback = real_time_feedback(prompt)
|
51 |
code = main(prompt, max_length, temperature)
|
|
|
57 |
fn=interactive_elements,
|
58 |
inputs=[
|
59 |
gr.Textbox(label="Enter your prompt", placeholder="Enter your prompt here...", lines=5),
|
60 |
+
gr.Slider(label="Max Length", minimum=50, maximum=2000, value=500, step=10),
|
61 |
gr.Slider(label="Temperature", minimum=0.1, maximum=1.0, value=0.5, step=0.1)
|
62 |
],
|
63 |
outputs=[
|