muhammadtlha944 commited on
Commit
365332a
ยท
verified ยท
1 Parent(s): 7b608e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -3,17 +3,16 @@ import requests
3
  import time
4
 
5
  # --- CONFIGURATION ---
6
- # Replace with your actual URLs
7
  DROPLET_IP = "134.199.195.151"
8
  API_URL = "https://djrbe-134-199-192-140.run.pinggy-free.link/translate"
9
- LABLAB_URL = "https://lablab.ai/event/amd-ai-hackathon/ghost-coder" # Update this link!
 
10
 
11
  # --- LOGIC ---
12
  def ghost_translate(cuda_code):
13
  yield "๐Ÿ‘ป Ghost-Coder: Analyzing CUDA Kernel...", "Loading..."
14
 
15
  try:
16
- # Standard marker for backend slicing
17
  split_marker = "// --- GHOST-CODER HIP OUTPUT ---"
18
 
19
  formatted_prompt = f"""Task: Translate the following CUDA code to AMD HIP.
@@ -30,13 +29,11 @@ Output ONLY valid C++ code. Do not include markdown blocks or explanations.
30
  if response.status_code == 200:
31
  raw_response = response.json().get("hip_code", "")
32
 
33
- # Hard Slice logic to ensure clean output
34
  if split_marker in raw_response:
35
  hip_code = raw_response.split(split_marker)[-1].strip()
36
  else:
37
  hip_code = raw_response.strip()
38
 
39
- # Agentic Visual Feedback
40
  yield "๐Ÿ”„ Analyzing HIP logic on ROCm stack...", "Generating..."
41
  time.sleep(1)
42
  yield "๐Ÿ› ๏ธ Verifying syntax and memory offsets...", "Verifying..."
@@ -49,15 +46,15 @@ Output ONLY valid C++ code. Do not include markdown blocks or explanations.
49
  yield f"โŒ Connection Error: Ensure bridge is running", str(e)
50
 
51
  # --- UI DESIGN ---
52
- with gr.Blocks(css=".banner { margin-bottom: 20px; }") as demo:
 
53
 
54
- # Header Banner - Wrapped for maximum compatibility
55
  with gr.Row():
56
  gr.HTML(f"""
57
  <div style="background-color: #fff3cd; color: #856404; padding: 20px; border-radius: 8px; border: 1px solid #ffeeba; width: 100%; text-align: center; font-family: sans-serif;">
58
  <span style="font-size: 1.2em;">โš ๏ธ <strong>Demo Status: GPU Backend Paused</strong></span><br>
59
  <p style="margin-top: 10px; color: #856404;">The AMD MI300X instance for this live demo has been paused following the conclusion of the hackathon credit period.</p>
60
- <a href="https://lablab.ai/ai-hackathons/amd-developer/amd-ghost-coder-cuda-to-rocm-ai-migration/ghost-coder-autonomous-cuda-to-hip-agent" target="_blank" style="display: inline-block; background-color: #856404; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; margin-top: 5px;">View Full Video Demo & Technical Pitch</a>
61
  </div>
62
  """)
63
 
@@ -78,9 +75,12 @@ with gr.Blocks(css=".banner { margin-bottom: 20px; }") as demo:
78
  output_code = gr.Code(label="Generated HIP Code", language="cpp", lines=15)
79
  logs = gr.Textbox(label="Agent Status & Self-Healing Logs", interactive=False)
80
 
81
- # UI Action
82
  run_btn.click(ghost_translate, inputs=[input_code], outputs=[logs, output_code])
83
 
84
- # Launch configuration
85
  if __name__ == "__main__":
86
- demo.queue().launch(show_api=False)
 
 
 
 
 
3
  import time
4
 
5
  # --- CONFIGURATION ---
 
6
  DROPLET_IP = "134.199.195.151"
7
  API_URL = "https://djrbe-134-199-192-140.run.pinggy-free.link/translate"
8
+ # Your exact Lablab URL
9
+ LABLAB_URL = "https://lablab.ai/ai-hackathons/amd-developer/amd-ghost-coder-cuda-to-rocm-ai-migration/ghost-coder-autonomous-cuda-to-hip-agent"
10
 
11
  # --- LOGIC ---
12
  def ghost_translate(cuda_code):
13
  yield "๐Ÿ‘ป Ghost-Coder: Analyzing CUDA Kernel...", "Loading..."
14
 
15
  try:
 
16
  split_marker = "// --- GHOST-CODER HIP OUTPUT ---"
17
 
18
  formatted_prompt = f"""Task: Translate the following CUDA code to AMD HIP.
 
29
  if response.status_code == 200:
30
  raw_response = response.json().get("hip_code", "")
31
 
 
32
  if split_marker in raw_response:
33
  hip_code = raw_response.split(split_marker)[-1].strip()
34
  else:
35
  hip_code = raw_response.strip()
36
 
 
37
  yield "๐Ÿ”„ Analyzing HIP logic on ROCm stack...", "Generating..."
38
  time.sleep(1)
39
  yield "๐Ÿ› ๏ธ Verifying syntax and memory offsets...", "Verifying..."
 
46
  yield f"โŒ Connection Error: Ensure bridge is running", str(e)
47
 
48
  # --- UI DESIGN ---
49
+ # Removed 'css' from here to fix the UserWarning
50
+ with gr.Blocks() as demo:
51
 
 
52
  with gr.Row():
53
  gr.HTML(f"""
54
  <div style="background-color: #fff3cd; color: #856404; padding: 20px; border-radius: 8px; border: 1px solid #ffeeba; width: 100%; text-align: center; font-family: sans-serif;">
55
  <span style="font-size: 1.2em;">โš ๏ธ <strong>Demo Status: GPU Backend Paused</strong></span><br>
56
  <p style="margin-top: 10px; color: #856404;">The AMD MI300X instance for this live demo has been paused following the conclusion of the hackathon credit period.</p>
57
+ <a href="{LABLAB_URL}" target="_blank" style="display: inline-block; background-color: #856404; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-weight: bold; margin-top: 5px;">View Full Video Demo & Technical Pitch</a>
58
  </div>
59
  """)
60
 
 
75
  output_code = gr.Code(label="Generated HIP Code", language="cpp", lines=15)
76
  logs = gr.Textbox(label="Agent Status & Self-Healing Logs", interactive=False)
77
 
 
78
  run_btn.click(ghost_translate, inputs=[input_code], outputs=[logs, output_code])
79
 
80
+ # --- LAUNCH CONFIG ---
81
  if __name__ == "__main__":
82
+ # Moved css here and removed show_api=False to fix the TypeError
83
+ demo.queue().launch(
84
+ css=".banner { margin-bottom: 20px; }",
85
+ theme=gr.themes.Soft()
86
+ )