Files
PyLlama/chat_session.py
T
2026-03-23 05:29:18 +01:00

29 lines
886 B
Python

class ChatSettings():
def __init__(self):
self.num_gpu: int = 15
self.low_vram: bool = False
self.num_thread: int = 0
self.temperature: int = 1.0
self.system_prompt: str = None
def convert_to_ollama(self):
return {
"num_gpu": self.num_gpu,
"low_vram": self.low_vram,
"num_thread": self.num_thread,
"temperature": self.temperature,
}
class ChatSession():
def __init__(self, model_name):
self.model_name: str = model_name
self.history = []
self.settings: ChatSettings = ChatSettings()
def push_history(self, text: str, role: str = "user"):
if not self.history or self.history[-1]["role"] != role:
self.history.append({"role": role, "content": text})
else:
self.history[-1]["content"] += text