Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,35 @@ import ctransformers
|
|
| 4 |
|
| 5 |
class Z(object):
|
| 6 |
def __init__(self):
|
| 7 |
-
|
| 8 |
|
| 9 |
def init(self):
|
| 10 |
pass
|
| 11 |
|
| 12 |
def greet(name):
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
z = Z()
|
|
|
|
| 16 |
z.init()
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
iface.launch()
|
|
|
|
| 4 |
|
| 5 |
class Z(object):
|
| 6 |
def __init__(self):
|
| 7 |
+
self.llm = None
|
| 8 |
|
| 9 |
def init(self):
|
| 10 |
pass
|
| 11 |
|
| 12 |
def greet(name):
|
| 13 |
+
|
| 14 |
+
prompt00 = 'What is a Frog? Answer:'
|
| 15 |
+
|
| 16 |
+
response0 = llm(prompt00, max_new_tokens=128, temperature=0.5) # 0.3
|
| 17 |
+
|
| 18 |
+
return f'Hi {response0}'
|
| 19 |
+
|
| 20 |
+
from ctransformers import AutoModelForCausalLM
|
| 21 |
+
|
| 22 |
+
# wizzard vicuna
|
| 23 |
+
# see https://github.com/melodysdreamj/WizardVicunaLM
|
| 24 |
+
llm = AutoModelForCausalLM.from_pretrained('TheBloke/Wizard-Vicuna-7B-Uncensored-GGML', model_file='Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin', model_type='llama')
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
|
| 29 |
z = Z()
|
| 30 |
+
z.llm = llm
|
| 31 |
z.init()
|
| 32 |
|
| 33 |
+
def greet(arg0):
|
| 34 |
+
global z
|
| 35 |
+
return z.greet(arg0)
|
| 36 |
+
|
| 37 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 38 |
iface.launch()
|