Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 8 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 15 additions & 20 deletions memgpt/server/rest_api/agents/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,21 @@ def create_agent(
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))

Expand Down
23 changes: 16 additions & 7 deletions memgpt/server/rest_api/agents/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading