Update main.py
Browse files
main.py
CHANGED
|
@@ -1,27 +1,24 @@
|
|
| 1 |
from ctransformers import AutoModelForCausalLM
|
| 2 |
-
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
|
| 5 |
-
|
| 6 |
-
llm = AutoModelForCausalLM.from_pretrained("
|
| 7 |
model_type='mistral',
|
| 8 |
max_new_tokens = 1096,
|
| 9 |
threads = 3,
|
| 10 |
)
|
| 11 |
-
|
| 12 |
|
| 13 |
#Pydantic object
|
| 14 |
class validation(BaseModel):
|
| 15 |
prompt: str
|
| 16 |
-
|
| 17 |
#Fast API
|
| 18 |
app = FastAPI()
|
| 19 |
|
| 20 |
-
#Zephyr completion
|
| 21 |
@app.post("/llm_on_cpu")
|
| 22 |
async def stream(item: validation):
|
| 23 |
system_prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request.'
|
| 24 |
E_INST = "</s>"
|
| 25 |
user, assistant = "<|user|>", "<|assistant|>"
|
| 26 |
-
prompt = f"{system_prompt}{E_INST}\n{user}\n{item.prompt
|
| 27 |
return llm(prompt)
|
|
|
|
| 1 |
from ctransformers import AutoModelForCausalLM
|
| 2 |
+
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
|
| 5 |
+
|
| 6 |
+
llm = AutoModelForCausalLM.from_pretrained("noromaid-20b-v0.1.1.Q6_K.gguf",
|
| 7 |
model_type='mistral',
|
| 8 |
max_new_tokens = 1096,
|
| 9 |
threads = 3,
|
| 10 |
)
|
|
|
|
| 11 |
|
| 12 |
#Pydantic object
|
| 13 |
class validation(BaseModel):
|
| 14 |
prompt: str
|
|
|
|
| 15 |
#Fast API
|
| 16 |
app = FastAPI()
|
| 17 |
|
|
|
|
| 18 |
@app.post("/llm_on_cpu")
|
| 19 |
async def stream(item: validation):
|
| 20 |
system_prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request.'
|
| 21 |
E_INST = "</s>"
|
| 22 |
user, assistant = "<|user|>", "<|assistant|>"
|
| 23 |
+
prompt = f"{system_prompt}{E_INST}\n{user}\n{item.prompt}{E_INST}\n{assistant}\n"
|
| 24 |
return llm(prompt)
|