@coasys/ad4m 0.10.0-rc7.local-ai.4 → 0.10.0
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/lib/index.cjs +142 -3
- package/lib/index.js +142 -3
- package/lib/src/ai/AIClient.d.ts +7 -0
- package/lib/src/ai/AIClient.js +95 -3
- package/lib/src/ai/AIResolver.d.ts +42 -0
- package/lib/src/ai/AIResolver.js +227 -1
- package/lib/src/schema.gql +47 -0
- package/lib/src/typeDefs.js +47 -0
- package/package.json +3 -4
- package/src/Ad4mClient.test.ts +83 -0
- package/src/ai/AIClient.ts +102 -4
- package/src/ai/AIResolver.ts +164 -1
- package/yarn-error.log +90 -0
package/lib/index.cjs
CHANGED
|
@@ -14007,6 +14007,101 @@ class AIClient {
|
|
|
14007
14007
|
_AIClient_transcriptionSubscriptions.set(this, new Map());
|
|
14008
14008
|
__classPrivateFieldSet$3(this, _AIClient_apolloClient, apolloClient, "f");
|
|
14009
14009
|
}
|
|
14010
|
+
async getModels() {
|
|
14011
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14012
|
+
query: gql `
|
|
14013
|
+
query {
|
|
14014
|
+
aiGetModels {
|
|
14015
|
+
id
|
|
14016
|
+
name
|
|
14017
|
+
api {
|
|
14018
|
+
baseUrl
|
|
14019
|
+
apiKey
|
|
14020
|
+
model
|
|
14021
|
+
apiType
|
|
14022
|
+
}
|
|
14023
|
+
local {
|
|
14024
|
+
fileName
|
|
14025
|
+
tokenizerSource
|
|
14026
|
+
modelParameters
|
|
14027
|
+
}
|
|
14028
|
+
modelType
|
|
14029
|
+
}
|
|
14030
|
+
}
|
|
14031
|
+
`
|
|
14032
|
+
});
|
|
14033
|
+
return unwrapApolloResult(result).aiGetModels;
|
|
14034
|
+
}
|
|
14035
|
+
async addModel(model) {
|
|
14036
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14037
|
+
mutation: gql `
|
|
14038
|
+
mutation($model: ModelInput!) {
|
|
14039
|
+
aiAddModel(model: $model)
|
|
14040
|
+
}
|
|
14041
|
+
`,
|
|
14042
|
+
variables: { model }
|
|
14043
|
+
});
|
|
14044
|
+
return unwrapApolloResult(result).aiAddModel;
|
|
14045
|
+
}
|
|
14046
|
+
async updateModel(modelId, model) {
|
|
14047
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14048
|
+
mutation: gql `
|
|
14049
|
+
mutation($modelId: String!, $model: ModelInput!) {
|
|
14050
|
+
aiUpdateModel(modelId: $modelId, model: $model)
|
|
14051
|
+
}
|
|
14052
|
+
`,
|
|
14053
|
+
variables: { modelId, model }
|
|
14054
|
+
});
|
|
14055
|
+
return unwrapApolloResult(result).aiUpdateModel;
|
|
14056
|
+
}
|
|
14057
|
+
async removeModel(modelId) {
|
|
14058
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14059
|
+
mutation: gql `
|
|
14060
|
+
mutation($modelId: String!) {
|
|
14061
|
+
aiRemoveModel(modelId: $modelId)
|
|
14062
|
+
}
|
|
14063
|
+
`,
|
|
14064
|
+
variables: { modelId }
|
|
14065
|
+
});
|
|
14066
|
+
return unwrapApolloResult(result).aiRemoveModel;
|
|
14067
|
+
}
|
|
14068
|
+
async setDefaultModel(modelType, modelId) {
|
|
14069
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14070
|
+
mutation: gql `
|
|
14071
|
+
mutation($modelType: ModelType!, $modelId: String!) {
|
|
14072
|
+
aiSetDefaultModel(modelType: $modelType modelId: $modelId)
|
|
14073
|
+
}
|
|
14074
|
+
`,
|
|
14075
|
+
variables: { modelId, modelType }
|
|
14076
|
+
});
|
|
14077
|
+
return unwrapApolloResult(result).aiSetDefaultModel;
|
|
14078
|
+
}
|
|
14079
|
+
async getDefaultModel(modelType) {
|
|
14080
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14081
|
+
query: gql `
|
|
14082
|
+
query($modelType: ModelType!) {
|
|
14083
|
+
aiGetDefaultModel(modelType: $modelType) {
|
|
14084
|
+
id
|
|
14085
|
+
name
|
|
14086
|
+
api {
|
|
14087
|
+
baseUrl
|
|
14088
|
+
apiKey
|
|
14089
|
+
model
|
|
14090
|
+
apiType
|
|
14091
|
+
}
|
|
14092
|
+
local {
|
|
14093
|
+
fileName
|
|
14094
|
+
tokenizerSource
|
|
14095
|
+
modelParameters
|
|
14096
|
+
}
|
|
14097
|
+
modelType
|
|
14098
|
+
}
|
|
14099
|
+
}
|
|
14100
|
+
`,
|
|
14101
|
+
variables: { modelType }
|
|
14102
|
+
});
|
|
14103
|
+
return unwrapApolloResult(result).aiGetDefaultModel;
|
|
14104
|
+
}
|
|
14010
14105
|
async tasks() {
|
|
14011
14106
|
const { aiTasks } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14012
14107
|
query: gql `
|
|
@@ -14161,7 +14256,6 @@ class AIClient {
|
|
|
14161
14256
|
return decompressed;
|
|
14162
14257
|
}
|
|
14163
14258
|
async openTranscriptionStream(modelId, streamCallback) {
|
|
14164
|
-
console.log("Opening transcription stream for model:", modelId);
|
|
14165
14259
|
const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14166
14260
|
mutation: gql `
|
|
14167
14261
|
mutation AiOpenTranscriptionStream($modelId: String!) {
|
|
@@ -14172,14 +14266,12 @@ class AIClient {
|
|
|
14172
14266
|
modelId
|
|
14173
14267
|
}
|
|
14174
14268
|
}));
|
|
14175
|
-
console.log("Opened transcription stream:", aiOpenTranscriptionStream);
|
|
14176
14269
|
const subscription = __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").subscribe({
|
|
14177
14270
|
query: gql ` subscription {
|
|
14178
14271
|
aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
|
|
14179
14272
|
}`
|
|
14180
14273
|
}).subscribe({
|
|
14181
14274
|
next(data) {
|
|
14182
|
-
console.log("Received transcription:", data.data);
|
|
14183
14275
|
streamCallback(data.data.aiTranscriptionText);
|
|
14184
14276
|
return data.data.aiTranscriptionText;
|
|
14185
14277
|
},
|
|
@@ -15361,6 +15453,47 @@ input LinkQuery {
|
|
|
15361
15453
|
untilDate: DateTime
|
|
15362
15454
|
}
|
|
15363
15455
|
|
|
15456
|
+
type LocalModel {
|
|
15457
|
+
fileName: String!
|
|
15458
|
+
modelParameters: String!
|
|
15459
|
+
tokenizerSource: String!
|
|
15460
|
+
}
|
|
15461
|
+
|
|
15462
|
+
input LocalModelInput {
|
|
15463
|
+
fileName: String!
|
|
15464
|
+
modelParameters: String!
|
|
15465
|
+
tokenizerSource: String!
|
|
15466
|
+
}
|
|
15467
|
+
|
|
15468
|
+
type Model {
|
|
15469
|
+
api: ModelApi
|
|
15470
|
+
id: String!
|
|
15471
|
+
local: LocalModel
|
|
15472
|
+
modelType: String!
|
|
15473
|
+
name: String!
|
|
15474
|
+
}
|
|
15475
|
+
|
|
15476
|
+
type ModelApi {
|
|
15477
|
+
apiKey: String!
|
|
15478
|
+
apiType: String!
|
|
15479
|
+
baseUrl: String!
|
|
15480
|
+
model: String!
|
|
15481
|
+
}
|
|
15482
|
+
|
|
15483
|
+
input ModelApiInput {
|
|
15484
|
+
apiKey: String!
|
|
15485
|
+
apiType: String!
|
|
15486
|
+
baseUrl: String!
|
|
15487
|
+
model: String!
|
|
15488
|
+
}
|
|
15489
|
+
|
|
15490
|
+
input ModelInput {
|
|
15491
|
+
api: ModelApiInput
|
|
15492
|
+
local: LocalModelInput
|
|
15493
|
+
modelType: String!
|
|
15494
|
+
name: String!
|
|
15495
|
+
}
|
|
15496
|
+
|
|
15364
15497
|
type Mutation {
|
|
15365
15498
|
addTrustedAgents(agents: [String!]!): [String!]!
|
|
15366
15499
|
agentAddEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
|
|
@@ -15378,13 +15511,17 @@ type Mutation {
|
|
|
15378
15511
|
agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
|
|
15379
15512
|
agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
|
|
15380
15513
|
agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
|
|
15514
|
+
aiAddModel(model: ModelInput!): String!
|
|
15381
15515
|
aiAddTask(task: AITaskInput!): AITask!
|
|
15382
15516
|
aiCloseTranscriptionStream(streamId: String!): String!
|
|
15383
15517
|
aiEmbed(modelId: String!, text: String!): String!
|
|
15384
15518
|
aiFeedTranscriptionStream(audio: [Float!]!, streamId: String!): String!
|
|
15385
15519
|
aiOpenTranscriptionStream(modelId: String!): String!
|
|
15386
15520
|
aiPrompt(prompt: String!, taskId: String!): String!
|
|
15521
|
+
aiRemoveModel(modelId: String!): Boolean!
|
|
15387
15522
|
aiRemoveTask(taskId: String!): AITask!
|
|
15523
|
+
aiSetDefaultModel(modelId: String!, modelType: String!): Boolean!
|
|
15524
|
+
aiUpdateModel(model: ModelInput!, modelId: String!): Boolean!
|
|
15388
15525
|
aiUpdateTask(task: AITaskInput!, taskId: String!): AITask!
|
|
15389
15526
|
deleteTrustedAgents(agents: [String!]!): [String!]!
|
|
15390
15527
|
expressionCreate(content: String!, languageAddress: String!): String!
|
|
@@ -15506,6 +15643,8 @@ type Query {
|
|
|
15506
15643
|
agentGetEntanglementProofs: [EntanglementProof!]!
|
|
15507
15644
|
agentIsLocked: Boolean!
|
|
15508
15645
|
agentStatus: AgentStatus!
|
|
15646
|
+
aiGetDefaultModel(modelType: String!): Model!
|
|
15647
|
+
aiGetModels: [Model!]!
|
|
15509
15648
|
aiModelLoadingStatus(model: String!): AIModelLoadingStatus!
|
|
15510
15649
|
aiTasks: [AITask!]!
|
|
15511
15650
|
expression(url: String!): ExpressionRendered
|
package/lib/index.js
CHANGED
|
@@ -14003,6 +14003,101 @@ class AIClient {
|
|
|
14003
14003
|
_AIClient_transcriptionSubscriptions.set(this, new Map());
|
|
14004
14004
|
__classPrivateFieldSet$3(this, _AIClient_apolloClient, apolloClient, "f");
|
|
14005
14005
|
}
|
|
14006
|
+
async getModels() {
|
|
14007
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14008
|
+
query: gql `
|
|
14009
|
+
query {
|
|
14010
|
+
aiGetModels {
|
|
14011
|
+
id
|
|
14012
|
+
name
|
|
14013
|
+
api {
|
|
14014
|
+
baseUrl
|
|
14015
|
+
apiKey
|
|
14016
|
+
model
|
|
14017
|
+
apiType
|
|
14018
|
+
}
|
|
14019
|
+
local {
|
|
14020
|
+
fileName
|
|
14021
|
+
tokenizerSource
|
|
14022
|
+
modelParameters
|
|
14023
|
+
}
|
|
14024
|
+
modelType
|
|
14025
|
+
}
|
|
14026
|
+
}
|
|
14027
|
+
`
|
|
14028
|
+
});
|
|
14029
|
+
return unwrapApolloResult(result).aiGetModels;
|
|
14030
|
+
}
|
|
14031
|
+
async addModel(model) {
|
|
14032
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14033
|
+
mutation: gql `
|
|
14034
|
+
mutation($model: ModelInput!) {
|
|
14035
|
+
aiAddModel(model: $model)
|
|
14036
|
+
}
|
|
14037
|
+
`,
|
|
14038
|
+
variables: { model }
|
|
14039
|
+
});
|
|
14040
|
+
return unwrapApolloResult(result).aiAddModel;
|
|
14041
|
+
}
|
|
14042
|
+
async updateModel(modelId, model) {
|
|
14043
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14044
|
+
mutation: gql `
|
|
14045
|
+
mutation($modelId: String!, $model: ModelInput!) {
|
|
14046
|
+
aiUpdateModel(modelId: $modelId, model: $model)
|
|
14047
|
+
}
|
|
14048
|
+
`,
|
|
14049
|
+
variables: { modelId, model }
|
|
14050
|
+
});
|
|
14051
|
+
return unwrapApolloResult(result).aiUpdateModel;
|
|
14052
|
+
}
|
|
14053
|
+
async removeModel(modelId) {
|
|
14054
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14055
|
+
mutation: gql `
|
|
14056
|
+
mutation($modelId: String!) {
|
|
14057
|
+
aiRemoveModel(modelId: $modelId)
|
|
14058
|
+
}
|
|
14059
|
+
`,
|
|
14060
|
+
variables: { modelId }
|
|
14061
|
+
});
|
|
14062
|
+
return unwrapApolloResult(result).aiRemoveModel;
|
|
14063
|
+
}
|
|
14064
|
+
async setDefaultModel(modelType, modelId) {
|
|
14065
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14066
|
+
mutation: gql `
|
|
14067
|
+
mutation($modelType: ModelType!, $modelId: String!) {
|
|
14068
|
+
aiSetDefaultModel(modelType: $modelType modelId: $modelId)
|
|
14069
|
+
}
|
|
14070
|
+
`,
|
|
14071
|
+
variables: { modelId, modelType }
|
|
14072
|
+
});
|
|
14073
|
+
return unwrapApolloResult(result).aiSetDefaultModel;
|
|
14074
|
+
}
|
|
14075
|
+
async getDefaultModel(modelType) {
|
|
14076
|
+
const result = await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14077
|
+
query: gql `
|
|
14078
|
+
query($modelType: ModelType!) {
|
|
14079
|
+
aiGetDefaultModel(modelType: $modelType) {
|
|
14080
|
+
id
|
|
14081
|
+
name
|
|
14082
|
+
api {
|
|
14083
|
+
baseUrl
|
|
14084
|
+
apiKey
|
|
14085
|
+
model
|
|
14086
|
+
apiType
|
|
14087
|
+
}
|
|
14088
|
+
local {
|
|
14089
|
+
fileName
|
|
14090
|
+
tokenizerSource
|
|
14091
|
+
modelParameters
|
|
14092
|
+
}
|
|
14093
|
+
modelType
|
|
14094
|
+
}
|
|
14095
|
+
}
|
|
14096
|
+
`,
|
|
14097
|
+
variables: { modelType }
|
|
14098
|
+
});
|
|
14099
|
+
return unwrapApolloResult(result).aiGetDefaultModel;
|
|
14100
|
+
}
|
|
14006
14101
|
async tasks() {
|
|
14007
14102
|
const { aiTasks } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").query({
|
|
14008
14103
|
query: gql `
|
|
@@ -14157,7 +14252,6 @@ class AIClient {
|
|
|
14157
14252
|
return decompressed;
|
|
14158
14253
|
}
|
|
14159
14254
|
async openTranscriptionStream(modelId, streamCallback) {
|
|
14160
|
-
console.log("Opening transcription stream for model:", modelId);
|
|
14161
14255
|
const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
|
|
14162
14256
|
mutation: gql `
|
|
14163
14257
|
mutation AiOpenTranscriptionStream($modelId: String!) {
|
|
@@ -14168,14 +14262,12 @@ class AIClient {
|
|
|
14168
14262
|
modelId
|
|
14169
14263
|
}
|
|
14170
14264
|
}));
|
|
14171
|
-
console.log("Opened transcription stream:", aiOpenTranscriptionStream);
|
|
14172
14265
|
const subscription = __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").subscribe({
|
|
14173
14266
|
query: gql ` subscription {
|
|
14174
14267
|
aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
|
|
14175
14268
|
}`
|
|
14176
14269
|
}).subscribe({
|
|
14177
14270
|
next(data) {
|
|
14178
|
-
console.log("Received transcription:", data.data);
|
|
14179
14271
|
streamCallback(data.data.aiTranscriptionText);
|
|
14180
14272
|
return data.data.aiTranscriptionText;
|
|
14181
14273
|
},
|
|
@@ -15357,6 +15449,47 @@ input LinkQuery {
|
|
|
15357
15449
|
untilDate: DateTime
|
|
15358
15450
|
}
|
|
15359
15451
|
|
|
15452
|
+
type LocalModel {
|
|
15453
|
+
fileName: String!
|
|
15454
|
+
modelParameters: String!
|
|
15455
|
+
tokenizerSource: String!
|
|
15456
|
+
}
|
|
15457
|
+
|
|
15458
|
+
input LocalModelInput {
|
|
15459
|
+
fileName: String!
|
|
15460
|
+
modelParameters: String!
|
|
15461
|
+
tokenizerSource: String!
|
|
15462
|
+
}
|
|
15463
|
+
|
|
15464
|
+
type Model {
|
|
15465
|
+
api: ModelApi
|
|
15466
|
+
id: String!
|
|
15467
|
+
local: LocalModel
|
|
15468
|
+
modelType: String!
|
|
15469
|
+
name: String!
|
|
15470
|
+
}
|
|
15471
|
+
|
|
15472
|
+
type ModelApi {
|
|
15473
|
+
apiKey: String!
|
|
15474
|
+
apiType: String!
|
|
15475
|
+
baseUrl: String!
|
|
15476
|
+
model: String!
|
|
15477
|
+
}
|
|
15478
|
+
|
|
15479
|
+
input ModelApiInput {
|
|
15480
|
+
apiKey: String!
|
|
15481
|
+
apiType: String!
|
|
15482
|
+
baseUrl: String!
|
|
15483
|
+
model: String!
|
|
15484
|
+
}
|
|
15485
|
+
|
|
15486
|
+
input ModelInput {
|
|
15487
|
+
api: ModelApiInput
|
|
15488
|
+
local: LocalModelInput
|
|
15489
|
+
modelType: String!
|
|
15490
|
+
name: String!
|
|
15491
|
+
}
|
|
15492
|
+
|
|
15360
15493
|
type Mutation {
|
|
15361
15494
|
addTrustedAgents(agents: [String!]!): [String!]!
|
|
15362
15495
|
agentAddEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
|
|
@@ -15374,13 +15507,17 @@ type Mutation {
|
|
|
15374
15507
|
agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
|
|
15375
15508
|
agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
|
|
15376
15509
|
agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
|
|
15510
|
+
aiAddModel(model: ModelInput!): String!
|
|
15377
15511
|
aiAddTask(task: AITaskInput!): AITask!
|
|
15378
15512
|
aiCloseTranscriptionStream(streamId: String!): String!
|
|
15379
15513
|
aiEmbed(modelId: String!, text: String!): String!
|
|
15380
15514
|
aiFeedTranscriptionStream(audio: [Float!]!, streamId: String!): String!
|
|
15381
15515
|
aiOpenTranscriptionStream(modelId: String!): String!
|
|
15382
15516
|
aiPrompt(prompt: String!, taskId: String!): String!
|
|
15517
|
+
aiRemoveModel(modelId: String!): Boolean!
|
|
15383
15518
|
aiRemoveTask(taskId: String!): AITask!
|
|
15519
|
+
aiSetDefaultModel(modelId: String!, modelType: String!): Boolean!
|
|
15520
|
+
aiUpdateModel(model: ModelInput!, modelId: String!): Boolean!
|
|
15384
15521
|
aiUpdateTask(task: AITaskInput!, taskId: String!): AITask!
|
|
15385
15522
|
deleteTrustedAgents(agents: [String!]!): [String!]!
|
|
15386
15523
|
expressionCreate(content: String!, languageAddress: String!): String!
|
|
@@ -15502,6 +15639,8 @@ type Query {
|
|
|
15502
15639
|
agentGetEntanglementProofs: [EntanglementProof!]!
|
|
15503
15640
|
agentIsLocked: Boolean!
|
|
15504
15641
|
agentStatus: AgentStatus!
|
|
15642
|
+
aiGetDefaultModel(modelType: String!): Model!
|
|
15643
|
+
aiGetModels: [Model!]!
|
|
15505
15644
|
aiModelLoadingStatus(model: String!): AIModelLoadingStatus!
|
|
15506
15645
|
aiTasks: [AITask!]!
|
|
15507
15646
|
expression(url: String!): ExpressionRendered
|
package/lib/src/ai/AIClient.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { ApolloClient } from "@apollo/client";
|
|
2
2
|
import { AIModelLoadingStatus, AITask } from "./Tasks";
|
|
3
|
+
import { ModelInput, Model, ModelType } from "./AIResolver";
|
|
3
4
|
export declare class AIClient {
|
|
4
5
|
#private;
|
|
5
6
|
constructor(apolloClient: ApolloClient<any>, subscribe?: boolean);
|
|
7
|
+
getModels(): Promise<Model[]>;
|
|
8
|
+
addModel(model: ModelInput): Promise<string>;
|
|
9
|
+
updateModel(modelId: string, model: ModelInput): Promise<boolean>;
|
|
10
|
+
removeModel(modelId: string): Promise<boolean>;
|
|
11
|
+
setDefaultModel(modelType: ModelType, modelId: string): Promise<boolean>;
|
|
12
|
+
getDefaultModel(modelType: ModelType): Promise<Model>;
|
|
6
13
|
tasks(): Promise<AITask[]>;
|
|
7
14
|
addTask(name: string, modelId: string, systemPrompt: string, promptExamples: {
|
|
8
15
|
input: string;
|
package/lib/src/ai/AIClient.js
CHANGED
|
@@ -21,6 +21,101 @@ export class AIClient {
|
|
|
21
21
|
_AIClient_transcriptionSubscriptions.set(this, new Map());
|
|
22
22
|
__classPrivateFieldSet(this, _AIClient_apolloClient, apolloClient, "f");
|
|
23
23
|
}
|
|
24
|
+
async getModels() {
|
|
25
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
|
|
26
|
+
query: gql `
|
|
27
|
+
query {
|
|
28
|
+
aiGetModels {
|
|
29
|
+
id
|
|
30
|
+
name
|
|
31
|
+
api {
|
|
32
|
+
baseUrl
|
|
33
|
+
apiKey
|
|
34
|
+
model
|
|
35
|
+
apiType
|
|
36
|
+
}
|
|
37
|
+
local {
|
|
38
|
+
fileName
|
|
39
|
+
tokenizerSource
|
|
40
|
+
modelParameters
|
|
41
|
+
}
|
|
42
|
+
modelType
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
});
|
|
47
|
+
return unwrapApolloResult(result).aiGetModels;
|
|
48
|
+
}
|
|
49
|
+
async addModel(model) {
|
|
50
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
|
|
51
|
+
mutation: gql `
|
|
52
|
+
mutation($model: ModelInput!) {
|
|
53
|
+
aiAddModel(model: $model)
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
variables: { model }
|
|
57
|
+
});
|
|
58
|
+
return unwrapApolloResult(result).aiAddModel;
|
|
59
|
+
}
|
|
60
|
+
async updateModel(modelId, model) {
|
|
61
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
|
|
62
|
+
mutation: gql `
|
|
63
|
+
mutation($modelId: String!, $model: ModelInput!) {
|
|
64
|
+
aiUpdateModel(modelId: $modelId, model: $model)
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
variables: { modelId, model }
|
|
68
|
+
});
|
|
69
|
+
return unwrapApolloResult(result).aiUpdateModel;
|
|
70
|
+
}
|
|
71
|
+
async removeModel(modelId) {
|
|
72
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
|
|
73
|
+
mutation: gql `
|
|
74
|
+
mutation($modelId: String!) {
|
|
75
|
+
aiRemoveModel(modelId: $modelId)
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
78
|
+
variables: { modelId }
|
|
79
|
+
});
|
|
80
|
+
return unwrapApolloResult(result).aiRemoveModel;
|
|
81
|
+
}
|
|
82
|
+
async setDefaultModel(modelType, modelId) {
|
|
83
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
|
|
84
|
+
mutation: gql `
|
|
85
|
+
mutation($modelType: ModelType!, $modelId: String!) {
|
|
86
|
+
aiSetDefaultModel(modelType: $modelType modelId: $modelId)
|
|
87
|
+
}
|
|
88
|
+
`,
|
|
89
|
+
variables: { modelId, modelType }
|
|
90
|
+
});
|
|
91
|
+
return unwrapApolloResult(result).aiSetDefaultModel;
|
|
92
|
+
}
|
|
93
|
+
async getDefaultModel(modelType) {
|
|
94
|
+
const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
|
|
95
|
+
query: gql `
|
|
96
|
+
query($modelType: ModelType!) {
|
|
97
|
+
aiGetDefaultModel(modelType: $modelType) {
|
|
98
|
+
id
|
|
99
|
+
name
|
|
100
|
+
api {
|
|
101
|
+
baseUrl
|
|
102
|
+
apiKey
|
|
103
|
+
model
|
|
104
|
+
apiType
|
|
105
|
+
}
|
|
106
|
+
local {
|
|
107
|
+
fileName
|
|
108
|
+
tokenizerSource
|
|
109
|
+
modelParameters
|
|
110
|
+
}
|
|
111
|
+
modelType
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`,
|
|
115
|
+
variables: { modelType }
|
|
116
|
+
});
|
|
117
|
+
return unwrapApolloResult(result).aiGetDefaultModel;
|
|
118
|
+
}
|
|
24
119
|
async tasks() {
|
|
25
120
|
const { aiTasks } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
|
|
26
121
|
query: gql `
|
|
@@ -175,7 +270,6 @@ export class AIClient {
|
|
|
175
270
|
return decompressed;
|
|
176
271
|
}
|
|
177
272
|
async openTranscriptionStream(modelId, streamCallback) {
|
|
178
|
-
console.log("Opening transcription stream for model:", modelId);
|
|
179
273
|
const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
|
|
180
274
|
mutation: gql `
|
|
181
275
|
mutation AiOpenTranscriptionStream($modelId: String!) {
|
|
@@ -186,14 +280,12 @@ export class AIClient {
|
|
|
186
280
|
modelId
|
|
187
281
|
}
|
|
188
282
|
}));
|
|
189
|
-
console.log("Opened transcription stream:", aiOpenTranscriptionStream);
|
|
190
283
|
const subscription = __classPrivateFieldGet(this, _AIClient_apolloClient, "f").subscribe({
|
|
191
284
|
query: gql ` subscription {
|
|
192
285
|
aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
|
|
193
286
|
}`
|
|
194
287
|
}).subscribe({
|
|
195
288
|
next(data) {
|
|
196
|
-
console.log("Received transcription:", data.data);
|
|
197
289
|
streamCallback(data.data.aiTranscriptionText);
|
|
198
290
|
return data.data.aiTranscriptionText;
|
|
199
291
|
},
|
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
import { AIModelLoadingStatus, AITask, AITaskInput } from "./Tasks";
|
|
2
|
+
export declare class ModelApi {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
model: string;
|
|
6
|
+
apiType: String;
|
|
7
|
+
}
|
|
8
|
+
export declare class LocalModel {
|
|
9
|
+
fileName: string;
|
|
10
|
+
tokenizerSource: string;
|
|
11
|
+
modelParameters: string;
|
|
12
|
+
}
|
|
13
|
+
export type ModelType = "LLM" | "EMBEDDING" | "TRANSCRIPTION";
|
|
14
|
+
export declare class Model {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
api?: ModelApi;
|
|
18
|
+
local?: LocalModel;
|
|
19
|
+
modelType: ModelType;
|
|
20
|
+
}
|
|
21
|
+
export declare class ModelApiInput {
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
apiKey: string;
|
|
24
|
+
model: string;
|
|
25
|
+
apiType: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class LocalModelInput {
|
|
28
|
+
fileName: string;
|
|
29
|
+
tokenizerSource: string;
|
|
30
|
+
modelParameters: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class ModelInput {
|
|
33
|
+
name: string;
|
|
34
|
+
api?: ModelApiInput;
|
|
35
|
+
local?: LocalModelInput;
|
|
36
|
+
modelType: ModelType;
|
|
37
|
+
}
|
|
2
38
|
export default class AIResolver {
|
|
39
|
+
aiGetModels(): Model[];
|
|
40
|
+
aiAddModel(model: ModelInput): string;
|
|
41
|
+
aiUpdateModel(modelId: string, model: ModelInput): boolean;
|
|
42
|
+
aiRemoveModel(modelId: string): boolean;
|
|
43
|
+
aiSetDefaultModel(modelType: ModelType, modelId: string): boolean;
|
|
44
|
+
aiGetDefaultModel(modelType: ModelType): Model;
|
|
3
45
|
aiTasks(): AITask[];
|
|
4
46
|
aiAddTask(task: AITaskInput): AITask;
|
|
5
47
|
aiRemoveTask(taskId: string): AITask;
|