sayakpaul HF Staff commited on
Commit
d891944
·
verified ·
1 Parent(s): ef0e180

Sync from GitHub

Browse files
Files changed (3) hide show
  1. app.py +7 -7
  2. prompts.py +5 -0
  3. utils/pipeline_utils.py +1 -0
app.py CHANGED
@@ -66,8 +66,8 @@ with gr.Blocks() as demo:
66
  value="black-forest-labs/FLUX.1-dev",
67
  )
68
  gemini_model_to_use = gr.Dropdown(
69
- ["gemini-2.5-flash", "gemini-2.5-pro"],
70
- value="gemini-2.5-flash",
71
  label="Gemini Model",
72
  info="Select the model to generate the analysis.",
73
  )
@@ -92,7 +92,7 @@ with gr.Blocks() as demo:
92
  )
93
 
94
  with gr.Column(scale=1):
95
- submit_btn = gr.Button("Estimate Memory ☁", variant="primary", scale=1)
96
 
97
  # --- Start of New Code Block ---
98
  all_inputs = [
@@ -164,9 +164,9 @@ with gr.Blocks() as demo:
164
  prompt_output = gr.Textbox(label="Prompt", show_copy_button=True, lines=10, interactive=False)
165
 
166
  gr.Markdown("---")
167
- gr.Markdown("### Generated Code")
168
-
169
- output_markdown = gr.Markdown(label="LLM Output", value="*Your results will appear here...*")
170
 
171
  gr.Markdown(
172
  """
@@ -178,7 +178,7 @@ with gr.Blocks() as demo:
178
  )
179
 
180
  # --- Event Handling ---
181
- submit_btn.click(fn=get_output_code, inputs=all_inputs, outputs=[output_markdown, prompt_output])
182
 
183
 
184
  if __name__ == "__main__":
 
66
  value="black-forest-labs/FLUX.1-dev",
67
  )
68
  gemini_model_to_use = gr.Dropdown(
69
+ ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro"],
70
+ value="gemini-2.5-flash-lite",
71
  label="Gemini Model",
72
  info="Select the model to generate the analysis.",
73
  )
 
92
  )
93
 
94
  with gr.Column(scale=1):
95
+ submit_btn = gr.Button("Get Code ☁", variant="primary", scale=1)
96
 
97
  # --- Start of New Code Block ---
98
  all_inputs = [
 
164
  prompt_output = gr.Textbox(label="Prompt", show_copy_button=True, lines=10, interactive=False)
165
 
166
  gr.Markdown("---")
167
+
168
+ with gr.Accordion("Generated Code (expand)", open=False):
169
+ code_output = gr.Code(interactive=True, language="python")
170
 
171
  gr.Markdown(
172
  """
 
178
  )
179
 
180
  # --- Event Handling ---
181
+ submit_btn.click(fn=get_output_code, inputs=all_inputs, outputs=[code_output, prompt_output])
182
 
183
 
184
  if __name__ == "__main__":
prompts.py CHANGED
@@ -171,6 +171,11 @@ that this is different from using FP8. In FP8, we use quantization like shown ab
171
  * Add a comment before the `pipe` call, saying "Modify the pipe call arguments as needed."
172
  * Do NOT add any serialization step after the pipe call.
173
 
 
 
 
 
 
174
  Please think about these guidelines carefully before producing the outputs.
175
  """
176
 
 
171
  * Add a comment before the `pipe` call, saying "Modify the pipe call arguments as needed."
172
  * Do NOT add any serialization step after the pipe call.
173
 
174
+ ## Specific guidelines on output format
175
+
176
+ * When returning the outputs, your thinking/reasoning traces should be within comments.
177
+ * You don't have to put the actual code snippet within a ```python ...``` block.
178
+
179
  Please think about these guidelines carefully before producing the outputs.
180
  """
181
 
utils/pipeline_utils.py CHANGED
@@ -19,6 +19,7 @@ DTYPE_MAP = {"F32": torch.float32, "F16": torch.float16, "BF16": torch.bfloat16}
19
  def _parse_single_file(url):
20
  print(f"{url=}")
21
  token = os.getenv("HF_TOKEN")
 
22
  headers = {"Range": "bytes=0-7", "Authorization": f"Bearer {token}"}
23
  response = requests.get(url, headers=headers)
24
  length_of_header = struct.unpack("<Q", response.content)[0]
 
19
  def _parse_single_file(url):
20
  print(f"{url=}")
21
  token = os.getenv("HF_TOKEN")
22
+ assert token, "HF_TOKEN must be set"
23
  headers = {"Range": "bytes=0-7", "Authorization": f"Bearer {token}"}
24
  response = requests.get(url, headers=headers)
25
  length_of_header = struct.unpack("<Q", response.content)[0]