Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import requests
|
3 |
import json
|
4 |
import os
|
@@ -16,17 +16,22 @@ def generate_response(prompt):
|
|
16 |
if response.status_code == 200:
|
17 |
return response.json()
|
18 |
else:
|
19 |
-
|
20 |
-
st.error(response.text)
|
21 |
-
return None
|
22 |
|
23 |
-
def main():
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
-
|
|
|
1 |
+
import gradio as gr
|
2 |
import requests
|
3 |
import json
|
4 |
import os
|
|
|
16 |
if response.status_code == 200:
|
17 |
return response.json()
|
18 |
else:
|
19 |
+
return f"Error: {response.status_code}\n{response.text}"
|
|
|
|
|
20 |
|
21 |
+
def main(prompt):
|
22 |
+
response = generate_response(prompt)
|
23 |
+
if isinstance(response, str):
|
24 |
+
return response
|
25 |
+
else:
|
26 |
+
return json.dumps(response, indent=2)
|
27 |
+
|
28 |
+
iface = gr.Interface(
|
29 |
+
fn=main,
|
30 |
+
inputs=gr.Textbox(lines=4, placeholder="Enter your prompt here..."),
|
31 |
+
outputs=gr.Textbox(lines=10),
|
32 |
+
title="Code Assistant",
|
33 |
+
description="Enter your prompt and get responses from the model."
|
34 |
+
)
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
+
iface.launch()
|