|
import gradio as gr |
|
|
|
import ctransformers |
|
|
|
class Z(object): |
|
def __init__(self): |
|
self.llm = None |
|
|
|
def init(self): |
|
pass |
|
|
|
def run0(self, txt0, paramTemp): |
|
prompt0 = txt0 |
|
|
|
|
|
prompt00 = f'''USER: {prompt0} |
|
ASSISTANT:''' |
|
|
|
|
|
prompt00 = f'''Below is an instruction that describes a task. Write a response that appropriately completes the request. |
|
|
|
### Instruction: |
|
{prompt0} |
|
|
|
### Response:''' |
|
|
|
|
|
prompt00 = prompt0 |
|
|
|
response0 = llm(prompt00, max_new_tokens=198, temperature=paramTemp) |
|
|
|
return f'{response0}' |
|
|
|
from ctransformers import AutoModelForCausalLM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modelInfo = {'path2':'TheBloke/hippogriff-30b-chat-GGML:hippogriff-30b.ggmlv3.q4_1.bin', 'promptType':'raw', 'modelType':'llama'} |
|
|
|
print('[D] load LMt...') |
|
|
|
llm = AutoModelForCausalLM.from_pretrained(modelInfo['path2'].split(':')[0], model_file=modelInfo['path2'].split(':')[1], model_type=modelInfo['modelType']) |
|
|
|
print('[D] ...done') |
|
|
|
|
|
z = Z() |
|
z.llm = llm |
|
z.init() |
|
|
|
def run0(prompt, temperature): |
|
global z |
|
return z.run0(prompt, temperature) |
|
|
|
iface = gr.Interface(fn=run0, inputs=["text", gr.Slider(0.0, 1.0, value=0.41)], outputs="text") |
|
iface.launch() |