fix: remove message UTC validation temporarily to fix dev portal + add -d flag to docker compose up for tests (#1268)

This commit is contained in:
Sarah Wooders
2024-04-17 19:18:13 -07:00
committed by GitHub
parent ec7cf62d79
commit be50e44301
4 changed files with 33 additions and 29 deletions

View File

@@ -47,7 +47,7 @@ jobs:
MEMGPT_SERVER_PASS: test_server_token
MEMGPT_CONFIG_PATH: configs/server_config.yaml
run: docker compose up &
run: docker compose up -d
- name: Run server tests
env:

View File

@@ -57,26 +57,21 @@ def setup_agents_index_router(server: SyncServer, interface: QueuingInterface, p
interface.clear()
try:
try:
# print("YYY", request.config)
agent_state = server.create_agent(
user_id=user_id,
# **request.config
# TODO turn into a pydantic model
name=request.config["name"],
preset=request.config["preset"] if "preset" in request.config else None,
persona_name=request.config["persona_name"] if "persona_name" in request.config else None,
human_name=request.config["human_name"] if "human_name" in request.config else None,
persona=request.config["persona"] if "persona" in request.config else None,
human=request.config["human"] if "human" in request.config else None,
# llm_config=LLMConfigModel(
# model=request.config['model'],
# )
function_names=request.config["function_names"].split(",") if "function_names" in request.config else None,
)
except:
print(f"Failed to create agent from provided config:\n{request.config}")
raise
agent_state = server.create_agent(
user_id=user_id,
# **request.config
# TODO turn into a pydantic model
name=request.config["name"],
preset=request.config["preset"] if "preset" in request.config else None,
persona_name=request.config["persona_name"] if "persona_name" in request.config else None,
human_name=request.config["human_name"] if "human_name" in request.config else None,
persona=request.config["persona"] if "persona" in request.config else None,
human=request.config["human"] if "human" in request.config else None,
# llm_config=LLMConfigModel(
# model=request.config['model'],
# )
function_names=request.config["function_names"].split(",") if "function_names" in request.config else None,
)
llm_config = LLMConfigModel(**vars(agent_state.llm_config))
embedding_config = EmbeddingConfigModel(**vars(agent_state.embedding_config))

View File

@@ -34,13 +34,22 @@ class UserMessageRequest(BaseModel):
description="Timestamp to tag the message with (in ISO format). If null, timestamp will be created server-side on receipt of message.",
)
@validator("timestamp")
def validate_timestamp(cls, value: Any) -> Any:
if value.tzinfo is None or value.tzinfo.utcoffset(value) is None:
raise ValueError("Timestamp must include timezone information.")
if value.tzinfo.utcoffset(value) != datetime.fromtimestamp(timezone.utc).utcoffset():
raise ValueError("Timestamp must be in UTC.")
return value
# @validator("timestamp", pre=True, always=True)
# def validate_timestamp(cls, value: Optional[datetime]) -> Optional[datetime]:
# if value is None:
# return value # If the timestamp is None, just return None, implying default handling to set server-side
# if not isinstance(value, datetime):
# raise TypeError("Timestamp must be a datetime object with timezone information.")
# if value.tzinfo is None or value.tzinfo.utcoffset(value) is None:
# raise ValueError("Timestamp must be timezone-aware.")
# # Convert timestamp to UTC if it's not already in UTC
# if value.tzinfo.utcoffset(value) != timezone.utc.utcoffset(value):
# value = value.astimezone(timezone.utc)
# return value
class UserMessageResponse(BaseModel):

View File

@@ -106,7 +106,7 @@ def run_server():
@pytest.fixture(
params=[
{"base_url": local_service_url},
{"base_url": docker_compose_url}, # TODO: add when docker compose added to tests
# {"base_url": docker_compose_url}, # TODO: add when docker compose added to tests
# {"base_url": None} # TODO: add when implemented
],
scope="module",