@aj-archipelago/cortex 1.1.20 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/default.example.json +84 -0
- package/config.js +17 -4
- package/helper-apps/cortex-file-handler/blobHandler.js +144 -100
- package/helper-apps/cortex-file-handler/fileChunker.js +13 -8
- package/helper-apps/cortex-file-handler/index.js +56 -9
- package/lib/pathwayTools.js +7 -1
- package/lib/requestExecutor.js +4 -4
- package/lib/util.js +163 -1
- package/package.json +2 -1
- package/pathways/categorize.js +23 -0
- package/pathways/chat.js +1 -1
- package/pathways/chat_code.js +19 -0
- package/pathways/chat_context.js +19 -0
- package/pathways/chat_jarvis.js +19 -0
- package/pathways/chat_persist.js +23 -0
- package/pathways/code_review.js +17 -0
- package/pathways/cognitive_delete.js +2 -1
- package/pathways/cognitive_insert.js +1 -0
- package/pathways/cognitive_search.js +1 -0
- package/pathways/embeddings.js +1 -1
- package/pathways/expand_story.js +12 -0
- package/pathways/format_paragraph_turbo.js +16 -0
- package/pathways/format_summarization.js +21 -0
- package/pathways/gemini_15_vision.js +20 -0
- package/pathways/gemini_vision.js +20 -0
- package/pathways/grammar.js +30 -0
- package/pathways/hashtags.js +19 -0
- package/pathways/headline.js +43 -0
- package/pathways/headline_custom.js +169 -0
- package/pathways/highlights.js +22 -0
- package/pathways/image.js +2 -1
- package/pathways/index.js +109 -17
- package/pathways/jira_story.js +18 -0
- package/pathways/keywords.js +4 -0
- package/pathways/language.js +17 -6
- package/pathways/locations.js +93 -0
- package/pathways/quotes.js +19 -0
- package/pathways/rag.js +207 -0
- package/pathways/rag_jarvis.js +254 -0
- package/pathways/rag_search_helper.js +21 -0
- package/pathways/readme.js +18 -0
- package/pathways/release_notes.js +16 -0
- package/pathways/remove_content.js +31 -0
- package/pathways/retrieval.js +23 -0
- package/pathways/run_claude35_sonnet.js +21 -0
- package/pathways/run_claude3_haiku.js +20 -0
- package/pathways/run_gpt35turbo.js +20 -0
- package/pathways/run_gpt4.js +20 -0
- package/pathways/run_gpt4_32.js +20 -0
- package/pathways/select_extension.js +6 -0
- package/pathways/select_services.js +10 -0
- package/pathways/spelling.js +3 -0
- package/pathways/story_angles.js +13 -0
- package/pathways/styleguide/styleguide.js +221 -0
- package/pathways/styleguidemulti.js +127 -0
- package/pathways/subhead.js +48 -0
- package/pathways/summarize_turbo.js +98 -0
- package/pathways/summary.js +31 -12
- package/pathways/sys_claude_35_sonnet.js +19 -0
- package/pathways/sys_claude_3_haiku.js +19 -0
- package/pathways/sys_google_chat.js +19 -0
- package/pathways/sys_google_code_chat.js +19 -0
- package/pathways/sys_google_gemini_chat.js +23 -0
- package/pathways/sys_openai_chat.js +2 -2
- package/pathways/sys_openai_chat_16.js +19 -0
- package/pathways/sys_openai_chat_gpt4.js +19 -0
- package/pathways/sys_openai_chat_gpt4_32.js +19 -0
- package/pathways/sys_openai_chat_gpt4_turbo.js +19 -0
- package/pathways/tags.js +25 -0
- package/pathways/taxonomy.js +135 -0
- package/pathways/timeline.js +51 -0
- package/pathways/topics.js +25 -0
- package/pathways/topics_sentiment.js +20 -0
- package/pathways/transcribe.js +2 -4
- package/pathways/transcribe_neuralspace.js +18 -0
- package/pathways/translate.js +10 -12
- package/pathways/translate_azure.js +13 -0
- package/pathways/translate_context.js +21 -0
- package/pathways/translate_gpt4.js +19 -0
- package/pathways/translate_gpt4_turbo.js +19 -0
- package/pathways/translate_turbo.js +19 -0
- package/pathways/vision.js +9 -7
- package/server/modelExecutor.js +4 -0
- package/server/pathwayResolver.js +19 -1
- package/server/plugins/azureCognitivePlugin.js +10 -1
- package/server/plugins/claude3VertexPlugin.js +2 -1
- package/server/plugins/gemini15ChatPlugin.js +8 -3
- package/server/plugins/gemini15VisionPlugin.js +19 -3
- package/server/plugins/geminiChatPlugin.js +1 -1
- package/server/plugins/geminiVisionPlugin.js +2 -3
- package/server/plugins/neuralSpacePlugin.js +252 -0
- package/server/plugins/openAiVisionPlugin.js +32 -13
- package/server/plugins/openAiWhisperPlugin.js +5 -152
- package/server/plugins/palmChatPlugin.js +1 -1
- package/server/resolver.js +3 -4
- package/server/typeDef.js +1 -0
- package/tests/claude3VertexPlugin.test.js +214 -0
- package/tests/main.test.js +2 -2
- package/tests/mocks.js +2 -0
- package/tests/openAiChatPlugin.test.js +4 -0
- package/tests/vision.test.js +0 -34
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
import { PathwayResolver } from '../server/pathwayResolver.js';
|
|
3
|
+
import { callPathway } from '../lib/pathwayTools.js';
|
|
4
|
+
|
|
5
|
+
const getExamples = (style) => {
|
|
6
|
+
switch (style) {
|
|
7
|
+
case 'quote':
|
|
8
|
+
return [`"Enough is enough": A UK union rep fighting from the picket line`,
|
|
9
|
+
`"So trapped": A young Iraqi driver's costly taxi to nowhere`,
|
|
10
|
+
`"Enduring commitment": Key takeaways from US-GCC joint statement`,
|
|
11
|
+
`"Real good shape": Biden and Sunak hail ties at White House meet`,
|
|
12
|
+
];
|
|
13
|
+
default:
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
prompt: [],
|
|
20
|
+
inputParameters: {
|
|
21
|
+
count: 5,
|
|
22
|
+
targetLength: 80,
|
|
23
|
+
idea: '',
|
|
24
|
+
style: '',
|
|
25
|
+
keywords: ['']
|
|
26
|
+
},
|
|
27
|
+
list: true,
|
|
28
|
+
model: 'oai-gpt4o',
|
|
29
|
+
useInputChunking: false,
|
|
30
|
+
enableDuplicateRequests: false,
|
|
31
|
+
|
|
32
|
+
// Custom resolver to generate headlines by reprompting if they are too long
|
|
33
|
+
resolver: async (_parent, args, contextValue, _info) => {
|
|
34
|
+
const { config, pathway } = contextValue;
|
|
35
|
+
let { targetLength = 80, count = 5 } = args;
|
|
36
|
+
const MAX_ITERATIONS = 3;
|
|
37
|
+
|
|
38
|
+
if (count === 0) {
|
|
39
|
+
count = 5;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (targetLength === 0) {
|
|
43
|
+
targetLength = 80;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let targetWords = Math.round(targetLength / 7);
|
|
47
|
+
let quotesInDocument = [];
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
function getPathwayPrompt(args, count, targetWords) {
|
|
51
|
+
const examples = getExamples(args.style);
|
|
52
|
+
|
|
53
|
+
let keywordsPrompt = '';
|
|
54
|
+
if (args.keywords?.length) {
|
|
55
|
+
keywordsPrompt = `- Headline must include these keywords: ${args.keywords.map(k => `"${k}"`).join(', ')}\n`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let anglePrompt = '';
|
|
59
|
+
if (args.idea) {
|
|
60
|
+
anglePrompt = `- Headline must align to this angle: {{idea}}\n`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let examplesPrompt = '';
|
|
64
|
+
if (examples?.length) {
|
|
65
|
+
const { includedQuotes } = args;
|
|
66
|
+
|
|
67
|
+
examplesPrompt = `- Headline must start with a short, impactful quote snippet taken verbatim from a quote in the news excerpt. (example format: "Enduring commitment": Key takeaways from US-GCC joint statement, "Real good shape": Biden and Sunak hail ties at White House meet).`;
|
|
68
|
+
|
|
69
|
+
if (includedQuotes) {
|
|
70
|
+
examplesPrompt += `The snippet must be taken from one of the following quotes:\n - ${includedQuotes.map(q => `"${q}"`).join('\n - ')}\n`;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
examplesPrompt += `\n`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let instructionsPrompt = '';
|
|
78
|
+
if (anglePrompt || keywordsPrompt || examplesPrompt) {
|
|
79
|
+
instructionsPrompt = `${keywordsPrompt}${anglePrompt}${examplesPrompt}\n`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const prompt = [
|
|
83
|
+
new Prompt({
|
|
84
|
+
messages: [
|
|
85
|
+
{ "role": "system", "content": `Assistant is a highly skilled multilingual headline writer for a prestigious international news agency. Assistant generates attention-grabbing, informative, and engaging headlines that capture the essence of the article while sparking curiosity in readers. When the user posts any text in any language, assistant will create ${ count * 2 } compelling headlines for that text in the same language as the text. Assistant will produce only a numbered list of headlines and no additional notes or commentary.\n\nAll headlines must comply with all of the following instructions:\n${ instructionsPrompt }\n- Headlines must be ${ targetWords } words or fewer.\n- Headlines must be written in sentence-case (only the first letter of the headline and proper nouns capitalized).\n` },
|
|
86
|
+
{ "role": "user", "content": `{{{text}}}` }
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
return prompt;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getQuotes(text) {
|
|
94
|
+
|
|
95
|
+
const regex = /"([^"]*)"/g;
|
|
96
|
+
let matches;
|
|
97
|
+
|
|
98
|
+
text = text.replace(/“/g, '"').replace(/”/g, '"');
|
|
99
|
+
// normalize single quotes
|
|
100
|
+
text = text.replace(/‘/g, "'").replace(/’/g, "'");
|
|
101
|
+
|
|
102
|
+
matches = text.matchAll(regex);
|
|
103
|
+
|
|
104
|
+
let quotes = [];
|
|
105
|
+
for (const match of matches) {
|
|
106
|
+
quotes.push(match[1]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return quotes;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const areQuotesInHeadlineValid = (headline) => {
|
|
113
|
+
if (args.style === 'quote') {
|
|
114
|
+
const quotesInHeadline = getQuotes(headline);
|
|
115
|
+
const nonExactQuotes = [];
|
|
116
|
+
|
|
117
|
+
for (const quote of quotesInHeadline) {
|
|
118
|
+
const exists = quotesInDocument.some(q => q.toLowerCase().includes(quote.toLowerCase()));
|
|
119
|
+
if (!exists) {
|
|
120
|
+
nonExactQuotes.push(quote);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (nonExactQuotes.length) {
|
|
125
|
+
console.log(`Non-exact quotes: ${nonExactQuotes.join(', ')}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Commented out to allow non-verbatim quotes and give the AI some flexibility
|
|
129
|
+
// in adapting a quote to the headline
|
|
130
|
+
// return nonExactQuotes.length === 0;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let pathwayResolver = new PathwayResolver({ config, pathway, args });
|
|
139
|
+
|
|
140
|
+
if (args.style === 'quote') {
|
|
141
|
+
// The AI seems to node include the initial quote in the word count for the headline.
|
|
142
|
+
// Doing this to account for that.
|
|
143
|
+
targetWords = targetWords - 3;
|
|
144
|
+
quotesInDocument = await callPathway('quotes', { ...args, targetLength: 0 });
|
|
145
|
+
args.includedQuotes = quotesInDocument;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
pathwayResolver.pathwayPrompt = getPathwayPrompt(args, count, targetWords);
|
|
149
|
+
let headlines = await pathwayResolver.resolve(args);
|
|
150
|
+
|
|
151
|
+
// remove surrounding quotes from headlines
|
|
152
|
+
headlines = headlines.map(h => h.replace(/^"(.*)"$/, '$1'));
|
|
153
|
+
let shortHeadlines = headlines.filter(h => h.length < targetLength && areQuotesInHeadlineValid(h)).slice(0, count);
|
|
154
|
+
let i = 0;
|
|
155
|
+
|
|
156
|
+
// If some headlines do not meet the length requirement, reprompt
|
|
157
|
+
while (shortHeadlines.length < count && i < MAX_ITERATIONS) {
|
|
158
|
+
pathwayResolver.pathwayPrompt = getPathwayPrompt(args, count, targetWords);
|
|
159
|
+
let headlines = await pathwayResolver.resolve(args);
|
|
160
|
+
// remove surrounding quotes from headlines
|
|
161
|
+
headlines = headlines.map(h => h.replace(/^"(.*)"$/, '$1'));
|
|
162
|
+
shortHeadlines = shortHeadlines.concat(headlines.filter(h => h.length < targetLength && !shortHeadlines.includes(h) && areQuotesInHeadlineValid(h)).slice(0, count));
|
|
163
|
+
i++;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return shortHeadlines.slice(0, count);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({
|
|
6
|
+
messages: [
|
|
7
|
+
{ "role": "system", "content": "Assistant is a brilliant, multilingual news editor at a prestigious international news agency. Assistant's job is to extract a maximum of {{count}} bullet points from a news excerpt, where each bullet point contains a single fact. When the user posts a news excerpt, assistant will respond with a JSON array of bullet points from the excerpt. All bullet points must be in the same language as the news excerpt. Assistant will respond only with the points and no additional notes or commentary. Assistant will respond with a JSON array, no other output." },
|
|
8
|
+
{ "role": "user", "content": "After weeks of resistance, and ahead of a vote that could have compelled it to happen, Prime Minister Justin Trudeau's office announced Tuesday that his chief of staff Katie Telford will testify about foreign election interference, before a committee that has been studying the issue for months." },
|
|
9
|
+
{ "role": "assistant", "content": `["Katie Telford will testify about foreign election interference"]` },
|
|
10
|
+
{ "role": "user", "content": `The company said in a statement that the cancellation of these flights "comes in response to a request from Heathrow authorities to reduce the number of passengers during the strike period," adding that affected passengers can change their flights or claim a refund.
|
|
11
|
+
|
|
12
|
+
32 departing and arriving flights at London Airport will be cancelled daily, which is 5% of the flights operated by Heathrow in line with the Easter holiday. The measure will not affect long-haul flights.` },
|
|
13
|
+
{ "role": "assistant", "content": `["Affected passengers can change their flights or claim a refund", "5% of daily London Airport flights will be cancelled"]` },
|
|
14
|
+
{ "role": "user", "content": "{{text}}" },
|
|
15
|
+
]
|
|
16
|
+
})],
|
|
17
|
+
inputParameters: {
|
|
18
|
+
count: 4,
|
|
19
|
+
},
|
|
20
|
+
model: 'oai-gpt4o',
|
|
21
|
+
temperature: 0.0,
|
|
22
|
+
}
|
package/pathways/image.js
CHANGED
package/pathways/index.js
CHANGED
|
@@ -1,47 +1,139 @@
|
|
|
1
|
-
import edit from './edit.js';
|
|
2
|
-
import chat from './chat.js';
|
|
3
1
|
import bias from './bias.js';
|
|
2
|
+
import bing from './bing.js';
|
|
3
|
+
import categorize from './categorize.js';
|
|
4
|
+
import chat from './chat.js';
|
|
5
|
+
import chat_code from './chat_code.js';
|
|
6
|
+
import chat_context from './chat_context.js';
|
|
7
|
+
import chat_jarvis from './chat_jarvis.js';
|
|
8
|
+
import chat_persist from './chat_persist.js';
|
|
9
|
+
import code_review from './code_review.js';
|
|
4
10
|
import cognitive_delete from './cognitive_delete.js';
|
|
5
11
|
import cognitive_insert from './cognitive_insert.js';
|
|
6
12
|
import cognitive_search from './cognitive_search.js';
|
|
7
13
|
import complete from './complete.js';
|
|
14
|
+
import edit from './edit.js';
|
|
15
|
+
import embeddings from './embeddings.js';
|
|
8
16
|
import entities from './entities.js';
|
|
17
|
+
import expand_story from './expand_story.js';
|
|
18
|
+
import format_paragraph_turbo from './format_paragraph_turbo.js';
|
|
19
|
+
import gemini_15_vision from './gemini_15_vision.js';
|
|
20
|
+
import gemini_vision from './gemini_vision.js';
|
|
21
|
+
import grammar from './grammar.js';
|
|
22
|
+
import hashtags from './hashtags.js';
|
|
23
|
+
import headline from './headline.js';
|
|
24
|
+
import headline_custom from './headline_custom.js';
|
|
25
|
+
import highlights from './highlights.js';
|
|
26
|
+
import image from './image.js';
|
|
27
|
+
import jira_story from './jira_story.js';
|
|
28
|
+
import keywords from './keywords.js';
|
|
9
29
|
import language from './language.js';
|
|
30
|
+
import locations from './locations.js';
|
|
10
31
|
import paraphrase from './paraphrase.js';
|
|
32
|
+
import quotes from './quotes.js';
|
|
33
|
+
import rag from './rag.js';
|
|
34
|
+
import rag_jarvis from './rag_jarvis.js';
|
|
35
|
+
import rag_search_helper from './rag_search_helper.js';
|
|
36
|
+
import readme from './readme.js';
|
|
37
|
+
import release_notes from './release_notes.js';
|
|
38
|
+
import remove_content from './remove_content.js';
|
|
39
|
+
import retrieval from './retrieval.js';
|
|
40
|
+
import run_claude3_haiku from './run_claude3_haiku.js';
|
|
41
|
+
import run_claude35_sonnet from './run_claude35_sonnet.js';
|
|
42
|
+
import run_gpt35turbo from './run_gpt35turbo.js';
|
|
43
|
+
import run_gpt4 from './run_gpt4.js';
|
|
44
|
+
import run_gpt4_32 from './run_gpt4_32.js';
|
|
45
|
+
import select_extension from './select_extension.js';
|
|
46
|
+
import select_services from './select_services.js';
|
|
11
47
|
import sentiment from './sentiment.js';
|
|
48
|
+
import spelling from './spelling.js';
|
|
49
|
+
import story_angles from './story_angles.js';
|
|
50
|
+
import styleguide from './styleguide/styleguide.js';
|
|
51
|
+
import styleguidemulti from './styleguidemulti.js';
|
|
52
|
+
import subhead from './subhead.js';
|
|
53
|
+
import summarize_turbo from './summarize_turbo.js';
|
|
12
54
|
import summary from './summary.js';
|
|
55
|
+
import sys_claude_3_haiku from './sys_claude_3_haiku.js';
|
|
56
|
+
import sys_claude_35_sonnet from './sys_claude_35_sonnet.js';
|
|
57
|
+
import sys_google_chat from './sys_google_chat.js';
|
|
58
|
+
import sys_google_code_chat from './sys_google_code_chat.js';
|
|
59
|
+
import sys_google_gemini_chat from './sys_google_gemini_chat.js';
|
|
13
60
|
import sys_openai_chat from './sys_openai_chat.js';
|
|
61
|
+
import sys_openai_chat_16 from './sys_openai_chat_16.js';
|
|
62
|
+
import sys_openai_chat_gpt4 from './sys_openai_chat_gpt4.js';
|
|
63
|
+
import sys_openai_chat_gpt4_32 from './sys_openai_chat_gpt4_32.js';
|
|
64
|
+
import sys_openai_chat_gpt4_turbo from './sys_openai_chat_gpt4_turbo.js';
|
|
14
65
|
import sys_openai_completion from './sys_openai_completion.js';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
66
|
+
import tags from './tags.js';
|
|
67
|
+
import taxonomy from './taxonomy.js';
|
|
68
|
+
import timeline from './timeline.js';
|
|
69
|
+
import topics from './topics.js';
|
|
70
|
+
import topics_sentiment from './topics_sentiment.js';
|
|
18
71
|
import transcribe from './transcribe.js';
|
|
72
|
+
import transcribe_neuralspace from './transcribe_neuralspace.js';
|
|
19
73
|
import translate from './translate.js';
|
|
20
|
-
import
|
|
74
|
+
import translate_azure from './translate_azure.js';
|
|
75
|
+
import translate_context from './translate_context.js';
|
|
76
|
+
import translate_gpt4 from './translate_gpt4.js';
|
|
77
|
+
import translate_gpt4_turbo from './translate_gpt4_turbo.js';
|
|
78
|
+
import translate_turbo from './translate_turbo.js';
|
|
21
79
|
import vision from './vision.js';
|
|
22
|
-
import bing from './bing.js';
|
|
23
80
|
|
|
24
81
|
export {
|
|
25
|
-
bing,
|
|
26
|
-
edit,
|
|
27
|
-
chat,
|
|
28
82
|
bias,
|
|
83
|
+
bing,
|
|
84
|
+
categorize, chat, chat_code,
|
|
85
|
+
chat_context,
|
|
86
|
+
chat_jarvis,
|
|
87
|
+
chat_persist, code_review,
|
|
29
88
|
cognitive_delete,
|
|
30
89
|
cognitive_insert,
|
|
31
90
|
cognitive_search,
|
|
32
91
|
complete,
|
|
92
|
+
edit,
|
|
33
93
|
embeddings,
|
|
34
94
|
entities,
|
|
95
|
+
expand_story,
|
|
96
|
+
format_paragraph_turbo,
|
|
97
|
+
gemini_15_vision,
|
|
98
|
+
gemini_vision,
|
|
99
|
+
grammar,
|
|
100
|
+
hashtags, headline, headline_custom, highlights,
|
|
101
|
+
image,
|
|
102
|
+
jira_story,
|
|
103
|
+
keywords,
|
|
35
104
|
language,
|
|
105
|
+
locations,
|
|
36
106
|
paraphrase,
|
|
107
|
+
quotes, rag, rag_jarvis,
|
|
108
|
+
rag_search_helper, readme,
|
|
109
|
+
release_notes,
|
|
110
|
+
remove_content,
|
|
111
|
+
retrieval,
|
|
112
|
+
run_claude3_haiku,
|
|
113
|
+
run_claude35_sonnet,
|
|
114
|
+
run_gpt35turbo, run_gpt4, run_gpt4_32, select_extension,
|
|
115
|
+
select_services,
|
|
37
116
|
sentiment,
|
|
117
|
+
spelling,
|
|
118
|
+
story_angles,
|
|
119
|
+
styleguide,
|
|
120
|
+
styleguidemulti,
|
|
121
|
+
subhead,
|
|
122
|
+
summarize_turbo,
|
|
38
123
|
summary,
|
|
39
|
-
|
|
124
|
+
sys_claude_3_haiku,
|
|
125
|
+
sys_claude_35_sonnet,
|
|
126
|
+
sys_google_chat,
|
|
127
|
+
sys_google_code_chat,
|
|
128
|
+
sys_google_gemini_chat, sys_openai_chat, sys_openai_chat_16, sys_openai_chat_gpt4, sys_openai_chat_gpt4_32,
|
|
40
129
|
sys_openai_completion,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
130
|
+
sys_openai_chat_gpt4_turbo, tags,
|
|
131
|
+
taxonomy,
|
|
132
|
+
timeline, topics, topics_sentiment, transcribe,
|
|
133
|
+
transcribe_neuralspace,
|
|
45
134
|
translate,
|
|
46
|
-
|
|
47
|
-
|
|
135
|
+
translate_azure,
|
|
136
|
+
translate_context, translate_gpt4, translate_gpt4_turbo, translate_turbo,
|
|
137
|
+
vision
|
|
138
|
+
};
|
|
139
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({
|
|
6
|
+
messages: [
|
|
7
|
+
{ "role": "system", "content": `Assistant is highly skilled product manager who job is to write content for issues in JIRA. When the user posts some text, assistant will determine things mentioned in the text that are worth addressing as issues. For each issue, assistant will first select the type of issue and then create a title and description for each. For the title and description, assistant will use agile story format. Description should include acceptance criteria. Output in JSON array format. [{ "title": ..., "description": ..., "issueType": <Bug | Story | Task>}]` },
|
|
8
|
+
{ "role": "user", "content": "Number of tickets to create:{{storyCount}}\n\nContext:{{text}}" },
|
|
9
|
+
]
|
|
10
|
+
})],
|
|
11
|
+
inputParameters: {
|
|
12
|
+
text: "",
|
|
13
|
+
storyType: "Auto",
|
|
14
|
+
storyCount: "one",
|
|
15
|
+
},
|
|
16
|
+
model: 'oai-gpt4o',
|
|
17
|
+
temperature: 0.7,
|
|
18
|
+
}
|
package/pathways/language.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
// Analyze the language of a given text and return the language code.
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
|
-
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({
|
|
6
|
+
messages: [
|
|
7
|
+
{ "role": "system", "content": "Assistant is an AI that reads and recognizes the language of text provided by the user and returns the ISO 639-1 two letter code representing the language. Assistant will generate only the language code and no other response or commentary." },
|
|
8
|
+
{ "role": "user", "content": `Text:\nExample summary text.`},
|
|
9
|
+
{ "role": "assistant", "content": "en"},
|
|
10
|
+
{ "role": "user", "content": `Text:\nPrimjer sažetog teksta.`},
|
|
11
|
+
{ "role": "assistant", "content": "bs"},
|
|
12
|
+
{ "role": "user", "content": `Text:\n{{{text}}}`},
|
|
13
|
+
]
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
model: 'oai-gpt4o',
|
|
17
|
+
useInputChunking: false,
|
|
6
18
|
enableCache: true,
|
|
7
19
|
temperature: 0,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// locations.js
|
|
2
|
+
// News categories identification module
|
|
3
|
+
// This module exports a prompt that takes an input article text and identifies the top news categories for the article.
|
|
4
|
+
|
|
5
|
+
import { Prompt } from "../server/prompt.js";
|
|
6
|
+
import { PathwayResolver } from '../server/pathwayResolver.js';
|
|
7
|
+
import { callPathway } from '../lib/pathwayTools.js';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
prompt: [],
|
|
11
|
+
model: 'oai-gpt4o',
|
|
12
|
+
|
|
13
|
+
// Define input parameters for the prompt, such as the number of top news locations to identify and select.
|
|
14
|
+
inputParameters: {
|
|
15
|
+
count: 5,
|
|
16
|
+
locations: '',
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Set 'list' to true to indicate that the output is expected to be a list.
|
|
20
|
+
list: true,
|
|
21
|
+
timeout: 240,
|
|
22
|
+
|
|
23
|
+
// Custom resolver to find matching locations.
|
|
24
|
+
resolver: async (parent, args, contextValue, _info) => {
|
|
25
|
+
const { config, pathway } = contextValue;
|
|
26
|
+
const locations = args.locations;
|
|
27
|
+
let text = args.text;
|
|
28
|
+
|
|
29
|
+
// Summarize the input text
|
|
30
|
+
text = await callPathway('summary', { ...args, targetLength: 0 });
|
|
31
|
+
|
|
32
|
+
// loop through the comma delimited list of locations and create sets of 25 or less
|
|
33
|
+
// to pass into a call to the location picking logic
|
|
34
|
+
const locationsArray = locations.split(',')
|
|
35
|
+
.map(location => location.trim())
|
|
36
|
+
.filter(location => location.length > 0);
|
|
37
|
+
|
|
38
|
+
const locationSets = locationsArray.reduce((acc, location, index) => {
|
|
39
|
+
if (index % 25 === 0) {
|
|
40
|
+
acc.push(location);
|
|
41
|
+
} else {
|
|
42
|
+
acc[acc.length - 1] += `, ${location}`;
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
let pathwayResolver = new PathwayResolver({ config, pathway, args });
|
|
48
|
+
|
|
49
|
+
// call the locationging logic for each set of locations
|
|
50
|
+
const locationResults = [];
|
|
51
|
+
for (let locationSet of locationSets) {
|
|
52
|
+
if (locationSet.length === 0) continue;
|
|
53
|
+
pathwayResolver.pathwayPrompt = [
|
|
54
|
+
new Prompt({
|
|
55
|
+
messages: [
|
|
56
|
+
{ "role": "system", "content": "Assistant is an AI editorial assistant for an online news agency tasked with identifying locations from a pre-determined list that fit a news article summary. When User posts a news article summary and a list of possible locations, assistant will carefully examine the locations in the list. If any of them are a high confidence match for the article, assistant will return the matching locations as a comma separated list. Assistant must only identify a location if assistant is sure the location is a good match for the article. Any locations that assistant returns must be in the list already - assistant cannot add new locations. If there are no good matches, assistant will respond with <none>." },
|
|
57
|
+
{ "role": "user", "content": `Article Summary:\n\n{{{text}}}\n\nPossible locations: ${locationSet}`},
|
|
58
|
+
]
|
|
59
|
+
}),
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const locationResult = await pathwayResolver.resolve({ ...args, text });
|
|
63
|
+
|
|
64
|
+
// Filter locationResult based on case-insensitive matches with locationSet
|
|
65
|
+
const normalizelocation = (location) => {
|
|
66
|
+
return location.trim().toLowerCase().replace(/[.,]/g, '');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const filteredlocationResult = locationResult.reduce((acc, location) => {
|
|
70
|
+
const normalizedlocation = normalizelocation(location);
|
|
71
|
+
const matchinglocation = locationSet.split(',')
|
|
72
|
+
.map(s => normalizelocation(s))
|
|
73
|
+
.findIndex(normalizedPredefinedlocation => normalizedPredefinedlocation === normalizedlocation);
|
|
74
|
+
|
|
75
|
+
// If a matchinglocation is found, add the verbatim location from the predefined set
|
|
76
|
+
if (matchinglocation !== -1) {
|
|
77
|
+
acc.push(locationSet.split(',')[matchinglocation]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return acc;
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
// If filteredlocationResult is not empty, push the members of filteredlocationResult into locationResults
|
|
84
|
+
if (filteredlocationResult.length > 0) {
|
|
85
|
+
locationResults.push(...filteredlocationResult);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Join the locationResults array with a comma separator
|
|
90
|
+
return locationResults;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({
|
|
6
|
+
messages: [
|
|
7
|
+
{ "role": "system", "content": "Assistant is a brilliant multilingual AI editorial assistant for an online news agency tasked with extracting quotations from a news article excerpt and list them as a numbered list. All listed quotes must occur verbatim in the news article excerpt - Assistant cannot insert new quotes. Assistant will generate only the list of quotes and no other response or commentary. If there are no quotes in the article excerpt, Assistant will return <none>." },
|
|
8
|
+
{ "role": "user", "content": `Article Excerpt:\n\nExample article text. Bob was quoted as saying "the situation was dire". Mary responded, "I agree with Bob".`},
|
|
9
|
+
{ "role": "assistant", "content": "1. \"the situation was dire\" \n2. \"I agree with Bob\"\n"},
|
|
10
|
+
{ "role": "user", "content": `Article Excerpt:\n\nExample article text.`},
|
|
11
|
+
{ "role": "assistant", "content": "<none>"},
|
|
12
|
+
{ "role": "user", "content": `Article Excerpt:\n\n{{{text}}}`},
|
|
13
|
+
]
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
model: 'oai-gpt4o',
|
|
17
|
+
list: true,
|
|
18
|
+
temperature: 0.7,
|
|
19
|
+
}
|