okai 0.0.3 → 0.0.5
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/index.js +236 -11153
- package/dist/info.js +59 -0
- package/dist/okai.js +2 -11179
- package/dist/openai.js +97 -0
- package/dist/types.js +1 -0
- package/dist/utils.js +32 -0
- package/package.json +2 -2
- package/dist/index.d.ts +0 -5
- package/dist/okai.d.ts +0 -5
package/dist/openai.js
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
/* Options:
|
2
|
+
Date: 2024-11-29 17:33:02
|
3
|
+
Version: 8.53
|
4
|
+
Tip: To override a DTO option, remove "//" prefix before updating
|
5
|
+
BaseUrl: https://openai.servicestack.net
|
6
|
+
|
7
|
+
//GlobalNamespace:
|
8
|
+
//MakePropertiesOptional: False
|
9
|
+
//AddServiceStackTypes: True
|
10
|
+
//AddResponseStatus: False
|
11
|
+
//AddImplicitVersion:
|
12
|
+
//AddDescriptionAsComments: True
|
13
|
+
IncludeTypes: OpenAiChatCompletion.*
|
14
|
+
//ExcludeTypes:
|
15
|
+
//DefaultImports:
|
16
|
+
*/
|
17
|
+
/** @description The tool calls generated by the model, such as function calls. */
|
18
|
+
// @Api(Description="The tool calls generated by the model, such as function calls.")
|
19
|
+
// @DataContract
|
20
|
+
export class ToolCall {
|
21
|
+
constructor(init) { Object.assign(this, init); }
|
22
|
+
}
|
23
|
+
/** @description A list of messages comprising the conversation so far. */
|
24
|
+
// @Api(Description="A list of messages comprising the conversation so far.")
|
25
|
+
// @DataContract
|
26
|
+
export class OpenAiMessage {
|
27
|
+
constructor(init) { Object.assign(this, init); }
|
28
|
+
}
|
29
|
+
export var ResponseFormat;
|
30
|
+
(function (ResponseFormat) {
|
31
|
+
ResponseFormat["Text"] = "text";
|
32
|
+
ResponseFormat["JsonObject"] = "json_object";
|
33
|
+
})(ResponseFormat || (ResponseFormat = {}));
|
34
|
+
// @DataContract
|
35
|
+
export class OpenAiResponseFormat {
|
36
|
+
constructor(init) { Object.assign(this, init); }
|
37
|
+
}
|
38
|
+
export var OpenAiToolType;
|
39
|
+
(function (OpenAiToolType) {
|
40
|
+
OpenAiToolType["Function"] = "function";
|
41
|
+
})(OpenAiToolType || (OpenAiToolType = {}));
|
42
|
+
// @DataContract
|
43
|
+
export class OpenAiTools {
|
44
|
+
constructor(init) { Object.assign(this, init); }
|
45
|
+
}
|
46
|
+
/** @description Given a list of messages comprising a conversation, the model will return a response. */
|
47
|
+
// @Api(Description="Given a list of messages comprising a conversation, the model will return a response.")
|
48
|
+
// @DataContract
|
49
|
+
export class OpenAiChat {
|
50
|
+
constructor(init) {
|
51
|
+
/** @description A list of messages comprising the conversation so far. */
|
52
|
+
// @DataMember(Name="messages")
|
53
|
+
// @ApiMember(Description="A list of messages comprising the conversation so far.")
|
54
|
+
this.messages = [];
|
55
|
+
Object.assign(this, init);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
// @DataContract
|
59
|
+
export class ResponseError {
|
60
|
+
constructor(init) { Object.assign(this, init); }
|
61
|
+
}
|
62
|
+
// @DataContract
|
63
|
+
export class ResponseStatus {
|
64
|
+
constructor(init) { Object.assign(this, init); }
|
65
|
+
}
|
66
|
+
// @DataContract
|
67
|
+
export class ChoiceMessage {
|
68
|
+
constructor(init) { Object.assign(this, init); }
|
69
|
+
}
|
70
|
+
export class Choice {
|
71
|
+
constructor(init) { Object.assign(this, init); }
|
72
|
+
}
|
73
|
+
/** @description Usage statistics for the completion request. */
|
74
|
+
// @Api(Description="Usage statistics for the completion request.")
|
75
|
+
// @DataContract
|
76
|
+
export class OpenAiUsage {
|
77
|
+
constructor(init) { Object.assign(this, init); }
|
78
|
+
}
|
79
|
+
// @DataContract
|
80
|
+
export class OpenAiChatResponse {
|
81
|
+
constructor(init) {
|
82
|
+
/** @description A list of chat completion choices. Can be more than one if n is greater than 1. */
|
83
|
+
// @DataMember(Name="choices")
|
84
|
+
// @ApiMember(Description="A list of chat completion choices. Can be more than one if n is greater than 1.")
|
85
|
+
this.choices = [];
|
86
|
+
Object.assign(this, init);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
/** @description Given a list of messages comprising a conversation, the model will return a response. */
|
90
|
+
// @Route("/v1/chat/completions", "POST")
|
91
|
+
// @Api(Description="Given a list of messages comprising a conversation, the model will return a response.")
|
92
|
+
export class OpenAiChatCompletion extends OpenAiChat {
|
93
|
+
constructor(init) { super(init); Object.assign(this, init); }
|
94
|
+
getTypeName() { return 'OpenAiChatCompletion'; }
|
95
|
+
getMethod() { return 'POST'; }
|
96
|
+
createResponse() { return new OpenAiChatResponse(); }
|
97
|
+
}
|
package/dist/types.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/dist/utils.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
export function replaceMyApp(input, projectName) {
|
2
|
+
const condensed = projectName.replace(/_/g, '');
|
3
|
+
const kebabCase = camelToKebabCase(condensed);
|
4
|
+
const splitCase = splitPascalCase(condensed);
|
5
|
+
return input
|
6
|
+
.replace(/My_App/g, projectName)
|
7
|
+
.replace(/MyApp/g, projectName)
|
8
|
+
.replace(/My App/g, splitCase)
|
9
|
+
.replace(/my-app/g, kebabCase)
|
10
|
+
.replace(/myapp/g, condensed.toLowerCase())
|
11
|
+
.replace(/my_app/g, projectName.toLowerCase());
|
12
|
+
}
|
13
|
+
export function splitPascalCase(str) {
|
14
|
+
if (!str || str.length <= 1)
|
15
|
+
return str;
|
16
|
+
// Replace capital letters with space + letter, trim any leading space
|
17
|
+
return str
|
18
|
+
.replace(/([A-Z])/g, ' $1')
|
19
|
+
.trim();
|
20
|
+
}
|
21
|
+
export function camelToKebabCase(str) {
|
22
|
+
if (!str || str.length <= 1)
|
23
|
+
return str.toLowerCase();
|
24
|
+
// Insert hyphen before capitals and numbers, convert to lowercase
|
25
|
+
return str
|
26
|
+
.replace(/([A-Z0-9])/g, '-$1')
|
27
|
+
.toLowerCase()
|
28
|
+
// Remove leading hyphen if exists
|
29
|
+
.replace(/^-/, '')
|
30
|
+
// Replace multiple hyphens with single hyphen
|
31
|
+
.replace(/-+/g, '-');
|
32
|
+
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "okai",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.5",
|
5
5
|
"bin": "./dist/okai.js",
|
6
6
|
"main": "./dist/index.js",
|
7
7
|
"module": "./dist/index.js",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"import": "./dist/index.js"
|
13
13
|
},
|
14
14
|
"scripts": {
|
15
|
-
"build": "bun run
|
15
|
+
"build": "bun run clean && tsc",
|
16
16
|
"clean": "shx rm -rf ./dist",
|
17
17
|
"test": "bun test --",
|
18
18
|
"prepublishOnly": "bun run build",
|
package/dist/index.d.ts
DELETED