@aj-archipelago/cortex 1.1.8 → 1.1.9

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.
Files changed (2) hide show
  1. package/lib/util.js +36 -0
  2. package/package.json +1 -1
package/lib/util.js ADDED
@@ -0,0 +1,36 @@
1
+ function convertToSingleContentChatHistory(chatHistory){
2
+ for(let i=0; i<chatHistory.length; i++){
3
+ //if isarray make it single string
4
+ if (Array.isArray(chatHistory[i]?.content)) {
5
+ chatHistory[i].content = chatHistory[i].content.join("\n");
6
+ }
7
+ }
8
+ }
9
+
10
+ //check if args has a type in chatHistory
11
+ function chatArgsHasType(args, type){
12
+ const { chatHistory } = args;
13
+ for(const ch of chatHistory){
14
+ for(const content of ch.content){
15
+ try{
16
+ if(JSON.parse(content).type == type){
17
+ return true;
18
+ }
19
+ }catch(e){
20
+ continue;
21
+ }
22
+ }
23
+ }
24
+ return false;
25
+ }
26
+
27
+ //check if args has an image_url in chatHistory
28
+ function chatArgsHasImageUrl(args){
29
+ return chatArgsHasType(args, 'image_url');
30
+ }
31
+
32
+ export {
33
+ convertToSingleContentChatHistory,
34
+ chatArgsHasImageUrl,
35
+ chatArgsHasType
36
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aj-archipelago/cortex",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Cortex is a GraphQL API for AI. It provides a simple, extensible interface for using AI services from OpenAI, Azure and others.",
5
5
  "private": false,
6
6
  "repository": {