1
0
Fork 0

increase memory limit

This commit is contained in:
Sean Sube 2024-05-26 22:42:08 -05:00
parent bd42c115b4
commit dd0e4ed573
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 16 additions and 3 deletions

View File

@ -1,10 +1,12 @@
import atexit
from functools import partial
from logging.config import dictConfig
from os import environ, path
from typing import List
from dotenv import load_dotenv
from packit.agent import Agent, agent_easy_connect
from packit.memory import make_limited_memory
from packit.utils import logger_with_colors
from adventure.utils.file import load_yaml
@ -43,8 +45,12 @@ if True:
from adventure.models.files import PromptFile, WorldPrompt
from adventure.plugins import load_plugin
from adventure.simulate import simulate_world
from adventure.state import create_agents, save_world, save_world_state
from adventure.state import (
MEMORY_LIMIT,
create_agents,
save_world,
save_world_state,
)
# start the debugger, if needed
if environ.get("DEBUG", "false").lower() == "true":
@ -55,6 +61,9 @@ if environ.get("DEBUG", "false").lower() == "true":
debugpy.wait_for_client()
memory_factory = partial(make_limited_memory, limit=MEMORY_LIMIT)
def int_or_inf(value: str) -> float | int:
if value == "inf":
return float("inf")
@ -224,6 +233,7 @@ def load_or_generate_world(
f"{world_prompt.flavor}. The theme is: {world_prompt.theme}.",
{},
llm,
memory_factory=memory_factory,
)
if path.exists(world_state_file):
@ -372,6 +382,7 @@ def main():
),
{},
llm,
memory_factory=memory_factory,
)
set_dungeon_master(world_builder)

View File

@ -11,6 +11,8 @@ from adventure.context import get_all_character_agents, set_character_agent
from adventure.models.entity import World
from adventure.player import LocalPlayer
MEMORY_LIMIT = 25 # 10
def create_agents(
world: World,
@ -83,7 +85,7 @@ def restore_memory(
elif memory_type == "ai":
memories.append(AIMessage(content=memory_content))
return deque(memories, maxlen=10)
return deque(memories, maxlen=MEMORY_LIMIT)
def save_world(world, filename):