@aj-archipelago/cortex 1.1.21 → 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 +5 -4
- package/helper-apps/cortex-file-handler/blobHandler.js +115 -98
- package/helper-apps/cortex-file-handler/fileChunker.js +13 -8
- package/helper-apps/cortex-file-handler/index.js +48 -2
- 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 +107 -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/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/plugins/azureCognitivePlugin.js +10 -1
- package/server/plugins/openAiVisionPlugin.js +14 -6
- package/tests/main.test.js +2 -2
- package/tests/vision.test.js +0 -34
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({
|
|
6
|
+
messages: [
|
|
7
|
+
{ "role": "system", "content": "Assistant is an expert senior software engineer tasked with reviewing code and code changes as they are submitted to the GitHub repository for a software team. When user posts a list of code changes, assistant will examine the changes and determine the most relevant updates to understand the scope and context of the code review. Assistant will begin the review with a short paragraph summarizing the purpose of the code changes. Assistant will then review the code changes carefully and produce a thorough, detailed, professional report containing the following: 1. potential bugs, errors or omissions, 2. any security risks inherent in the changes, 3. any opportunities to improve the code via simplification, 4. any opportunities to apply best practices for the language and framework being used, and 5. a determination of whether, given the issues identified, the code is APPROVED FOR MERGE or REQUIRES CHANGES. Assistant will use markdown where it helps make output more readable - especially to format code examples." },
|
|
8
|
+
{ "role": "user", "content": `Code changes:\n\n{{{text}}}`},
|
|
9
|
+
]
|
|
10
|
+
})
|
|
11
|
+
],
|
|
12
|
+
model: 'oai-gpt4o',
|
|
13
|
+
tokenRatio: 0.75,
|
|
14
|
+
enableDuplicateRequests: false,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
package/pathways/embeddings.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt: [
|
|
5
|
+
new Prompt({ messages: [
|
|
6
|
+
{"role": "system", "content": "Assistant helps journalists write news stories at a prestigious international news agency. When the user posts a news excerpt, assistant will respond with a numbered list of further questions that the reader of the news excerpt may ask."},
|
|
7
|
+
{"role": "user", "content": "{{text}}"}
|
|
8
|
+
]}),
|
|
9
|
+
],
|
|
10
|
+
model: 'oai-gpt4o',
|
|
11
|
+
list: true,
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
|
|
5
|
+
prompt: [
|
|
6
|
+
new Prompt({ messages: [
|
|
7
|
+
{"role": "system", "content": "Assistant is a highly skilled AI writing agent that formats blocks of text into paragraphs. Assistant does not converse with the user or respond in any way other than to produce a formatted version of the users input. When the user posts any text in any language, assistant will examine that text, look for the best possible paragraph breaks, and insert newlines to demark the paragraphs if they are not already there. If there is less than one complete paragraph, assistant will respond with the text with no changes."},
|
|
8
|
+
{"role": "user", "content": "Text to format:\n{{{text}}}"}
|
|
9
|
+
]}),
|
|
10
|
+
],
|
|
11
|
+
//inputChunkSize: 500,
|
|
12
|
+
model: 'oai-gpt4o',
|
|
13
|
+
enableDuplicateRequests: true,
|
|
14
|
+
duplicateRequestAfter: 20,
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Import required modules
|
|
2
|
+
import { Prompt } from '../server/prompt.js';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
temperature: 0,
|
|
6
|
+
// The main prompt function that takes the input text and asks to generate a summary.
|
|
7
|
+
prompt:[
|
|
8
|
+
new Prompt({ messages: [
|
|
9
|
+
{"role": "system", "content": "Assistant is a highly skilled multilingual AI writing agent that summarizes text. When the user posts any text in any language, assistant will create a detailed summary of that text. The summary must be in the same language as the posted text. Assistant will produce only the summary text and no additional or other response. {{{summaryFormat}}}"},
|
|
10
|
+
{"role": "user", "content": "Text to summarize:\n{{{text}}}"}
|
|
11
|
+
]}),
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
// Define input parameters for the prompt, such as the target length of the summary.
|
|
15
|
+
inputParameters: {
|
|
16
|
+
targetLength: 0,
|
|
17
|
+
summaryFormat: ''
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
model: 'oai-gpt4o',
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt:
|
|
5
|
+
[
|
|
6
|
+
new Prompt({ messages: [
|
|
7
|
+
{"role": "system", "content": "Instructions:\nYou are Jarvis Vision, an AI entity working for a prestigious international news agency. Jarvis is truthful, kind, helpful, has a strong moral character, and is generally positive without being annoying or repetitive. Your primary expertise is image analysis. You are capable of understanding and interpreting complex image data, identifying patterns and trends, and delivering insights in a clear, digestible format. You know the current date and time - it is {{now}}."},
|
|
8
|
+
"{{chatHistory}}",
|
|
9
|
+
]}),
|
|
10
|
+
],
|
|
11
|
+
inputParameters: {
|
|
12
|
+
chatHistory: [{role: '', content: []}],
|
|
13
|
+
contextId: ``,
|
|
14
|
+
},
|
|
15
|
+
max_tokens: 2048,
|
|
16
|
+
model: 'gemini-pro-15-vision',
|
|
17
|
+
useInputChunking: false,
|
|
18
|
+
enableDuplicateRequests: false,
|
|
19
|
+
timeout: 600,
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
prompt:
|
|
5
|
+
[
|
|
6
|
+
new Prompt({ messages: [
|
|
7
|
+
{"role": "system", "content": "Instructions:\nYou are Jarvis Vision, an AI entity working for a prestigious international news agency. Jarvis is truthful, kind, helpful, has a strong moral character, and is generally positive without being annoying or repetitive. Your primary expertise is image analysis. You are capable of understanding and interpreting complex image data, identifying patterns and trends, and delivering insights in a clear, digestible format. You know the current date and time - it is {{now}}."},
|
|
8
|
+
"{{chatHistory}}",
|
|
9
|
+
]}),
|
|
10
|
+
],
|
|
11
|
+
inputParameters: {
|
|
12
|
+
chatHistory: [{role: '', content: []}],
|
|
13
|
+
contextId: ``,
|
|
14
|
+
},
|
|
15
|
+
max_tokens: 2048,
|
|
16
|
+
model: 'gemini-pro-vision',
|
|
17
|
+
useInputChunking: false,
|
|
18
|
+
enableDuplicateRequests: false,
|
|
19
|
+
timeout: 600,
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
temperature: 0,
|
|
5
|
+
prompt: [
|
|
6
|
+
new Prompt({
|
|
7
|
+
messages: [
|
|
8
|
+
{
|
|
9
|
+
"role": "system", "content": `
|
|
10
|
+
Assistant is a highly skilled copy editor for a prestigious news agency.
|
|
11
|
+
When the user posts any text, assistant will correct all spelling and grammar in the text and change words to British English word spellings, while following the rules below:
|
|
12
|
+
- Assistant will preserve HTML markup in the text, e.g. The <a href="https://bbc.com">British Broadcsating Corporation</a> reported on this fact yesterday. => The <a href="https://bbc.com">British Broadcasting Corporation</a> reportd on this fact yesterday.
|
|
13
|
+
- Assistant will not modify or delete image URLs.
|
|
14
|
+
- Assistant will not change self-closing tags (e.g. don't change <br/> to <br> or <br> to <br/>).
|
|
15
|
+
- Assistant will preserve WordPress shortcodes in the text, e.g. foo [caption prop="x"] A biy inspects the insect [/caption] baz => foo [caption prop="x"] A boy inspects the insect [/caption] baz
|
|
16
|
+
- Assistant will produce only the corrected text and no additional notes or commentary.` },
|
|
17
|
+
{ "role": "user", "content": "The $20 bill was the wrong color." },
|
|
18
|
+
{ "role": "assistant", "content": "The $20 bill was the wrong colour." },
|
|
19
|
+
{ "role": "user", "content": `The <a href="https://bbc.com">British Broadcsating Corporation</a> reportd on this fact yesterday.` },
|
|
20
|
+
{ "role": "assistant", "content": `The <a href="https://bbc.com">British Broadcasting Corporation</a> reported on this fact yesterday.` },
|
|
21
|
+
{ "role": "user", "content": "{{{text}}}" }
|
|
22
|
+
]
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
inputFormat: 'html',
|
|
26
|
+
useInputChunking: true,
|
|
27
|
+
inputChunkSize: 1000,
|
|
28
|
+
useParallelChunkProcessing: true,
|
|
29
|
+
model: 'oai-gpt4o'
|
|
30
|
+
}
|
|
@@ -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 identifying social media hashtags that fit a news article summary. When user posts a news article summary, assistant will carefully read the summary and generate a numbered list of fitting hashtags. Assistant will generate only the hashtags and no other response or commentary. All hashtags must match the language of the summary." },
|
|
8
|
+
{ "role": "user", "content": `Article Summary:\n\nExample summary text.`},
|
|
9
|
+
{ "role": "assistant", "content": "1. #firsthashtag\n2. #secondhashtag\n 3. #thirdhashtag\n"},
|
|
10
|
+
{ "role": "user", "content": `Article Summary:\n\n{{{text}}}`},
|
|
11
|
+
]
|
|
12
|
+
})
|
|
13
|
+
],
|
|
14
|
+
model: 'oai-gpt4o',
|
|
15
|
+
useInputSummarization: true,
|
|
16
|
+
list: true,
|
|
17
|
+
temperature: 0.7,
|
|
18
|
+
}
|
|
19
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Prompt } from '../server/prompt.js';
|
|
2
|
+
import { PathwayResolver } from '../server/pathwayResolver.js';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
|
|
6
|
+
prompt: [],
|
|
7
|
+
inputParameters: {
|
|
8
|
+
seoOptimized: false,
|
|
9
|
+
count: 5,
|
|
10
|
+
targetLength: 65
|
|
11
|
+
},
|
|
12
|
+
list: true,
|
|
13
|
+
useInputSummarization: true,
|
|
14
|
+
model: 'oai-gpt4o',
|
|
15
|
+
|
|
16
|
+
// Custom resolver to generate headlines by reprompting if they are too long
|
|
17
|
+
resolver: async (_parent, args, contextValue, _info) => {
|
|
18
|
+
const { config, pathway } = contextValue;
|
|
19
|
+
const { targetLength, count } = args;
|
|
20
|
+
const targetWords = Math.round(targetLength / 7);
|
|
21
|
+
const MAX_ITERATIONS = 3;
|
|
22
|
+
|
|
23
|
+
let pathwayResolver = new PathwayResolver({ config, pathway, args });
|
|
24
|
+
pathwayResolver.pathwayPrompt = [
|
|
25
|
+
new Prompt({ messages: [
|
|
26
|
+
{"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. The headlines that assistant writes must be ${ targetWords } words or less. All headlines must be capitalized in sentence-case (first letter and proper nouns capitalized). The headlines may not be in quotes. Assistant will produce only the list of headlines and no additional notes or commentary.`},
|
|
27
|
+
{"role": "user", "content": "Text:\n\n{{{text}}}"}
|
|
28
|
+
]}),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
let shortHeadlines = [];
|
|
32
|
+
let i = 0;
|
|
33
|
+
while ( shortHeadlines.length < count && i < MAX_ITERATIONS ) {
|
|
34
|
+
let headlines = await pathwayResolver.resolve(args);
|
|
35
|
+
shortHeadlines = headlines.filter(h => h.length < targetLength).slice(0, count);
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return shortHeadlines;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -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,49 +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';
|
|
19
72
|
import transcribe_neuralspace from './transcribe_neuralspace.js';
|
|
20
73
|
import translate from './translate.js';
|
|
21
|
-
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';
|
|
22
79
|
import vision from './vision.js';
|
|
23
|
-
import bing from './bing.js';
|
|
24
80
|
|
|
25
81
|
export {
|
|
26
|
-
bing,
|
|
27
|
-
edit,
|
|
28
|
-
chat,
|
|
29
82
|
bias,
|
|
83
|
+
bing,
|
|
84
|
+
categorize, chat, chat_code,
|
|
85
|
+
chat_context,
|
|
86
|
+
chat_jarvis,
|
|
87
|
+
chat_persist, code_review,
|
|
30
88
|
cognitive_delete,
|
|
31
89
|
cognitive_insert,
|
|
32
90
|
cognitive_search,
|
|
33
91
|
complete,
|
|
92
|
+
edit,
|
|
34
93
|
embeddings,
|
|
35
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,
|
|
36
104
|
language,
|
|
105
|
+
locations,
|
|
37
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,
|
|
38
116
|
sentiment,
|
|
117
|
+
spelling,
|
|
118
|
+
story_angles,
|
|
119
|
+
styleguide,
|
|
120
|
+
styleguidemulti,
|
|
121
|
+
subhead,
|
|
122
|
+
summarize_turbo,
|
|
39
123
|
summary,
|
|
40
|
-
|
|
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,
|
|
41
129
|
sys_openai_completion,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
transcribe,
|
|
130
|
+
sys_openai_chat_gpt4_turbo, tags,
|
|
131
|
+
taxonomy,
|
|
132
|
+
timeline, topics, topics_sentiment, transcribe,
|
|
46
133
|
transcribe_neuralspace,
|
|
47
134
|
translate,
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
}
|