• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IBM / unitxt / 14911405902

08 May 2025 04:31PM UTC coverage: 80.074% (-0.07%) from 80.14%
14911405902

Pull #1773

github

web-flow
Merge e96fbbe15 into 2d15f20af
Pull Request #1773: Simplify tool calling base types

1645 of 2037 branches covered (80.76%)

Branch coverage included in aggregate %.

10250 of 12818 relevant lines covered (79.97%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.32
src/unitxt/types.py
1
from typing import Any, Dict, List, Literal, NewType, Optional, TypedDict, Union
1✔
2

3
from .type_utils import register_type
1✔
4

5
Text = NewType("Text", str)
1✔
6
Number = NewType("Number", Union[float, int])
1✔
7

8

9
class Turn(TypedDict):
1✔
10
    role: Literal["system", "user", "agent"]
1✔
11
    content: Text
1✔
12

13

14
class RagResponse(TypedDict):
1✔
15
    answer: str
1✔
16
    contexts: List[str]
1✔
17
    context_ids: Union[List[int], List[str]]
1✔
18
    is_answerable: bool
1✔
19

20

21
Dialog = NewType("Dialog", List[Turn])
1✔
22

23

24
class Image(TypedDict):
1✔
25
    image: Any
1✔
26
    format: str
1✔
27

28

29
class Document(TypedDict):
1✔
30
    title: str
1✔
31
    body: str
1✔
32

33

34
MultiDocument = NewType("MultiDocument", List[Document])
1✔
35

36
Video = NewType("Video", List[Image])
1✔
37

38

39
class Audio(TypedDict):
1✔
40
    audio: Any
1✔
41

42

43
class Table(TypedDict):
1✔
44
    header: List[str]
1✔
45
    rows: List[List[Any]]
1✔
46

47

48
class SQLDatabase(TypedDict):
1✔
49
    db_id: Optional[str]
1✔
50
    db_type: Literal["local", "in_memory", "remote"]
1✔
51
    dbms: Optional[str]
1✔
52
    data: Optional[Dict[str, Dict]]
1✔
53

54
class JsonSchema:
1✔
55

56
    @classmethod
1✔
57
    def __verify_type__(cls, object):
1✔
58
        if not isinstance(object, dict):
×
59
            return False
×
60
        import jsonschema_rs
×
61
        jsonschema_rs.meta.validate(object)
×
62
        return True
×
63

64
class Tool(TypedDict):
1✔
65
    name: str
1✔
66
    description: str
1✔
67
    parameters: JsonSchema
1✔
68

69
class ToolCall(TypedDict):
1✔
70
    name: str
1✔
71
    arguments: Dict[str, Any]
1✔
72

73
register_type(Text)
1✔
74
register_type(Number)
1✔
75
register_type(Turn)
1✔
76
register_type(Dialog)
1✔
77
register_type(Table)
1✔
78
register_type(Audio)
1✔
79
register_type(Image)
1✔
80
register_type(Video)
1✔
81
register_type(Document)
1✔
82
register_type(MultiDocument)
1✔
83
register_type(RagResponse)
1✔
84
register_type(SQLDatabase)
1✔
85
register_type(Tool)
1✔
86
register_type(JsonSchema)
1✔
87
register_type(ToolCall)
1✔
88

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc