Oranblock commited on
Commit
bc57e29
·
verified ·
1 Parent(s): b95bcc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
2
  import json
3
  from huggingface_hub import InferenceClient
4
 
5
- # Initialize the InferenceClient, specifying the model and enabling GPU
6
- client = InferenceClient(model="gpt-3.5-turbo", use_gpu=True)
7
 
8
- # Function to attempt to fix JSON using a Hugging Face model with GPU
9
  def ai_fix_json(json_data):
10
  prompt = f"Fix the following JSON data and make it valid:\n\n{json_data}\n\nFixed JSON:"
11
  response = client.text_generation(prompt, max_new_tokens=1024)
@@ -15,7 +15,7 @@ def ai_fix_json(json_data):
15
  try:
16
  parsed_data = json.loads(fixed_json)
17
  pretty_json = json.dumps(parsed_data, indent=4)
18
- return pretty_json, "JSON fixed using AI with GPU."
19
  except json.JSONDecodeError as e:
20
  return None, f"Failed to fix JSON: {str(e)}"
21
 
@@ -32,8 +32,8 @@ iface = gr.Interface(
32
  fn=process_file,
33
  inputs=gr.File(label="Upload your JSON file"),
34
  outputs=[gr.JSON(label="Fixed JSON"), "text", gr.File(label="Download cleaned JSON file")],
35
- title="AI-Powered JSON Cleaner with GPU",
36
- description="Upload a JSON file to automatically fix, remove duplicates, and download the cleaned version using AI on a GPU."
37
  )
38
 
39
  iface.launch()
 
2
  import json
3
  from huggingface_hub import InferenceClient
4
 
5
+ # Initialize the InferenceClient
6
+ client = InferenceClient(model="gpt-3.5-turbo")
7
 
8
+ # Function to attempt to fix JSON using a Hugging Face model
9
  def ai_fix_json(json_data):
10
  prompt = f"Fix the following JSON data and make it valid:\n\n{json_data}\n\nFixed JSON:"
11
  response = client.text_generation(prompt, max_new_tokens=1024)
 
15
  try:
16
  parsed_data = json.loads(fixed_json)
17
  pretty_json = json.dumps(parsed_data, indent=4)
18
+ return pretty_json, "JSON fixed using AI."
19
  except json.JSONDecodeError as e:
20
  return None, f"Failed to fix JSON: {str(e)}"
21
 
 
32
  fn=process_file,
33
  inputs=gr.File(label="Upload your JSON file"),
34
  outputs=[gr.JSON(label="Fixed JSON"), "text", gr.File(label="Download cleaned JSON file")],
35
+ title="AI-Powered JSON Cleaner",
36
+ description="Upload a JSON file to automatically fix, remove duplicates, and download the cleaned version using AI."
37
  )
38
 
39
  iface.launch()