linoyts HF Staff commited on
Commit
b73a917
·
verified ·
1 Parent(s): 8106715

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -16,6 +16,7 @@ import math
16
 
17
  import os
18
  import base64
 
19
  import json
20
 
21
  SYSTEM_PROMPT = '''
@@ -98,7 +99,7 @@ Please strictly follow the rewriting rules below:
98
  }
99
  '''
100
 
101
- def polish_prompt_hf(prompt, img_list):
102
  """
103
  Rewrites the prompt using a Hugging Face InferenceClient.
104
  Supports multiple images via img_list.
@@ -107,8 +108,8 @@ def polish_prompt_hf(prompt, img_list):
107
  api_key = os.environ.get("HF_TOKEN")
108
  if not api_key:
109
  print("Warning: HF_TOKEN not set. Falling back to original prompt.")
110
- return prompt
111
- prompt = f"{SYSTEM_PROMPT}\n\nUser Input: {prompt}\n\nRewritten Prompt:"
112
  system_prompt = "you are a helpful assistant, you should provide useful answers to users."
113
  try:
114
  # Initialize the client
@@ -197,7 +198,7 @@ def polish_prompt_hf(prompt, img_list):
197
  except Exception as e:
198
  print(f"Error during API call to Hugging Face: {e}")
199
  # Fallback to original prompt if enhancement fails
200
- return prompt
201
 
202
 
203
 
 
16
 
17
  import os
18
  import base64
19
+ from io import BytesIO
20
  import json
21
 
22
  SYSTEM_PROMPT = '''
 
99
  }
100
  '''
101
 
102
+ def polish_prompt_hf(original_prompt, img_list):
103
  """
104
  Rewrites the prompt using a Hugging Face InferenceClient.
105
  Supports multiple images via img_list.
 
108
  api_key = os.environ.get("HF_TOKEN")
109
  if not api_key:
110
  print("Warning: HF_TOKEN not set. Falling back to original prompt.")
111
+ return original_prompt
112
+ prompt = f"{SYSTEM_PROMPT}\n\nUser Input: {original_prompt}\n\nRewritten Prompt:"
113
  system_prompt = "you are a helpful assistant, you should provide useful answers to users."
114
  try:
115
  # Initialize the client
 
198
  except Exception as e:
199
  print(f"Error during API call to Hugging Face: {e}")
200
  # Fallback to original prompt if enhancement fails
201
+ return original_prompt
202
 
203
 
204