Spaces:
Runtime error
Runtime error
File size: 1,002 Bytes
580a5a7 67628a6 580a5a7 71e4921 67628a6 71e4921 67628a6 580a5a7 fe9bde4 580a5a7 abff1a0 580a5a7 abff1a0 fe9bde4 abff1a0 580a5a7 fe9bde4 580a5a7 fe9bde4 580a5a7 abff1a0 fe9bde4 580a5a7 fe9bde4 |
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
from llama_cpp import Llama
# Load the model
llm = Llama.from_pretrained(
repo_id="bartowski/Marco-o1-GGUF",
filename="Marco-o1-Q4_K_M.gguf",
)
# Access the tokenizer from the Llama model
tokenizer = llm.get_tokenizer()
def respond(
message,
history: list[tuple[str, str]],
system_message,
max_tokens,
temperature,
top_p,
):
# Initialize an empty list to hold tokenized messages
tokenized_messages = []
# Tokenize the system message
tokenized_messages.append(tokenizer.encode(system_message))
# Tokenize the history messages
for val in history:
if val[0]:
tokenized_messages.append(tokenizer.encode(val[0])) # User message
if val[1]:
tokenized_messages.append(tokenizer.encode(val[1])) # Assistant message
# Tokenize the current user message
tokenized_messages.append(tokenizer.encode(message))
response = ""
# Use llm.create_completion with tokenized message
|