File size: 988 Bytes
fd282d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer

class CatGPT:
    def __init__(self, model_name="OrionStarAI/Orion-14B"):
        self.model_name = model_name
        self.tokenizer = AutoTokenizer.from_pretrained(model_name)
        self.model = AutoModelForCausalLM.from_pretrained(model_name)

    def generate(self, prompt, max_length=100):
        inputs = self.tokenizer(prompt, return_tensors="pt")
        outputs = self.model.generate(inputs.input_ids, max_length=max_length)
        response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
        return response

# Instantiate CatGPT
catgpt = CatGPT()

def catgpt_response(prompt):
    return catgpt.generate(prompt)

# Gradio Interface
iface = gr.Interface(
    fn=catgpt_response,
    inputs="text",
    outputs="text",
    title="CatGPT - Orion-14B Demo",
    description="This is a CatGPT demo using the Orion-14B model from OrionStarAI."
)

# Launch the app
iface.launch()