File size: 1,276 Bytes
3a9413b
a444fc3
 
3a9413b
fe09faf
a444fc3
d6d86b8
fe09faf
a444fc3
 
 
 
 
bfb8bae
3a9413b
a444fc3
fe09faf
a444fc3
fe09faf
a444fc3
 
 
 
 
 
d6d86b8
fe09faf
a444fc3
fe09faf
3a9413b
a444fc3
d6d86b8
fe09faf
 
 
 
 
 
 
3a9413b
d6d86b8
 
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
42
import gradio as gr
import torch
from transformers import pipeline

# Model: Gemma 2B for efficiency
model_id = "google/gemma-2-2b-it"

# Initialize Pipeline
pipe = pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",
)

def specialist_respond(message, history):
    system_prompt = "You are MINZO-PRIME, a highly advanced AI developed under the INACHI AI project. Be technical and precise."
    
    # Format message history
    messages = [{"role": "system", "content": system_prompt}]
    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})
    
    # Generate
    prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    outputs = pipe(prompt, max_new_tokens=512, do_sample=True, temperature=0.7)
    
    return outputs[0]["generated_text"][len(prompt):]

# πŸ”± UI Setup
demo = gr.ChatInterface(
    fn=specialist_respond,
    title="INACHI-CORE V1.0",
    description="Authorized Access Only: MINZO-PRIME",
    theme="soft"
)

if __name__ == "__main__":
    demo.launch()