microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ecec6489db2ad85ccd1be99c0860dc3b057af2b1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

python/nprData/prompts.py

141lines · modecode

1# Copyright (c) Microsoft Corporation and Henry Lucco.
2# Licensed under the MIT License.
3
4typeagent_entity_extraction_system = """
5You are a service that extracts all entities and actions from a conversation passage into a JSON object of type KnowledgeResponsea according to the following TypeScript definitions:
6export type Quantity = {
7 amount: number;
8 units: string;
9};
10
11export type Value = string | number | boolean | Quantity;
12
13export type Facet = {
14 name: string;
15 // Very concise values.
16 value: Value;
17};
18
19// Specific, tangible people, places, institutions or things only
20export type ConcreteEntity = {
21 // the name of the entity or thing such as "Bach", "Great Gatsby", "frog" or "piano"
22 name: string;
23 // the types of the entity such as "speaker", "person", "artist", "animal", "object", "instrument", "school", "room", "museum", "food" etc.
24 // An entity can have multiple types; entity types should be single words
25 type: string[];
26 // A specific, inherent, defining, or non-immediate facet of the entity such as "blue", "old", "famous", "sister", "aunt_of", "weight: 4 kg"
27 // trivial actions or state changes are not facets
28 // facets are concise "properties"
29 facets?: Facet[];
30};
31
32export type ActionParam = {
33 name: string;
34 value: Value;
35};
36
37export type VerbTense = "past" | "present" | "future";
38
39export type Action = {
40 // Each verb is typically a word not a phrase; parse the verb phrase and put the object into the objectEntityName field
41 verbs: string[];
42 verbTense: VerbTense;
43 // the subject of "mary ate pie" is mary
44 subjectEntityName: string | "none";
45 // the object of the verb for example the object of "mary ate pie" is pie
46 objectEntityName: string | "none";
47 // the indirect object of "mary gave the pie to mom" is mom
48 indirectObjectEntityName: string | "none";
49 params?: (string | ActionParam)[];
50 // If the action implies this additional facet or property of the subjectEntity, such as hobbies, activities, interests, personality
51 subjectEntityFacet?: Facet | undefined;
52};
53
54// Detailed and comprehensive knowledge response
55export type KnowledgeResponse = {
56 entities: ConcreteEntity[];
57 // The 'subjectEntityName' and 'objectEntityName' must correspond to the 'name' of an entity listed in the 'entities' array.
58 actions: Action[];
59 // Detailed, descriptive topics and keywords. Each topic is a string; topics don't have object structure like entities and actions.
60 topics: string[];
61};
62The following is the conversation passage:
63"""
64
65def typeagent_entity_extraction_user(passage: str):
66 return f"""
67{passage}
68The following is a comprehensive set of entities, actions, and topics extracted from the conversation passage above, expressed as a JSON object of type KnowledgeResponse with 2 spaces of indentation and no properties with the value undefined:
69"""
70
71def typeagent_entity_extraction_system_full(passage: str):
72 return """
73You are a service that extracts all entities and actions from a conversation passage into a JSON object of type KnowledgeResponsea according to the following TypeScript definitions:
74export type Quantity = {
75 amount: number;
76 units: string;
77};
78
79export type Value = string | number | boolean | Quantity;
80
81export type Facet = {
82 name: string;
83 // Very concise values.
84 value: Value;
85};
86
87// Specific, tangible people, places, institutions or things only
88export type ConcreteEntity = {
89 // the name of the entity or thing such as "Bach", "Great Gatsby", "frog" or "piano"
90 name: string;
91 // the types of the entity such as "speaker", "person", "artist", "animal", "object", "instrument", "school", "room", "museum", "food" etc.
92 // An entity can have multiple types; entity types should be single words
93 type: string[];
94 // A specific, inherent, defining, or non-immediate facet of the entity such as "blue", "old", "famous", "sister", "aunt_of", "weight: 4 kg"
95 // trivial actions or state changes are not facets
96 // facets are concise "properties"
97 facets?: Facet[];
98};
99
100export type ActionParam = {
101 name: string;
102 value: Value;
103};
104
105export type VerbTense = "past" | "present" | "future";
106
107export type Action = {
108 // Each verb is typically a word not a phrase; parse the verb phrase and put the object into the objectEntityName field
109 verbs: string[];
110 verbTense: VerbTense;
111 // the subject of "mary ate pie" is mary
112 subjectEntityName: string | "none";
113 // the object of the verb for example the object of "mary ate pie" is pie
114 objectEntityName: string | "none";
115 // the indirect object of "mary gave the pie to mom" is mom
116 indirectObjectEntityName: string | "none";
117 params?: (string | ActionParam)[];
118 // If the action implies this additional facet or property of the subjectEntity, such as hobbies, activities, interests, personality
119 subjectEntityFacet?: Facet | undefined;
120};
121
122// Detailed and comprehensive knowledge response
123export type KnowledgeResponse = {
124 entities: ConcreteEntity[];
125 // The 'subjectEntityName' and 'objectEntityName' must correspond to the 'name' of an entity listed in the 'entities' array.
126 actions: Action[];
127 // Detailed, descriptive topics and keywords. Each topic is a string; topics don't have object structure like entities and actions.
128 topics: string[];
129};
130The following is the conversation passage:
131""" + f"""
132{passage}
133The following is a comprehensive set of entities, actions, and topics extracted from the conversation passage above, expressed as a JSON object of type KnowledgeResponse with 2 spaces of indentation and no properties with the value undefined:
134"""
135
136def generic_chunk_prompt(content: str):
137 return f"""
138You are a service that generates a chunk of text from a conversation passage. The conversation passage is the following:
139{content}
140Generate a chunk of text that summarizes the conversation passage.
141"""