mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
wip
This commit is contained in:

committed by
Geoff Seemueller

parent
21d6c8604e
commit
554096abb2
25
packages/schema/package.json
Normal file
25
packages/schema/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@open-gsio/schema",
|
||||
"version": "0.0.1",
|
||||
"description": "Schema for open-gsio",
|
||||
"type": "module",
|
||||
"module": "src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./src/index.ts",
|
||||
"types": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "vitest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.2",
|
||||
"mobx-state-tree": "^6.0.1"
|
||||
}
|
||||
}
|
3
packages/schema/src/index.ts
Normal file
3
packages/schema/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as Schema from './models';
|
||||
|
||||
export { Schema };
|
11
packages/schema/src/models/ContactRecord.ts
Normal file
11
packages/schema/src/models/ContactRecord.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { types } from 'mobx-state-tree';
|
||||
|
||||
const ContactRecord = types.model('ContactRecord', {
|
||||
message: types.string,
|
||||
timestamp: types.string,
|
||||
email: types.string,
|
||||
firstname: types.string,
|
||||
lastname: types.string,
|
||||
});
|
||||
|
||||
export default ContactRecord;
|
10
packages/schema/src/models/FeedbackRecord.ts
Normal file
10
packages/schema/src/models/FeedbackRecord.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// FeedbackRecord.ts
|
||||
import { types } from 'mobx-state-tree';
|
||||
|
||||
const FeedbackRecord = types.model('FeedbackRecord', {
|
||||
feedback: types.string,
|
||||
timestamp: types.string,
|
||||
user: types.optional(types.string, 'Anonymous'),
|
||||
});
|
||||
|
||||
export default FeedbackRecord;
|
18
packages/schema/src/models/Message.ts
Normal file
18
packages/schema/src/models/Message.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// Base Message
|
||||
import { type Instance, types } from 'mobx-state-tree';
|
||||
|
||||
export default types
|
||||
.model('Message', {
|
||||
content: types.string,
|
||||
role: types.enumeration(['user', 'assistant', 'system']),
|
||||
})
|
||||
.actions(self => ({
|
||||
setContent(newContent: string) {
|
||||
self.content = newContent;
|
||||
},
|
||||
append(newContent: string) {
|
||||
self.content += newContent;
|
||||
},
|
||||
}));
|
||||
|
||||
export type MessageType = Instance<typeof this>;
|
20
packages/schema/src/models/O1Message.ts
Normal file
20
packages/schema/src/models/O1Message.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { types } from 'mobx-state-tree';
|
||||
|
||||
export default types
|
||||
.model('O1Message', {
|
||||
role: types.enumeration(['user', 'assistant', 'system']),
|
||||
content: types.array(
|
||||
types.model({
|
||||
type: types.string,
|
||||
text: types.string,
|
||||
}),
|
||||
),
|
||||
})
|
||||
.actions(self => ({
|
||||
setContent(newContent: string, contentType: string = 'text') {
|
||||
self.content = [{ type: contentType, text: newContent }];
|
||||
},
|
||||
append(newContent: string, contentType: string = 'text') {
|
||||
self.content.push({ type: contentType, text: newContent });
|
||||
},
|
||||
}));
|
16
packages/schema/src/models/OpenAiMessage.ts
Normal file
16
packages/schema/src/models/OpenAiMessage.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// Models
|
||||
import { types } from 'mobx-state-tree';
|
||||
|
||||
export default types
|
||||
.model('Message', {
|
||||
content: types.string,
|
||||
role: types.enumeration(['user', 'assistant', 'system']),
|
||||
})
|
||||
.actions(self => ({
|
||||
setContent(newContent: string) {
|
||||
self.content = newContent;
|
||||
},
|
||||
append(newContent: string) {
|
||||
self.content += newContent;
|
||||
},
|
||||
}));
|
7
packages/schema/src/models/index.ts
Normal file
7
packages/schema/src/models/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import ContactRecord from './ContactRecord';
|
||||
import FeedbackRecord from './FeedbackRecord';
|
||||
import Message from './Message';
|
||||
import O1Message from './O1Message';
|
||||
import OpenAiMessage from './OpenAiMessage';
|
||||
|
||||
export { ContactRecord, FeedbackRecord, Message, O1Message, OpenAiMessage };
|
Reference in New Issue
Block a user