File tree Expand file tree Collapse file tree 6 files changed +177
-186
lines changed Expand file tree Collapse file tree 6 files changed +177
-186
lines changed Original file line number Diff line number Diff line change 71
71
- id : mypy
72
72
additional_dependencies :
73
73
- fastapi>=0.109 # Match pyproject.toml
74
- - fhaviary
74
+ - fhaviary>=0.6 # Match pyproject.toml
75
75
- httpx
76
76
- litellm>=1.40.9,<=1.40.12 # Match pyproject.toml
77
77
- numpy
Original file line number Diff line number Diff line change 1
1
import logging
2
2
from typing import Any , Self , cast
3
3
4
- from aviary .message import Message
4
+ from aviary .message import MalformedMessageError , Message
5
5
from aviary .tools import Tool , ToolRequestMessage , ToolResponseMessage
6
6
from pydantic import BaseModel , ConfigDict , Field
7
7
from tenacity import (
16
16
from ldp .graph .modules .react import (
17
17
ACT_DEFAULT_PROMPT_TEMPLATE ,
18
18
REACT_DEFAULT_PROMPT_TEMPLATE ,
19
- MalformedMessageError ,
20
19
ReActModule ,
21
20
ToolDescriptionMethods ,
22
21
)
Original file line number Diff line number Diff line change 6
6
7
7
from .llm_call import ParsedLLMCallModule
8
8
from .react import (
9
- MalformedMessageError ,
10
9
ReActModule ,
11
10
ToolDescriptionMethods ,
12
11
parse_message ,
15
14
from .thought import ThoughtModule
16
15
17
16
__all__ = [
18
- "MalformedMessageError" ,
19
17
"ParsedLLMCallModule" ,
20
18
"ReActModule" ,
21
19
"ReflectModule" ,
Original file line number Diff line number Diff line change 1
1
import ast
2
- import logging
3
2
import re
4
3
import textwrap
5
4
from collections .abc import Iterable
6
5
from enum import StrEnum
7
6
from typing import Any
8
7
9
- from aviary .message import Message
8
+ from aviary .message import EMPTY_CONTENT_BASE_MSG , MalformedMessageError , Message
10
9
from aviary .tools import Tool , ToolCall , ToolRequestMessage
11
10
12
11
from ldp .graph .common_ops import FxnOp , PromptOp
59
58
)
60
59
61
60
62
- class MalformedMessageError (ValueError ):
63
- """Error to throw if some aspect of a ToolRequestMessage is malformed."""
64
-
65
- @classmethod
66
- def react_parser_log_filter (cls , record : logging .LogRecord ) -> bool :
67
- """
68
- Filter out common parsing failures not worth looking into from logs.
69
-
70
- Returns:
71
- False if the LogRecord should be filtered out, otherwise True to keep it.
72
- """
73
- # NOTE: match both this Exception type's name and its content, to be robust
74
- return not all (x in record .msg for x in (cls .__name__ , EMPTY_CONTENT_BASE_MSG ))
75
-
76
-
77
- # Define separately so we can filter out this message type
78
- EMPTY_CONTENT_BASE_MSG = "No content in message"
79
-
80
-
81
61
def parse_message (m : Message , tools : list [Tool ]) -> ToolRequestMessage : # noqa: C901
82
62
"""
83
63
Parse an Act or ReAct Message into a ToolRequestMessage.
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ classifiers = [
17
17
dependencies = [
18
18
" aiofiles" ,
19
19
" dm-tree" ,
20
- " fhaviary" ,
20
+ " fhaviary>=0.6 " , # For MalformedMessageError
21
21
" httpx" ,
22
22
" litellm" ,
23
23
" networkx[default]~=3.0" , # Pin just to keep recent
You can’t perform that action at this time.
0 commit comments