File size: 824 Bytes
b235afa
 
e1b6041
 
711fde0
 
4406c32
b235afa
711fde0
 
 
6a8a445
35d2c47
4406c32
35d2c47
 
4406c32
 
 
6a8a445
4406c32
 
 
 
 
 
 
 
 
711fde0
 
4406c32
711fde0
 
4406c32
 
 
 
 
b235afa
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
import gradio as gr

import ctransformers

class Z(object):
    def __init__(self):
        self.llm = None

    def init(self):
        pass

    def greet(self, txt0):
        prompt0 = txt0

        prompt00 = f'''USER: {prompt0}
ASSISTANT:'''
        
        response0 = llm(prompt00, max_new_tokens=128, temperature=0.5) # 0.3
        
        return f'{response0}'

from ctransformers import AutoModelForCausalLM

# wizzard vicuna
# see https://github.com/melodysdreamj/WizardVicunaLM
llm = AutoModelForCausalLM.from_pretrained('TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', model_file='Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', model_type='llama')




z = Z()
z.llm = llm
z.init()

def greet(arg0):
    global z
    return z.greet(arg0)

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