-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompts.py
52 lines (38 loc) · 2.01 KB
/
prompts.py
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
41
42
43
44
45
46
47
48
49
50
51
52
OBJECT_EXTRACTION_PROMPT = """Extract all entities from the following document.
An entity should have a name, type (such as person, location etc) and a description.
Also identify relationships between the entities.
For each relationship, provide the from entity, to entity, relationship label, and strength (0.0 to 1.0).
An Entity and a Relationship object should conform to the following pydantic definition:
class Entity(BaseModel):
name: str = Field(..., title="name of the entity")
type: str = Field(..., title="type of the entity")
description: Optional[str] = Field(..., title="description of the entity")
class Relationship(BaseModel):
from_entity: Entity = Field(..., title="starting entity for relationship")
to_entity: Entity = Field(..., title="target entity for relationship")
label: Optional[str] = Field(..., title="relationship label")
strength: Optional[float] = Field(
..., title="strength of relationship", ge=0.0, le=1.0
)
"""
SUMMARY_PROMPT = """Summarise the following entities and relationships into a concise list of Objects.
Prioritise Quality of Quantity. Make sure to deduplicate entities and relationships.
Remember, Entity, Relationship and Object are pydantic models:
class Entity(BaseModel):
name: str = Field(..., title="name of the entity")
type: str = Field(..., title="type of the entity")
description: Optional[str] = Field(..., title="description of the entity")
class Relationship(BaseModel):
from_entity: Entity = Field(..., title="starting entity for relationship")
to_entity: Entity = Field(..., title="target entity for relationship")
label: Optional[str] = Field(..., title="relationship label")
strength: Optional[float] = Field(
..., title="strength of relationship", ge=0.0, le=1.0
)
class ObjectType(Enum):
ENTITY = "entity"
RELATIONSHIP = "relationship"
class Object(BaseModel):
type: ObjectType = Field(..., title="object type")
object: Entity | Relationship = Field(..., title="object instance")
"""