File size: 526 Bytes
b2542ae
b4a8c77
b2542ae
b4a8c77
c66ed17
cc7dba3
c66ed17
 
b2542ae
cc7dba3
 
 
 
 
 
b2542ae
b4a8c77
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from os import name
import gradio as gr
from transformers import pipeline

# Load profiles once at module level
with open('Profiles/Python Translator.txt', 'r') as f:
    python_profile = f.read()

def greet(input_text):
    pipe = pipeline("text-generation", model="moonshotai/Kimi-K2-Thinking", trust_remote_code=True)
    messages = [
    {"role": python_profile, "content": input_text},
]
    pipe(messages)
    return pipe[0]['generated_text']
 

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()