@things-factory/codelingua 9.2.5 → 10.0.0-beta.10

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.
@@ -4,7 +4,7 @@ exports.apiDocCompletion = apiDocCompletion;
4
4
  const openai_connection_1 = require("./openai-connection");
5
5
  async function apiDocCompletion({ code, language = 'en-US' }) {
6
6
  try {
7
- const completion = await openai_connection_1.client.createChatCompletion({
7
+ const completion = await openai_connection_1.client.chat.completions.create({
8
8
  model: 'gpt-3.5-turbo',
9
9
  messages: [
10
10
  {
@@ -22,7 +22,7 @@ async function apiDocCompletion({ code, language = 'en-US' }) {
22
22
  }
23
23
  ]
24
24
  });
25
- return completion.data.choices[0].message.content;
25
+ return completion.choices[0].message.content;
26
26
  }
27
27
  catch (error) {
28
28
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"api-doc-completion.js","sourceRoot":"","sources":["../../server/controllers/api-doc-completion.ts"],"names":[],"mappings":";;AAEA,4CAgCC;AAlCD,2DAA4C;AAErC,KAAK,UAAU,gBAAgB,CAAC,EACrC,IAAI,EACJ,QAAQ,GAAG,OAAO,EAInB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE;oJACiI;iBAC3I;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,uBAAuB,IAAI,2FAA2F;iBAChI;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oEAAoE,QAAQ,IAAI;iBAC1F;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function apiDocCompletion({\n code,\n language = 'en-US'\n}: {\n code: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that takes in JavaScript or TypeScript code and generates detailed developer documentation in markdown format.\n And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content: `Here is some code: [${code}]. Can you help generate a detailed explanation and markdown documentation for this code?`\n },\n {\n role: 'assistant',\n content: `Please generate the documentation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"api-doc-completion.js","sourceRoot":"","sources":["../../server/controllers/api-doc-completion.ts"],"names":[],"mappings":";;AAEA,4CAgCC;AAlCD,2DAA4C;AAErC,KAAK,UAAU,gBAAgB,CAAC,EACrC,IAAI,EACJ,QAAQ,GAAG,OAAO,EAInB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE;oJACiI;iBAC3I;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,uBAAuB,IAAI,2FAA2F;iBAChI;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oEAAoE,QAAQ,IAAI;iBAC1F;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function apiDocCompletion({\n code,\n language = 'en-US'\n}: {\n code: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that takes in JavaScript or TypeScript code and generates detailed developer documentation in markdown format.\n And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content: `Here is some code: [${code}]. Can you help generate a detailed explanation and markdown documentation for this code?`\n },\n {\n role: 'assistant',\n content: `Please generate the documentation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -4,7 +4,7 @@ exports.chatCompletion = chatCompletion;
4
4
  const openai_connection_1 = require("./openai-connection");
5
5
  async function chatCompletion({ content }) {
6
6
  try {
7
- const completion = await openai_connection_1.client.createChatCompletion({
7
+ const completion = await openai_connection_1.client.chat.completions.create({
8
8
  model: 'gpt-3.5-turbo',
9
9
  messages: [
10
10
  {
@@ -21,7 +21,7 @@ async function chatCompletion({ content }) {
21
21
  }
22
22
  ]
23
23
  });
24
- return completion.data.choices[0].message.content;
24
+ return completion.choices[0].message.content;
25
25
  }
26
26
  catch (error) {
27
27
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"chat-completion.js","sourceRoot":"","sources":["../../server/controllers/chat-completion.ts"],"names":[],"mappings":";;AAEA,wCAyBC;AA3BD,2DAA4C;AAErC,KAAK,UAAU,cAAc,CAAC,EAAE,OAAO,EAAuB;IACnE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,gOAAgO;iBAC1O;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO;iBACR;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oDAAoD;iBAC9D;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function chatCompletion({ content }: { content: string }): Promise<string> {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that generates detailed information in response to user requests. And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content\n },\n {\n role: 'assistant',\n content: 'Sure, please fetch the information in JSON format.'\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"chat-completion.js","sourceRoot":"","sources":["../../server/controllers/chat-completion.ts"],"names":[],"mappings":";;AAEA,wCAyBC;AA3BD,2DAA4C;AAErC,KAAK,UAAU,cAAc,CAAC,EAAE,OAAO,EAAuB;IACnE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,gOAAgO;iBAC1O;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO;iBACR;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oDAAoD;iBAC9D;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function chatCompletion({ content }: { content: string }): Promise<string> {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that generates detailed information in response to user requests. And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content\n },\n {\n role: 'assistant',\n content: 'Sure, please fetch the information in JSON format.'\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -16,7 +16,7 @@ Please provide:
16
16
  `;
17
17
  const codereviewCompletion = async (codeDiff) => {
18
18
  try {
19
- const completion = await openai_connection_1.client.createChatCompletion({
19
+ const completion = await openai_connection_1.client.chat.completions.create({
20
20
  model: 'gpt-3.5-turbo',
21
21
  messages: [
22
22
  {
@@ -29,7 +29,7 @@ const codereviewCompletion = async (codeDiff) => {
29
29
  }
30
30
  ]
31
31
  });
32
- return completion.data.choices[0].message.content;
32
+ return completion.choices[0].message.content;
33
33
  }
34
34
  catch (error) {
35
35
  console.error('Error fetching OpenAI review:', error);
@@ -1 +1 @@
1
- {"version":3,"file":"codereview-completion.js","sourceRoot":"","sources":["../../server/controllers/codereview-completion.ts"],"names":[],"mappings":";;;AAAA,2DAA4C;AAE5C,MAAM,cAAc,GAAG;;;;;;;;;;;CAWtB,CAAA;AAEM,MAAM,oBAAoB,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IAC9E,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,cAAc;iBACxB;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,iCAAiC,QAAQ,EAAE;iBACrD;aACF;SACF,CAAC,CAAA;QACF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;QACrD,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC,CAAA;AApBY,QAAA,oBAAoB,wBAoBhC","sourcesContent":["import { client } from './openai-connection'\n\nconst SYSTEM_MESSAGE = `You are an expert software engineer with a deep understanding of multiple programming languages, including Python, JavaScript, Java, and C++. Your role is to analyze, review, and provide insights on code snippets, highlighting potential issues, suggesting improvements, and explaining complex parts of the code. Respond in a clear, concise, and professional manner.\n\nHere's the code for analysis:\n\n<code snippet>\n\nPlease provide:\n1. An overall assessment of the code quality.\n2. Identification of any potential bugs or issues.\n3. Suggestions for improving the code.\n4. An explanation of any complex or non-obvious parts of the code.\n`\n\nexport const codereviewCompletion = async (codeDiff: string): Promise<string> => {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: SYSTEM_MESSAGE\n },\n {\n role: 'user',\n content: `Review the following code:\\n\\n${codeDiff}`\n }\n ]\n })\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error('Error fetching OpenAI review:', error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"codereview-completion.js","sourceRoot":"","sources":["../../server/controllers/codereview-completion.ts"],"names":[],"mappings":";;;AAAA,2DAA4C;AAE5C,MAAM,cAAc,GAAG;;;;;;;;;;;CAWtB,CAAA;AAEM,MAAM,oBAAoB,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IAC9E,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,cAAc;iBACxB;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,iCAAiC,QAAQ,EAAE;iBACrD;aACF;SACF,CAAC,CAAA;QACF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;QACrD,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC,CAAA;AApBY,QAAA,oBAAoB,wBAoBhC","sourcesContent":["import { client } from './openai-connection'\n\nconst SYSTEM_MESSAGE = `You are an expert software engineer with a deep understanding of multiple programming languages, including Python, JavaScript, Java, and C++. Your role is to analyze, review, and provide insights on code snippets, highlighting potential issues, suggesting improvements, and explaining complex parts of the code. Respond in a clear, concise, and professional manner.\n\nHere's the code for analysis:\n\n<code snippet>\n\nPlease provide:\n1. An overall assessment of the code quality.\n2. Identification of any potential bugs or issues.\n3. Suggestions for improving the code.\n4. An explanation of any complex or non-obvious parts of the code.\n`\n\nexport const codereviewCompletion = async (codeDiff: string): Promise<string> => {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: SYSTEM_MESSAGE\n },\n {\n role: 'user',\n content: `Review the following code:\\n\\n${codeDiff}`\n }\n ]\n })\n return completion.choices[0].message.content\n } catch (error) {\n console.error('Error fetching OpenAI review:', error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -4,7 +4,7 @@ exports.decipherCode = decipherCode;
4
4
  const openai_connection_1 = require("./openai-connection");
5
5
  async function decipherCode({ code, system, language = 'en-US' }) {
6
6
  try {
7
- const completion = await openai_connection_1.client.createChatCompletion({
7
+ const completion = await openai_connection_1.client.chat.completions.create({
8
8
  model: 'gpt-3.5-turbo',
9
9
  messages: [
10
10
  {
@@ -23,7 +23,7 @@ async function decipherCode({ code, system, language = 'en-US' }) {
23
23
  }
24
24
  ]
25
25
  });
26
- return completion.data.choices[0].message.content;
26
+ return completion.choices[0].message.content;
27
27
  }
28
28
  catch (error) {
29
29
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"decipher-code.js","sourceRoot":"","sources":["../../server/controllers/decipher-code.ts"],"names":[],"mappings":";;AAEA,oCAmCC;AArCD,2DAA4C;AAErC,KAAK,UAAU,YAAY,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,QAAQ,GAAG,OAAO,EAKnB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,8FAA8F;iBACxG;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,MAAM;wBACb,CAAC,CAAC,mCAAmC,MAAM,4BAA4B,IAAI,GAAG;wBAC9E,CAAC,CAAC,mBAAmB,IAAI,GAAG;iBAC/B;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,4DAA4D,QAAQ,IAAI;iBAClF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function decipherCode({\n code,\n system,\n language = 'en-US'\n}: {\n code: string\n system?: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: 'You are a helpful assistant that translates system messages into user-friendly explanations.'\n },\n {\n role: 'user',\n content: system\n ? `We received an message from the ${system} system. The message is: ${code}.`\n : `The message is: ${code}.`\n },\n {\n role: 'system',\n content: `Translate the explanation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"decipher-code.js","sourceRoot":"","sources":["../../server/controllers/decipher-code.ts"],"names":[],"mappings":";;AAEA,oCAmCC;AArCD,2DAA4C;AAErC,KAAK,UAAU,YAAY,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,QAAQ,GAAG,OAAO,EAKnB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,8FAA8F;iBACxG;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,MAAM;wBACb,CAAC,CAAC,mCAAmC,MAAM,4BAA4B,IAAI,GAAG;wBAC9E,CAAC,CAAC,mBAAmB,IAAI,GAAG;iBAC/B;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,4DAA4D,QAAQ,IAAI;iBAClF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function decipherCode({\n code,\n system,\n language = 'en-US'\n}: {\n code: string\n system?: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: 'You are a helpful assistant that translates system messages into user-friendly explanations.'\n },\n {\n role: 'user',\n content: system\n ? `We received an message from the ${system} system. The message is: ${code}.`\n : `The message is: ${code}.`\n },\n {\n role: 'system',\n content: `Translate the explanation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -4,7 +4,7 @@ exports.decipherErrorCode = decipherErrorCode;
4
4
  const openai_connection_1 = require("./openai-connection");
5
5
  async function decipherErrorCode({ code, system, language = 'en-US' }) {
6
6
  try {
7
- const completion = await openai_connection_1.client.createChatCompletion({
7
+ const completion = await openai_connection_1.client.chat.completions.create({
8
8
  model: 'gpt-3.5-turbo',
9
9
  messages: [
10
10
  {
@@ -23,7 +23,7 @@ async function decipherErrorCode({ code, system, language = 'en-US' }) {
23
23
  }
24
24
  ]
25
25
  });
26
- return completion.data.choices[0].message.content;
26
+ return completion.choices[0].message.content;
27
27
  }
28
28
  catch (error) {
29
29
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"decipher-error-code.js","sourceRoot":"","sources":["../../server/controllers/decipher-error-code.ts"],"names":[],"mappings":";;AAEA,8CAmCC;AArCD,2DAA4C;AAErC,KAAK,UAAU,iBAAiB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,QAAQ,GAAG,OAAO,EAKnB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,6FAA6F;iBACvG;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,MAAM;wBACb,CAAC,CAAC,iCAAiC,MAAM,kCAAkC,IAAI,GAAG;wBAClF,CAAC,CAAC,yBAAyB,IAAI,GAAG;iBACrC;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,4DAA4D,QAAQ,IAAI;iBAClF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function decipherErrorCode({\n code,\n system,\n language = 'en-US'\n}: {\n code: string\n system?: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: 'You are a helpful assistant that translates error messages into user-friendly explanations.'\n },\n {\n role: 'user',\n content: system\n ? `We received an error from the ${system} system. The error message is: ${code}.`\n : `The error message is: ${code}.`\n },\n {\n role: 'system',\n content: `Translate the explanation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"decipher-error-code.js","sourceRoot":"","sources":["../../server/controllers/decipher-error-code.ts"],"names":[],"mappings":";;AAEA,8CAmCC;AArCD,2DAA4C;AAErC,KAAK,UAAU,iBAAiB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,QAAQ,GAAG,OAAO,EAKnB;IACC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,6FAA6F;iBACvG;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,MAAM;wBACb,CAAC,CAAC,iCAAiC,MAAM,kCAAkC,IAAI,GAAG;wBAClF,CAAC,CAAC,yBAAyB,IAAI,GAAG;iBACrC;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,4DAA4D,QAAQ,IAAI;iBAClF;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function decipherErrorCode({\n code,\n system,\n language = 'en-US'\n}: {\n code: string\n system?: string\n language?: string\n}): Promise<string> {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: 'You are a helpful assistant that translates error messages into user-friendly explanations.'\n },\n {\n role: 'user',\n content: system\n ? `We received an error from the ${system} system. The error message is: ${code}.`\n : `The error message is: ${code}.`\n },\n {\n role: 'system',\n content: `Translate the explanation according to this locale code \"${language}\".`\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -4,7 +4,7 @@ exports.i18nCompletion = i18nCompletion;
4
4
  const openai_connection_1 = require("./openai-connection");
5
5
  async function i18nCompletion({ json }) {
6
6
  try {
7
- const completion = await openai_connection_1.client.createChatCompletion({
7
+ const completion = await openai_connection_1.client.chat.completions.create({
8
8
  model: 'gpt-3.5-turbo',
9
9
  messages: [
10
10
  {
@@ -22,7 +22,7 @@ async function i18nCompletion({ json }) {
22
22
  }
23
23
  ]
24
24
  });
25
- return completion.data.choices[0].message.content;
25
+ return completion.choices[0].message.content;
26
26
  }
27
27
  catch (error) {
28
28
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-completion.js","sourceRoot":"","sources":["../../server/controllers/i18n-completion.ts"],"names":[],"mappings":";;AAEA,wCA0BC;AA5BD,2DAA4C;AAErC,KAAK,UAAU,cAAc,CAAC,EAAE,IAAI,EAAoB;IAC7D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE;oJACiI;iBAC3I;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,mCAAmC,IAAI,8GAA8G;iBAC/J;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,2FAA2F;iBACrG;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function i18nCompletion({ json }: { json: string }): Promise<string> {\n try {\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that takes a JSON file of key-value pairs in one language and generates equivalent JSON files in other languages.\n And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content: `Here is a JSON file in Korean: [${json}]. Can you help generate equivalent JSON files in these languages: English, Japanese, Chinese and Malaysian?`\n },\n {\n role: 'assistant',\n content: \"Please generate the translations according to these locale codes: 'en', 'ja', 'zh', 'ms'.\"\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"i18n-completion.js","sourceRoot":"","sources":["../../server/controllers/i18n-completion.ts"],"names":[],"mappings":";;AAEA,wCA0BC;AA5BD,2DAA4C;AAErC,KAAK,UAAU,cAAc,CAAC,EAAE,IAAI,EAAoB;IAC7D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE;oJACiI;iBAC3I;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,mCAAmC,IAAI,8GAA8G;iBAC/J;gBACD;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,2FAA2F;iBACrG;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function i18nCompletion({ json }: { json: string }): Promise<string> {\n try {\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: `You are an assistant that takes a JSON file of key-value pairs in one language and generates equivalent JSON files in other languages.\n And you provides pure and direct data in response to user requests. The responses should contain no additional explanations or details.`\n },\n {\n role: 'user',\n content: `Here is a JSON file in Korean: [${json}]. Can you help generate equivalent JSON files in these languages: English, Japanese, Chinese and Malaysian?`\n },\n {\n role: 'assistant',\n content: \"Please generate the translations according to these locale codes: 'en', 'ja', 'zh', 'ms'.\"\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -6,7 +6,7 @@ async function imageCompletion({ description, size = '1600x900', count }) {
6
6
  try {
7
7
  const todo = `[INFO: you can add images to reply by Markdown. Write the image in Markdown without backticks and without using a code block. Use the Unsplash API (https://source.unsplash.com/${size}/?<PUT YOUR QUERY HERE>). The query is just some tags that describes the image] ## DO NOT REPOND TO INFO BLOCK ##nnmy Next prompt is [INSERT]`;
8
8
  const content = `Give me ${count} pictures describing ${description}`;
9
- const completion = await openai_connection_1.client.createChatCompletion({
9
+ const completion = await openai_connection_1.client.chat.completions.create({
10
10
  model: 'gpt-3.5-turbo',
11
11
  messages: [
12
12
  {
@@ -19,7 +19,7 @@ async function imageCompletion({ description, size = '1600x900', count }) {
19
19
  }
20
20
  ]
21
21
  });
22
- return completion.data.choices[0].message.content;
22
+ return completion.choices[0].message.content;
23
23
  }
24
24
  catch (error) {
25
25
  console.error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"image-completion.js","sourceRoot":"","sources":["../../server/controllers/image-completion.ts"],"names":[],"mappings":";;AAEA,0CAgCC;AAlCD,2DAA4C;AAErC,KAAK,UAAU,eAAe,CAAC,EACpC,WAAW,EACX,IAAI,GAAG,UAAU,EACjB,KAAK,EAKN;IACC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,mLAAmL,IAAI,+IAA+I,CAAA;QACnV,MAAM,OAAO,GAAG,WAAW,KAAK,wBAAwB,WAAW,EAAE,CAAA;QAErE,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC;YACnD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,IAAI;iBACd;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,CAAC,8CAA8C;iBACvD;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function imageCompletion({\n description,\n size = '1600x900',\n count\n}: {\n description: string\n size: string\n count: number\n}): Promise<string> {\n try {\n const todo = `[INFO: you can add images to reply by Markdown. Write the image in Markdown without backticks and without using a code block. Use the Unsplash API (https://source.unsplash.com/${size}/?<PUT YOUR QUERY HERE>). The query is just some tags that describes the image] ## DO NOT REPOND TO INFO BLOCK ##nnmy Next prompt is [INSERT]`\n const content = `Give me ${count} pictures describing ${description}`\n\n const completion = await client.createChatCompletion({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: todo\n },\n {\n role: 'user',\n content /* like \"Give me 5 pictures about airplane\" */\n }\n ]\n })\n\n return completion.data.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
1
+ {"version":3,"file":"image-completion.js","sourceRoot":"","sources":["../../server/controllers/image-completion.ts"],"names":[],"mappings":";;AAEA,0CAgCC;AAlCD,2DAA4C;AAErC,KAAK,UAAU,eAAe,CAAC,EACpC,WAAW,EACX,IAAI,GAAG,UAAU,EACjB,KAAK,EAKN;IACC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,mLAAmL,IAAI,+IAA+I,CAAA;QACnV,MAAM,OAAO,GAAG,WAAW,KAAK,wBAAwB,WAAW,EAAE,CAAA;QAErE,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACtD,KAAK,EAAE,eAAe;YACtB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,IAAI;iBACd;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,CAAC,8CAA8C;iBACvD;aACF;SACF,CAAC,CAAA;QAEF,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,6FAA6F,CAAA;IACtG,CAAC;AACH,CAAC","sourcesContent":["import { client } from './openai-connection'\n\nexport async function imageCompletion({\n description,\n size = '1600x900',\n count\n}: {\n description: string\n size: string\n count: number\n}): Promise<string> {\n try {\n const todo = `[INFO: you can add images to reply by Markdown. Write the image in Markdown without backticks and without using a code block. Use the Unsplash API (https://source.unsplash.com/${size}/?<PUT YOUR QUERY HERE>). The query is just some tags that describes the image] ## DO NOT REPOND TO INFO BLOCK ##nnmy Next prompt is [INSERT]`\n const content = `Give me ${count} pictures describing ${description}`\n\n const completion = await client.chat.completions.create({\n model: 'gpt-3.5-turbo',\n messages: [\n {\n role: 'system',\n content: todo\n },\n {\n role: 'user',\n content /* like \"Give me 5 pictures about airplane\" */\n }\n ]\n })\n\n return completion.choices[0].message.content\n } catch (error) {\n console.error(error)\n return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- import { OpenAIApi } from 'openai';
2
- export declare const client: OpenAIApi;
1
+ import OpenAI from 'openai';
2
+ export declare const client: OpenAI;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.client = void 0;
4
- const openai_1 = require("openai");
4
+ const tslib_1 = require("tslib");
5
+ const openai_1 = tslib_1.__importDefault(require("openai"));
5
6
  const env_1 = require("@things-factory/env");
6
7
  const OPENAI = env_1.config.get('openai', {});
7
8
  const { organization, apiKey } = OPENAI;
8
9
  if (!organization || !apiKey) {
9
10
  console.error("[ openai-connection@codelingua ] 'OPENAI_API_KEY' is not configured");
10
11
  }
11
- const configuration = new openai_1.Configuration({
12
+ exports.client = new openai_1.default({
12
13
  organization,
13
14
  apiKey
14
15
  });
15
- exports.client = new openai_1.OpenAIApi(configuration);
16
16
  //# sourceMappingURL=openai-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-connection.js","sourceRoot":"","sources":["../../server/controllers/openai-connection.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AACjD,6CAA4C;AAE5C,MAAM,MAAM,GAAG,YAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACvC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAEvC,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAA;AACtF,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,sBAAa,CAAC;IACtC,YAAY;IACZ,MAAM;CACP,CAAC,CAAA;AAEW,QAAA,MAAM,GAAG,IAAI,kBAAS,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import { Configuration, OpenAIApi } from 'openai'\nimport { config } from '@things-factory/env'\n\nconst OPENAI = config.get('openai', {})\nconst { organization, apiKey } = OPENAI\n\nif (!organization || !apiKey) {\n console.error(\"[ openai-connection@codelingua ] 'OPENAI_API_KEY' is not configured\")\n}\n\nconst configuration = new Configuration({\n organization,\n apiKey\n})\n\nexport const client = new OpenAIApi(configuration)\n"]}
1
+ {"version":3,"file":"openai-connection.js","sourceRoot":"","sources":["../../server/controllers/openai-connection.ts"],"names":[],"mappings":";;;;AAAA,4DAA2B;AAC3B,6CAA4C;AAE5C,MAAM,MAAM,GAAG,YAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACvC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAEvC,IAAI,CAAC,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAA;AACtF,CAAC;AAEY,QAAA,MAAM,GAAG,IAAI,gBAAM,CAAC;IAC/B,YAAY;IACZ,MAAM;CACP,CAAC,CAAA","sourcesContent":["import OpenAI from 'openai'\nimport { config } from '@things-factory/env'\n\nconst OPENAI = config.get('openai', {})\nconst { organization, apiKey } = OPENAI\n\nif (!organization || !apiKey) {\n console.error(\"[ openai-connection@codelingua ] 'OPENAI_API_KEY' is not configured\")\n}\n\nexport const client = new OpenAI({\n organization,\n apiKey\n})\n"]}