missing parse history entries
This commit is contained in:
@@ -37,6 +37,29 @@ AGENT_TOOL_NAMES = [
|
|||||||
"py_get_hierarchy"
|
"py_get_hierarchy"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[dict[str, Any]]:
|
||||||
|
"""Parse stored history strings back to disc entry dicts."""
|
||||||
|
import re
|
||||||
|
entries = []
|
||||||
|
for raw in history_strings:
|
||||||
|
ts = ""
|
||||||
|
rest = raw
|
||||||
|
if rest.startswith("@"):
|
||||||
|
nl = rest.find("\n")
|
||||||
|
if nl != -1:
|
||||||
|
ts = rest[1:nl]
|
||||||
|
rest = rest[nl + 1:]
|
||||||
|
known = roles or ["User", "AI", "Vendor API", "System"]
|
||||||
|
role_pat = re.compile(r"^(" + "|".join(re.escape(r) for r in known) + r"):", re.IGNORECASE)
|
||||||
|
match = role_pat.match(rest)
|
||||||
|
role = match.group(1) if match else "User"
|
||||||
|
if match:
|
||||||
|
content = rest[match.end():].strip()
|
||||||
|
else:
|
||||||
|
content = rest
|
||||||
|
entries.append({"role": role, "content": content, "collapsed": False, "ts": ts})
|
||||||
|
return entries
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Ticket:
|
class Ticket:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user