This commit is contained in:
geoffsee
2025-06-25 13:20:59 -04:00
committed by Geoff Seemueller
parent 21d6c8604e
commit 554096abb2
86 changed files with 556 additions and 508 deletions

View 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"
}
}

View File

@@ -0,0 +1,3 @@
import * as Schema from './models';
export { Schema };

View 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;

View 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;

View 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>;

View 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 });
},
}));

View 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;
},
}));

View 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 };