|
@ -90,10 +90,11 @@ class AI(object): |
|
|
self.bot = bot |
|
|
self.bot = bot |
|
|
self.memory_path = memory_path |
|
|
self.memory_path = memory_path |
|
|
self.rooms = {} |
|
|
self.rooms = {} |
|
|
|
|
|
self.max_context = 2048 |
|
|
|
|
|
|
|
|
from ..wrappers.langchain_koboldcpp import KoboldCpp |
|
|
from ..wrappers.langchain_koboldcpp import KoboldCpp |
|
|
self.llm_chat = KoboldCpp(temperature=self.bot.temperature, endpoint_url="http://172.16.85.10:5001/api/latest/generate", stop=['<|endoftext|>'], verbose=True) |
|
|
self.llm_chat = KoboldCpp(temperature=self.bot.temperature, endpoint_url="http://172.16.85.10:5001/api/latest/generate", max_context=self.max_context, stop=['<|endoftext|>'], verbose=True) |
|
|
self.llm_summary = KoboldCpp(temperature=0.7, repeat_penalty=1.176, top_k = 40, top_p= 0.1, endpoint_url="http://172.16.85.10:5001/api/latest/generate", stop=['<|endoftext|>'], max_tokens=512, verbose=True) |
|
|
self.llm_summary = KoboldCpp(temperature=0.7, repeat_penalty=1.15, top_k = 20, top_p= 0.9, endpoint_url="http://172.16.85.10:5001/api/latest/generate", max_context=self.max_context, stop=['<|endoftext|>'], max_tokens=512, verbose=True) |
|
|
self.llm_chat_model = "pygmalion-7b" |
|
|
self.llm_chat_model = "pygmalion-7b" |
|
|
self.llm_summary_model = "vicuna-13b" |
|
|
self.llm_summary_model = "vicuna-13b" |
|
|
self.text_wrapper = text_wrapper |
|
|
self.text_wrapper = text_wrapper |
|
@ -122,7 +123,7 @@ class AI(object): |
|
|
last_message_ids_summarized = [] |
|
|
last_message_ids_summarized = [] |
|
|
if not human_prefix: |
|
|
if not human_prefix: |
|
|
human_prefix = "Human" |
|
|
human_prefix = "Human" |
|
|
memory = CustomMemory(memory_key="chat_history", input_key="input", human_prefix=human_prefix, ai_prefix=self.bot.name, llm=self.llm_summary, summary_prompt=prompt_progressive_summary, moving_summary_buffer=moving_summary, max_len=1200, min_len=200, last_message_ids_summarized=last_message_ids_summarized) |
|
|
memory = CustomMemory(memory_key="chat_history", input_key="input", human_prefix=human_prefix, ai_prefix=self.bot.name, llm=self.llm_summary, summary_prompt=prompt_progressive_summary, moving_summary_buffer=moving_summary, max_len=int(self.max_context-800), min_len=int(0.1*self.max_context), last_message_ids_summarized=last_message_ids_summarized) |
|
|
self.rooms[room_id]["memory"] = memory |
|
|
self.rooms[room_id]["memory"] = memory |
|
|
#memory.chat_memory.add_ai_message(self.bot.greeting) |
|
|
#memory.chat_memory.add_ai_message(self.bot.greeting) |
|
|
else: |
|
|
else: |
|
@ -251,7 +252,7 @@ class AI(object): |
|
|
tmp_prompt_text = prompt.format(chat_history=conversation_memory.buffer, input=message.content) |
|
|
tmp_prompt_text = prompt.format(chat_history=conversation_memory.buffer, input=message.content) |
|
|
prompt_len = self.llm_chat.get_num_tokens(tmp_prompt_text) |
|
|
prompt_len = self.llm_chat.get_num_tokens(tmp_prompt_text) |
|
|
|
|
|
|
|
|
if prompt_len+200 > 2048: |
|
|
if prompt_len+200 > self.max_context: |
|
|
logger.warning(f"Prompt too large. Estimated {prompt_len} tokens. Summarizing...") |
|
|
logger.warning(f"Prompt too large. Estimated {prompt_len} tokens. Summarizing...") |
|
|
await reply_fn(f"<WARNING> Prompt too large. Estimated {prompt_len} tokens") |
|
|
await reply_fn(f"<WARNING> Prompt too large. Estimated {prompt_len} tokens") |
|
|
if i == 0: |
|
|
if i == 0: |
|
@ -460,6 +461,8 @@ class AI(object): |
|
|
conversation_memory.chat_memory.messages.append(message) |
|
|
conversation_memory.chat_memory.messages.append(message) |
|
|
#conversation_memory.chat_memory.add_system_message(message) |
|
|
#conversation_memory.chat_memory.add_system_message(message) |
|
|
|
|
|
|
|
|
|
|
|
# [ 21:30 | Tuesday 9th | Pentagram City Alleys | 18°C | Overcast | 92% ] |
|
|
|
|
|
|
|
|
# Summarize the last day and save a diary entry |
|
|
# Summarize the last day and save a diary entry |
|
|
yesterday = ( datetime.now() - timedelta(days=1) ).strftime('%Y-%m-%d') |
|
|
yesterday = ( datetime.now() - timedelta(days=1) ).strftime('%Y-%m-%d') |
|
|
for room_id in self.rooms.keys(): |
|
|
for room_id in self.rooms.keys(): |
|
|