Update app.py
Browse files7 unmodified lines89101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778791 unmodified line818283848586878889909192937 unmodified lines"ROLE:\n""You are an Elite Minecraft Modding and Environment Diagnostician.\n""The user is an experienced modder. Do NOT provide basic IT advice.\n\n""GOAL:\n""Analyze Minecraft crash reports (latest.log, crash-reports, hs_err_pid) and pinpoint the exact root cause.\n""Identify whether the issue is caused by a specific mod, mod conflict, library, JVM configuration, or hardware/driver issue.\n\n""KNOWLEDGE DOMAINS:\n""1. Java/JVM & Environment:\n""- Detect incorrect Java versions (Java 8 vs 17 vs 21 mismatches).\n""- Identify GC overhead errors, invalid JVM flags, and memory leaks.\n""- Diagnose hs_err_pid crashes (native crashes, lwjgl corruption).\n\n""2. Hardware & OS:\n""- Diagnose EXCEPTION_ACCESS_VIOLATION (0xc0000005).\n""- Detect GL_OUT_OF_MEMORY and OpenGL issues.\n""- Identify wrong GPU usage (integrated vs dedicated).\n""- Detect outdated or incompatible graphics drivers.\n\n""3. Modloader & Mixins:\n""- Trace NoSuchMethodError, ClassNotFoundException, AbstractMethodError to exact modid.\n""- Analyze Mixin conflicts, failed injections, OVERWRITE/REDIRECT failures.\n""- Detect duplicate or incompatible mods.\n\n""4. Rendering Conflicts:\n""- Detect conflicts between OptiFine, Sodium/Rubidium/Embeddium, Iris/Oculus.\n\n""5. Data/Config Issues:\n""- Detect malformed JSON configs.\n""- Identify corrupted world data (level.dat).\n""- Detect missing dependencies or broken datapacks.\n\n""CONSTRAINTS:\n""- Do NOT guess.\n""- Do NOT hallucinate mod names or file paths.\n""- If stack trace shows net.minecraft.*, scan deeper to find injected mod.\n""- In Mixin conflicts, identify the actual instigator.\n""- Be concise and technical.\n\n""OUTPUT FORMAT:\n""1. Root Cause: One-line exact failure source.\n""2. Evidence: Exact log line, stack trace, or error code.\n""3. Fix: Direct actionable solution.\n")def respond(message, history, system_message, max_tokens, temperature, top_p, hf_token: gr.OAuthToken):client = InferenceClient(token=hf_token.token if hf_token else None, model=MODEL_ID)messages = [{"role": "system", "content": system_message}]for val in history:if val[0]: messages.append({"role": "user", "content": val[0]})if val[1]: messages.append({"role": "assistant", "content": val[1]})messages.append({"role": "user", "content": message})response = ""try:# Qwen models are very fast on the HF APIfor message_chunk in client.chat_completion(messages, max_tokens=max_tokens, stream=True, temperature=temperature, top_p=top_p):token = message_chunk.choices[0].delta.content or ""response += tokenyield responseexcept Exception as e:yield f"API Error: {str(e)}. Check if your HF Token is valid or if the model is currently loading."# Gradio Interfacewith gr.Blocks(theme=gr.themes.Monochrome()) as demo:gr.Markdown("# 🛠️ Minecraft Modding Log Analyzer")with gr.Sidebar():1 unmodified linegr.Markdown("---")system_msg = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, label="Modder Persona", lines=5)tokens = gr.Slider(128, 8192, value=2048, label="Max Log Length")temp = gr.Slider(0.1, 1.0, value=0.3, label="Creativity (Keep low for logs)")top_p = gr.Slider(0.1, 1.0, value=0.9, label="Top-P")gr.ChatInterface(respond,additional_inputs=[system_msg, tokens, temp, top_p],)if __name__ == "__main__":demo.launch()7 unmodified lines891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374751 unmodified line777879808182838485868788899091927 unmodified lines"ROLE:\n""You are an Elite Minecraft Modding and Environment Diagnostician.\n""The user is an experienced modder. Do NOT provide basic IT advice.\n\n""GOAL:\n""Analyze Minecraft crash reports (latest.log, crash-reports, hs_err_pid) and pinpoint the exact root cause.\n""Identify whether the issue is caused by a specific mod, mod conflict, library, JVM configuration, or hardware/driver issue.\n\n""KNOWLEDGE DOMAINS:\n""1. Java/JVM & Environment:\n""- Detect incorrect Java versions (Java 8 vs 17 vs 21 mismatches).\n""- Identify GC overhead errors, invalid JVM flags, and memory leaks.\n""- Diagnose hs_err_pid crashes (native crashes, lwjgl corruption).\n\n""2. Hardware & OS:\n""- Diagnose EXCEPTION_ACCESS_VIOLATION (0xc0000005).\n""- Detect GL_OUT_OF_MEMORY and OpenGL issues.\n""- Identify wrong GPU usage (integrated vs dedicated).\n""- Detect outdated or incompatible graphics drivers.\n\n""3. Modloader & Mixins:\n""- Trace NoSuchMethodError, ClassNotFoundException, AbstractMethodError to exact modid.\n""- Analyze Mixin conflicts, failed injections, OVERWRITE/REDIRECT failures.\n""- Detect duplicate or incompatible mods.\n\n""4. Rendering Conflicts:\n""- Detect conflicts between OptiFine, Sodium/Rubidium/Embeddium, Iris/Oculus.\n\n""5. Data/Config Issues:\n""- Detect malformed JSON configs.\n""- Identify corrupted world data (level.dat).\n""- Detect missing dependencies or broken datapacks.\n\n""CONSTRAINTS:\n""- Do NOT guess.\n""- Do NOT hallucinate mod names or file paths.\n""- If stack trace shows net.minecraft.*, scan deeper to find injected mod.\n""- In Mixin conflicts, identify the actual instigator.\n""- Be concise and technical.\n\n""OUTPUT FORMAT:\n""1. Root Cause: One-line exact failure source.\n""2. Evidence: Exact log line, stack trace, or error code.\n""3. Fix: Direct actionable solution.\n")def respond(message, history, system_message, max_tokens, temperature, top_p):# This retrieves the token from the session automatically if logged in via gr.LoginButtonclient = InferenceClient(model=MODEL_ID)messages = [{"role": "system", "content": system_message}]for user_msg, assistant_msg in history:if user_msg: messages.append({"role": "user", "content": user_msg})if assistant_msg: messages.append({"role": "assistant", "content": assistant_msg})messages.append({"role": "user", "content": message})response = ""try:for message_chunk in client.chat_completion(messages,max_tokens=max_tokens,stream=True,temperature=temperature,top_p=top_p):token = message_chunk.choices[0].delta.content or ""response += tokenyield responseexcept Exception as e:yield f"API Error: {str(e)}. Make sure you are logged in via the Sidebar."# Gradio Interfacewith gr.Blocks() as demo:gr.Markdown("# 🛠️ Minecraft Modding Log Analyzer")with gr.Sidebar():1 unmodified linegr.Markdown("---")system_msg = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, label="Modder Persona", lines=5)tokens = gr.Slider(128, 8192, value=2048, label="Max Log Length")temp = gr.Slider(0.1, 1.0, value=0.3, label="Creativity")top_p = gr.Slider(0.1, 1.0, value=0.9, label="Top-P")# The additional_inputs must exactly match the arguments in respond()# after 'message' and 'history'gr.ChatInterface(respond,additional_inputs=[system_msg, tokens, temp, top_p],)if __name__ == "__main__":# Theme is applied here for Gradio 6.0 compatibilitydemo.launch(theme=gr.themes.Monochrome())
app.py+18-19