Delete main.py
Browse files
main.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI, Request
|
| 2 |
-
from llama_cpp import Llama
|
| 3 |
-
from moderator import check_for_hate
|
| 4 |
-
|
| 5 |
-
app = FastAPI()
|
| 6 |
-
llm = Llama(model_path="models/mistral-7b-instruct.Q4_K_M.gguf", n_ctx=2048)
|
| 7 |
-
|
| 8 |
-
@app.post("/chat")
|
| 9 |
-
async def chat(request: Request):
|
| 10 |
-
data = await request.json()
|
| 11 |
-
user_input = data.get("message", "")
|
| 12 |
-
|
| 13 |
-
if check_for_hate(user_input):
|
| 14 |
-
return {"response": "I don't entertain hate, denial, or fascist ideology. Let's talk about something human instead."}
|
| 15 |
-
|
| 16 |
-
prompt = f"[INST] You are Sol, a smart, ethical, and no-nonsense AI assistant. You speak honestly and never support hate or Nazism. Answer the following:\n{user_input} [/INST]"
|
| 17 |
-
output = llm(prompt, max_tokens=512)
|
| 18 |
-
return {"response": output["choices"][0]["text"].strip()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|