-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
41 lines (31 loc) · 2.29 KB
/
Copy pathmodels.py
File metadata and controls
41 lines (31 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import annotations
from pydantic import BaseModel, Field
from typing import List, Optional
class LexRef(BaseModel):
headword: str = Field(description="The exact headword of the dictionary entry as recorded in the headword field, including exact vowels, numerals, and spacing. The exact headword is used to determine the precise dictionary entry.")
lexicon_name: str = Field(description="The name of the lexicon, as recorded in the parent_lexicon field")
def __eq__(self, other):
if not isinstance(other, LexRef):
return NotImplemented
return self.headword == other.headword and self.lexicon_name == other.lexicon_name
def __hash__(self):
# Return a hash based on the same fields used in __eq__
return hash((self.headword, self.lexicon_name))
class LexiconAssociations(BaseModel):
lexrefs: List[LexRef] = Field(description="The dictionary entries associated with the word form")
refs: List[str] = Field(description="The refs of the segments of text in which the word form appears")
reasoning: Optional[str] = Field(default=None, description="The reasoning behind the association of these entries")
class WordFormAssociations(BaseModel):
word: str = Field(description="The word form being associated with the dictionary entries")
associations: List[LexiconAssociations] = Field(description="The associations of the word form with dictionary entries")
class WordDetermination(BaseModel):
"""Record a determination of dictionary entries to keep, add and remove. This can only be used after all lookups have completed and determinations have been made. It can not be called with other tools. It is a terminal tool."""
word: str = Field(description="The word being determined")
reasoning: str = Field(description="The reasoning behind the determination")
entries_to_keep: List[LexRef] = Field(description="The dictionary entries to keep")
entries_to_remove: List[LexRef] = Field(description="The dictionary entries to remove")
entries_to_add: List[LexRef] = Field(description="The dictionary entries to add")
class PhrasesInSegment(BaseModel):
phrases: List[str] = Field(description="The phrases in the segment")
class BoolOutput(BaseModel):
value: bool = Field(description="The boolean result of the operation")