Spaces:
Sleeping

eleeter commited on
Commit
63b2575
·
verified ·
1 Parent(s): d983dcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -33
app.py CHANGED
@@ -3,48 +3,24 @@ from huggingface_hub import InferenceClient
3
 
4
  MODEL_ID = "Qwen/Qwen2.5-Coder-32B-Instruct"
5
 
6
- # Tailored system prompt for a fellow modder
7
  DEFAULT_SYSTEM_PROMPT = (
8
  "ROLE:\n"
9
  "You are an Elite Minecraft Modding and Environment Diagnostician.\n"
10
  "The user is an experienced modder. Do NOT provide basic IT advice.\n\n"
11
  "GOAL:\n"
12
- "Analyze Minecraft crash reports (latest.log, crash-reports, hs_err_pid) and pinpoint the exact root cause.\n"
13
- "Identify whether the issue is caused by a specific mod, mod conflict, library, JVM configuration, or hardware/driver issue.\n\n"
14
- "KNOWLEDGE DOMAINS:\n"
15
- "1. Java/JVM & Environment:\n"
16
- "- Detect incorrect Java versions (Java 8 vs 17 vs 21 mismatches).\n"
17
- "- Identify GC overhead errors, invalid JVM flags, and memory leaks.\n"
18
- "- Diagnose hs_err_pid crashes (native crashes, lwjgl corruption).\n\n"
19
- "2. Hardware & OS:\n"
20
- "- Diagnose EXCEPTION_ACCESS_VIOLATION (0xc0000005).\n"
21
- "- Detect GL_OUT_OF_MEMORY and OpenGL issues.\n"
22
- "- Identify wrong GPU usage (integrated vs dedicated).\n"
23
- "- Detect outdated or incompatible graphics drivers.\n\n"
24
- "3. Modloader & Mixins:\n"
25
- "- Trace NoSuchMethodError, ClassNotFoundException, AbstractMethodError to exact modid.\n"
26
- "- Analyze Mixin conflicts, failed injections, OVERWRITE/REDIRECT failures.\n"
27
- "- Detect duplicate or incompatible mods.\n\n"
28
- "4. Rendering Conflicts:\n"
29
- "- Detect conflicts between OptiFine, Sodium/Rubidium/Embeddium, Iris/Oculus.\n\n"
30
- "5. Data/Config Issues:\n"
31
- "- Detect malformed JSON configs.\n"
32
- "- Identify corrupted world data (level.dat).\n"
33
- "- Detect missing dependencies or broken datapacks.\n\n"
34
  "CONSTRAINTS:\n"
35
  "- Do NOT guess.\n"
36
- "- Do NOT hallucinate mod names or file paths.\n"
37
- "- If stack trace shows net.minecraft.*, scan deeper to find injected mod.\n"
38
- "- In Mixin conflicts, identify the actual instigator.\n"
39
  "- Be concise and technical.\n\n"
40
  "OUTPUT FORMAT:\n"
41
  "1. Root Cause: One-line exact failure source.\n"
42
- "2. Evidence: Exact log line, stack trace, or error code.\n"
43
  "3. Fix: Direct actionable solution.\n"
44
  )
45
 
 
46
  def respond(message, history, system_message, max_tokens, temperature, top_p):
47
- # This retrieves the token from the session automatically if logged in via gr.LoginButton
48
  client = InferenceClient(model=MODEL_ID)
49
 
50
  messages = [{"role": "system", "content": system_message}]
@@ -66,9 +42,8 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
66
  response += token
67
  yield response
68
  except Exception as e:
69
- yield f"API Error: {str(e)}. Make sure you are logged in via the Sidebar."
70
 
71
- # Gradio Interface
72
  with gr.Blocks() as demo:
73
  gr.Markdown("# 🛠️ Minecraft Modding Log Analyzer")
74
 
@@ -80,13 +55,11 @@ with gr.Blocks() as demo:
80
  temp = gr.Slider(0.1, 1.0, value=0.3, label="Creativity")
81
  top_p = gr.Slider(0.1, 1.0, value=0.9, label="Top-P")
82
 
83
- # The additional_inputs must exactly match the arguments in respond()
84
- # after 'message' and 'history'
85
  gr.ChatInterface(
86
  respond,
87
  additional_inputs=[system_msg, tokens, temp, top_p],
88
  )
89
 
90
  if __name__ == "__main__":
91
- # Theme is applied here for Gradio 6.0 compatibility
92
  demo.launch(theme=gr.themes.Monochrome())
 
3
 
4
  MODEL_ID = "Qwen/Qwen2.5-Coder-32B-Instruct"
5
 
 
6
  DEFAULT_SYSTEM_PROMPT = (
7
  "ROLE:\n"
8
  "You are an Elite Minecraft Modding and Environment Diagnostician.\n"
9
  "The user is an experienced modder. Do NOT provide basic IT advice.\n\n"
10
  "GOAL:\n"
11
+ "Analyze Minecraft crash reports (latest.log, crash-reports, hs_err_pid) and pinpoint the exact root cause.\n\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  "CONSTRAINTS:\n"
13
  "- Do NOT guess.\n"
 
 
 
14
  "- Be concise and technical.\n\n"
15
  "OUTPUT FORMAT:\n"
16
  "1. Root Cause: One-line exact failure source.\n"
17
+ "2. Evidence: Exact log line or stack trace.\n"
18
  "3. Fix: Direct actionable solution.\n"
19
  )
20
 
21
+ # FIXED: Removed hf_token from arguments to match your Java payload (6 args total)
22
  def respond(message, history, system_message, max_tokens, temperature, top_p):
23
+ # The client will use the Space's internal token automatically
24
  client = InferenceClient(model=MODEL_ID)
25
 
26
  messages = [{"role": "system", "content": system_message}]
 
42
  response += token
43
  yield response
44
  except Exception as e:
45
+ yield f"API Error: {str(e)}"
46
 
 
47
  with gr.Blocks() as demo:
48
  gr.Markdown("# 🛠️ Minecraft Modding Log Analyzer")
49
 
 
55
  temp = gr.Slider(0.1, 1.0, value=0.3, label="Creativity")
56
  top_p = gr.Slider(0.1, 1.0, value=0.9, label="Top-P")
57
 
58
+ # FIXED: ChatInterface now passes exactly 6 arguments to respond()
 
59
  gr.ChatInterface(
60
  respond,
61
  additional_inputs=[system_msg, tokens, temp, top_p],
62
  )
63
 
64
  if __name__ == "__main__":
 
65
  demo.launch(theme=gr.themes.Monochrome())