File size: 1,225 Bytes
7a60b69
85f10e3
 
7a60b69
 
 
85f10e3
7a60b69
 
85f10e3
7a60b69
 
 
85f10e3
 
 
 
 
 
 
7a60b69
 
85f10e3
7a60b69
 
 
 
85f10e3
 
 
7a60b69
85f10e3
 
7a60b69
85f10e3
 
 
7a60b69
 
85f10e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Alloy Maintenance AI - Simplified Version
Uses HuggingFace Inference API (no need to load full model)
"""

import gradio as gr
from huggingface_hub import InferenceClient

MODEL_NAME = "CodeMasterAbdul/alloy-phi3-steel-maintenance"
client = InferenceClient(model=MODEL_NAME)

def generate_response(prompt: str, max_tokens: int = 500, temperature: float = 0.3):
    try:
        response = client.text_generation(
            prompt,
            max_new_tokens=int(max_tokens),
            temperature=float(temperature),
            do_sample=temperature > 0,
            return_full_text=False
        )
        return response
    except Exception as e:
        return f"Error: {str(e)}\n\nModel may be loading. Try again in 30 seconds."

iface = gr.Interface(
    fn=generate_response,
    inputs=[
        gr.Textbox(label="Maintenance Query", lines=5),
        gr.Slider(50, 1000, 500, label="Max Tokens"),
        gr.Slider(0.0, 1.0, 0.3, label="Temperature")
    ],
    outputs=gr.Textbox(label="AI Response", lines=15),
    title="🏭 Alloy Maintenance AI",
    examples=[
        ["What causes bearing failure?", 500, 0.3],
        ["Explain vibration analysis", 500, 0.3],
    ]
)

iface.launch(show_api=True)