mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
add handle_exception
This commit is contained in:
parent
ea9582cf0e
commit
a16535fb08
1 changed files with 5 additions and 3 deletions
|
|
@ -7,13 +7,14 @@
|
|||
@Modified By: mashenquan, 2023-11-1. According to RFC 116: Updated the type of index key.
|
||||
"""
|
||||
from collections import defaultdict
|
||||
from typing import DefaultDict, Iterable, Set
|
||||
from typing import DefaultDict, Iterable, Optional, Set
|
||||
|
||||
from pydantic import BaseModel, Field, SerializeAsAny
|
||||
|
||||
from metagpt.const import IGNORED_MESSAGE_ID
|
||||
from metagpt.schema import Message
|
||||
from metagpt.utils.common import any_to_str, any_to_str_set
|
||||
from metagpt.utils.exceptions import handle_exception
|
||||
|
||||
|
||||
class Memory(BaseModel):
|
||||
|
|
@ -105,6 +106,7 @@ class Memory(BaseModel):
|
|||
rsp += self.index[action]
|
||||
return rsp
|
||||
|
||||
def get_by_position(self, position: int) -> Message:
|
||||
"""Return the message by its position"""
|
||||
@handle_exception
|
||||
def get_by_position(self, position: int) -> Optional[Message]:
|
||||
"""Returns the message at the given position if valid, otherwise returns None"""
|
||||
return self.storage[position]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue