@cobrowser/chatgpt 0.7.26 → 0.7.28
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/dist/constants.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const MESSAGE_TYPES: {
|
|
|
6
6
|
text: string;
|
|
7
7
|
button: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const DEFAULT_PROMPT = "You are a helpful assistant. Your role is to address visitor \
|
|
9
|
+
export declare const DEFAULT_PROMPT = "\n You are a helpful assistant. Your role is to address visitor \n queries related to the ongoing conversation and the last message received. Please ensure \n that responses remain within the ongoing conversation. Politely decline any user queries \n that is not present in the ongoing conversation. \n\n You will always respond with a JSON. It will be in the format: \n\n { answer: '', suggestions: [], connectWithAgent: true or false }\n\n Fields in the JSON:\n\n Answer: It will consist of the user's query answer based on the ongoing conversation. \n Restrict this field to 100 characters.\n\n Suggestions: Request 2 suggestions from user's perspective that he can ask. \n It should be an array of strings. Restrict each suggestion to 50 characters.\n \n ConnectWithAgent: It is a boolean. It should be set to true if the user's query is \n not found in the ongoing conversation. Politely tell the user to talk to a real agent. \n Also when it is true, do not provide any suggestions.\n";
|
|
10
10
|
export declare const DESTINATION_LANGUAGE = "English";
|
|
11
11
|
export declare const LANGUAGE_DETECTION_SYSTEM_ROLE = "\n You are a language detection assistant. Your task is to analyze short text input and determine \n its language using ISO language code. Respond only in JSON format with two key-value pairs: \n - 'languageCode': the detected language's ISO code (or undefined if detection fails).\n - 'isError': a boolean value (true if detection fails, false otherwise).\n";
|
|
12
12
|
export declare const WORD_FREQUENCY_LANGUAGE_DETECTION_SYSTEM_ROLE = "\n You are a language detection assistant. Your task is to analyze the most frequently occurring words in the given text \n and determine the language based on those words. Respond only in JSON format with two key-value pairs: \n - 'languageCode': the detected language's ISO code (or undefined if detection fails).\n - 'isError': a boolean value (true if detection fails, false otherwise).\n";
|
package/dist/constants.js
CHANGED
|
@@ -12,26 +12,27 @@ exports.MESSAGE_TYPES = {
|
|
|
12
12
|
button: 'button'
|
|
13
13
|
};
|
|
14
14
|
// Default prompt for ChatGPT
|
|
15
|
-
exports.DEFAULT_PROMPT = `
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
that
|
|
15
|
+
exports.DEFAULT_PROMPT = `
|
|
16
|
+
You are a helpful assistant. Your role is to address visitor
|
|
17
|
+
queries related to the ongoing conversation and the last message received. Please ensure
|
|
18
|
+
that responses remain within the ongoing conversation. Politely decline any user queries
|
|
19
|
+
that is not present in the ongoing conversation.
|
|
19
20
|
|
|
20
|
-
You will always respond with a JSON. It will be in the format:
|
|
21
|
+
You will always respond with a JSON. It will be in the format:
|
|
21
22
|
|
|
22
|
-
{ answer: '', suggestions: [], connectWithAgent: true or false }
|
|
23
|
+
{ answer: '', suggestions: [], connectWithAgent: true or false }
|
|
23
24
|
|
|
24
|
-
Fields in the JSON:
|
|
25
|
+
Fields in the JSON:
|
|
25
26
|
|
|
26
|
-
Answer: It will consist of the user's query answer based on the ongoing conversation.
|
|
27
|
-
Restrict this field to 100 characters.
|
|
27
|
+
Answer: It will consist of the user's query answer based on the ongoing conversation.
|
|
28
|
+
Restrict this field to 100 characters.
|
|
28
29
|
|
|
29
|
-
Suggestions: Request 2 suggestions from user's perspective that he can ask.
|
|
30
|
-
It should be an array of strings. Restrict each suggestion to 50 characters.
|
|
31
|
-
|
|
32
|
-
ConnectWithAgent: It is a boolean. It should be set to true if the user's query is
|
|
33
|
-
not found in the ongoing conversation. Politely tell the user to talk to a real agent.
|
|
34
|
-
Also when it is true, do not provide any suggestions.
|
|
30
|
+
Suggestions: Request 2 suggestions from user's perspective that he can ask.
|
|
31
|
+
It should be an array of strings. Restrict each suggestion to 50 characters.
|
|
32
|
+
|
|
33
|
+
ConnectWithAgent: It is a boolean. It should be set to true if the user's query is
|
|
34
|
+
not found in the ongoing conversation. Politely tell the user to talk to a real agent.
|
|
35
|
+
Also when it is true, do not provide any suggestions.
|
|
35
36
|
`;
|
|
36
37
|
// Default destination language
|
|
37
38
|
exports.DESTINATION_LANGUAGE = 'English';
|
|
@@ -106,6 +106,7 @@ class BaseService {
|
|
|
106
106
|
* @param data
|
|
107
107
|
*/
|
|
108
108
|
output(data, shouldStringify = false) {
|
|
109
|
+
console.log('DATA: ', data);
|
|
109
110
|
if (!data) {
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
@@ -117,6 +118,8 @@ class BaseService {
|
|
|
117
118
|
catch (error) { }
|
|
118
119
|
}
|
|
119
120
|
const sanitized = xss_validation_1.XSSProtector.sanitize(data), encoded = xss_validation_1.XSSProtector.encode(sanitized);
|
|
121
|
+
console.log('sanitized: ', sanitized);
|
|
122
|
+
console.log('encoded: ', encoded);
|
|
120
123
|
logger_1.default.info({ data, sanitized, encoded }, ':: Sanitized Response ::');
|
|
121
124
|
return shouldStringify ? JSON.stringify(encoded) : encoded;
|
|
122
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobrowser/chatgpt",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.28",
|
|
4
4
|
"description": "chatgpt services to connect our projects with chatgpt api",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatgpt",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@cobrowser/logger": "^2.0.2",
|
|
25
|
-
"@cobrowser/xss-validation": "^2.0.
|
|
25
|
+
"@cobrowser/xss-validation": "^2.0.1",
|
|
26
26
|
"axios": "^1.6.1",
|
|
27
27
|
"axios-mock-adapter": "^1.22.0",
|
|
28
28
|
"openai": "^4.86.2"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"bugs": {
|
|
41
41
|
"url": "https://bitbucket.org/cobrowser/cb_utils/issues"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f547f433ea89be8b15b98081b3f80a396bd591e7"
|
|
44
44
|
}
|