-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
866f91f
commit 2c04ab5
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from typing import Protocol, TypedDict | ||
|
||
from .models import Message, PromptFunction, PromptVersion | ||
|
||
|
||
class Prompt(Protocol): | ||
v1: PromptVersion | ||
|
||
|
||
class Versions(TypedDict): | ||
v1: PromptFunction | ||
|
||
|
||
def v1(context: dict[str, any]) -> list[Message]: | ||
return [ | ||
Message( | ||
role='system', | ||
content='You are an AI assistant that extracts datetime information for graph edges, focusing only on dates directly related to the establishment or change of the relationship described in the edge fact.', | ||
), | ||
Message( | ||
role='user', | ||
content=f""" | ||
Edge: | ||
Source Node: {context['source_node']} | ||
Edge Name: {context['edge_name']} | ||
Target Node: {context['target_node']} | ||
Fact: {context['edge_fact']} | ||
Current Episode: {context['current_episode']} | ||
Previous Episodes: {context['previous_episodes']} | ||
Reference Timestamp: {context['reference_timestamp']} | ||
IMPORTANT: Only extract dates that are part of the provided fact. Otherwise ignore the date. | ||
Definitions: | ||
- valid_at: The date and time when the relationship described by the edge fact became true or was established. | ||
- invalid_at: The date and time when the relationship described by the edge fact stopped being true or ended. | ||
Task: | ||
Analyze the conversation and determine if there are dates that are part of the edge fact. Only set dates if they explicitly relate to the formation or alteration of the relationship itself. | ||
Guidelines: | ||
1. Use ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ) for datetimes. | ||
2. Use the reference timestamp as the current time when determining the valid_at and invalid_at dates. | ||
3. If no relevant dates are found that explicitly establish or change the relationship, leave the fields as null. | ||
4. Do not infer dates from related events. Only use dates that are directly stated to establish or change the relationship. | ||
5. For relative time mentions directly related to the relationship, calculate the actual datetime based on the reference timestamp. | ||
6. If only a date is mentioned without a specific time, use 00:00:00 (midnight) for that date. | ||
7. If only a year is mentioned, use January 1st of that year at 00:00:00. | ||
9. Always include the time zone offset (use Z for UTC if no specific time zone is mentioned). | ||
Respond with a JSON object: | ||
{{ | ||
"valid_at": "YYYY-MM-DDTHH:MM:SSZ or null", | ||
"invalid_at": "YYYY-MM-DDTHH:MM:SSZ or null", | ||
"explanation": "Brief explanation of why these dates were chosen or why they were set to null" | ||
}} | ||
""", | ||
), | ||
] | ||
|
||
|
||
versions: Versions = {'v1': v1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters