Skip to content

Commit

Permalink
Merge pull request #15 from xpert-ai/develop
Browse files Browse the repository at this point in the history
version 3.0.6
  • Loading branch information
tiven-w authored Dec 23, 2024
2 parents 6495031 + 8c9c32d commit b3fc13d
Show file tree
Hide file tree
Showing 204 changed files with 4,560 additions and 1,205 deletions.
4 changes: 2 additions & 2 deletions .deploy/api/package-prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"private": true,
"dependencies": {
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/core": "0.3.23",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
Expand All @@ -32,6 +32,6 @@
"packages/*"
],
"resolutions": {
"@langchain/core": "0.3.13"
"@langchain/core": "0.3.23"
}
}
4 changes: 2 additions & 2 deletions .deploy/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/core": "0.3.23",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
Expand Down Expand Up @@ -79,6 +79,6 @@
"packages/*"
],
"resolutions": {
"@langchain/core": "0.3.13"
"@langchain/core": "0.3.23"
}
}
4 changes: 2 additions & 2 deletions .deploy/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@foblex/platform": "^1.0.4",
"@foblex/utils": "^1.1.0",
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/core": "0.3.23",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
Expand Down Expand Up @@ -206,7 +206,7 @@
"packages/*"
],
"resolutions": {
"@langchain/core": "0.3.13"
"@langchain/core": "0.3.23"
},
"nx": {
"includedScripts": []
Expand Down
98 changes: 98 additions & 0 deletions apps/cloud/src/app/@core/services/configuration-schema.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { I18nObject } from '@metad/contracts'
import { NgmI18nPipe } from '@metad/ocap-angular/core'
import { includes, upperFirst } from 'lodash-es'

export function convertConfigurationSchema(schema: any, i18n?: any) {
Expand Down Expand Up @@ -79,3 +81,99 @@ function convertFormlyField(

return formField
}

/**
* Convert config schema to formly schema
* Use i18n pipe to transform label
*
* @param schema
* @param i18n
* @returns
*/
export function toFormlySchema(schema: any, i18n: NgmI18nPipe) {
const fields = []
schema.order
?.map((name) => ({ name, property: schema.properties[name] }))
.filter(({ property }) => !!property)
.forEach(({ name, property }) => {
fields.push(toFormlyField(schema, name, property, i18n))
})

Object.keys(schema.properties)
.filter((field) => !includes(schema.order, field))
.map((name) => ({ name, property: schema.properties[name] }))
.forEach(({ name, property }) => {
fields.push(toFormlyField(schema, name, property, i18n))
})
return fields
}

export function toFormlyField(
schema: any,
name: string,
property: {
type: string; extendedEnum: any[]; title: I18nObject; placeholder: I18nObject; default: string, depend: string; selectUrl: string; params: any; multi?: boolean },
i18n?: NgmI18nPipe
) {
const label = property.title || upperFirst(name)
let type = ''
let inputType = null
const props = {} as any
switch (property.type) {
case 'string':
if (property.extendedEnum) {
type = 'select'
} else {
type = 'input'
inputType = schema.secret?.includes(name) ? 'password' : 'text'
}
break
case 'textarea':
type = 'textarea'
break
case 'number':
type = 'input'
inputType = 'number'
break
case 'boolean':
type = 'checkbox'
break
case 'toggle':
type = 'toggle'
break
case 'remote-select':
type = 'remote-select'
props.url = property.selectUrl
props.params = property.params
props.multi = property.multi
break
case 'object':
return {
key: name,
fieldGroup: toFormlySchema(property, i18n)
}
}

const formField = {
key: name,
type,
props: {
label: i18n.transform(label),
type: inputType,
placeholder: i18n.transform(property.placeholder) || property.default,
floatLabel: 'always',
appearance: 'fill',
required: includes(schema.required, name),
options: property.extendedEnum?.map((item) => ({ value: item.value, label: item.name, icon: item.icon })),
autosize: type === 'textarea',
...props
},
expressions: {}
} as any

if (property.depend) {
formField.expressions.hide = `!model || !model.${property.depend}`
}

return formField
}
3 changes: 3 additions & 0 deletions apps/cloud/src/app/@core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export {

export const uid10 = new ShortUniqueId({ length: 10 })
export const uuid = new ShortUniqueId({ length: 10 })
export function letterStartSUID(start: string) {
return start + uuid()
}

export enum AbilityActions {
Create = 'Create',
Expand Down
1 change: 0 additions & 1 deletion apps/cloud/src/app/@shared/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './remote-select/select.component'
export * from './upsert/upsert.component'
export * from './select/select.component'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div
<div tabindex="0"
#menuTrigger
class="flex items-center px-3 py-2 rounded-lg bg-gray-100 cursor-pointer hover:bg-gray-200"
[cdkMenuTriggerFor]="menu"
Expand Down
118 changes: 59 additions & 59 deletions apps/cloud/src/app/@shared/copilot/prompt-editor/editor.component.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
<div class="rounded-xl bg-component-card-bg">
<div class="flex justify-between items-center h-11 pl-3 pr-6">
<div class="flex items-center space-x-1">
<div class="h2 text-sm">{{'PAC.Copilot.Prompt' | translate: {Default: 'Prompt'} }}</div>
<div class="p-[1px] w-4 h-4 flex items-center shrink-0 text-text-quaternary hover:text-text-tertiary"
[matTooltip]="tooltip()"
matTooltipPosition="above"
>
<i class="ri-question-line"></i>
</div>
</div>
<div class="flex items-center">
<div class="flex space-x-1 items-center !h-8 cursor-pointer group"
(click)="generate()">
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="w-3.5 h-3.5 text-indigo-600"
>
<path
opacity="0.5"
d="M10.5402 2.95679L10.5402 2.95685C10.4455 3.05146 10.3424 3.13459 10.2314 3.2072C10.3429 3.27923 10.4468 3.36165 10.5422 3.45535L10.5402 2.95679ZM10.5402 2.95679C10.6348 2.86217 10.718 2.75907 10.7906 2.64807C10.8626 2.75955 10.945 2.86339 11.0387 2.95881L11.0388 2.95888C11.1304 3.05224 11.2302 3.13482 11.3377 3.20717C11.2297 3.27895 11.1292 3.36081 11.0367 3.45327L11.0366 3.45333C10.9442 3.5458 10.8623 3.64635 10.7905 3.75431M10.5402 2.95679L10.7905 3.75431M10.7905 3.75431C10.7182 3.64686 10.6356 3.54707 10.5422 3.45538L10.7905 3.75431Z"
stroke="currentColor"
stroke-width="1.25"
></path>
<path
d="M6.99659 2.85105C6.96323 2.55641 6.71414 2.33368 6.41758 2.33337C6.12107 2.33307 5.87146 2.55529 5.83751 2.84987C5.67932 4.2213 5.27205 5.16213 4.6339 5.80028C3.99575 6.43841 3.05492 6.84569 1.68349 7.00389C1.3889 7.03784 1.16669 7.28745 1.16699 7.58396C1.1673 7.88052 1.39002 8.12961 1.68467 8.16297C3.03291 8.31569 3.99517 8.72292 4.64954 9.36546C5.30035 10.0045 5.71535 10.944 5.83593 12.3017C5.86271 12.6029 6.11523 12.8337 6.41763 12.8334C6.72009 12.833 6.97209 12.6016 6.99817 12.3003C7.11367 10.9656 7.52836 10.005 8.18344 9.34982C8.83858 8.69474 9.79922 8.28005 11.1339 8.16455C11.4352 8.13847 11.6666 7.88647 11.667 7.58402C11.6673 7.28162 11.4365 7.02909 11.1353 7.00232C9.77758 6.88174 8.83812 6.46676 8.19908 5.81592C7.55653 5.16155 7.14931 4.19929 6.99659 2.85105Z"
fill="currentColor"
></path>
</svg>
<span class="text-sm font-semibold text-indigo-500 group-hover:text-indigo-600">
{{'PAC.Copilot.Generate' | translate: {Default: 'Generate'} }}
</span>
</div>
<div class="rounded-xl bg-components-card-bg">
<div class="flex justify-between items-center h-11 pl-3 pr-6 bg-gray-50 rounded-t-xl">
<div class="flex items-center space-x-1">
<div class="h2 text-sm">{{'PAC.Copilot.Prompt' | translate: {Default: 'Prompt'} }}</div>
<div class="p-[1px] w-4 h-4 flex items-center shrink-0 text-text-quaternary hover:text-text-tertiary"
[matTooltip]="tooltip()"
matTooltipPosition="above"
>
<i class="ri-question-line"></i>
</div>
</div>

<div class="relative">
<div class="px-4 pt-2 bg-white rounded-t-xl text-sm text-gray-700 overflow-y-auto"
[style.height.px]="height"
<div class="flex items-center">
<div class="flex space-x-1 items-center !h-8 cursor-pointer group"
(click)="generate()">
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="w-3.5 h-3.5 text-indigo-600"
>
<div #editablePrompt
class="h-full outline-none leading-5 text-sm whitespace-pre-wrap break-words text-gray-700"
contenteditable="true"
role="textbox"
spellcheck="true"
(blur)="onPromptChange(editablePrompt)"
ngmHighlightVar
[regex]="regex"
[content]="prompt()"
customClasses="inline-block text-primary-500 bg-transparent"
>
</div>
</div>
<div class="pl-4 pb-2 flex bg-white rounded-b-xl">
<div class="h-[18px] leading-[18px] px-1 rounded-md bg-gray-100 text-xs text-gray-500">{{promptLength()}}</div>
<path
opacity="0.5"
d="M10.5402 2.95679L10.5402 2.95685C10.4455 3.05146 10.3424 3.13459 10.2314 3.2072C10.3429 3.27923 10.4468 3.36165 10.5422 3.45535L10.5402 2.95679ZM10.5402 2.95679C10.6348 2.86217 10.718 2.75907 10.7906 2.64807C10.8626 2.75955 10.945 2.86339 11.0387 2.95881L11.0388 2.95888C11.1304 3.05224 11.2302 3.13482 11.3377 3.20717C11.2297 3.27895 11.1292 3.36081 11.0367 3.45327L11.0366 3.45333C10.9442 3.5458 10.8623 3.64635 10.7905 3.75431M10.5402 2.95679L10.7905 3.75431M10.7905 3.75431C10.7182 3.64686 10.6356 3.54707 10.5422 3.45538L10.7905 3.75431Z"
stroke="currentColor"
stroke-width="1.25"
></path>
<path
d="M6.99659 2.85105C6.96323 2.55641 6.71414 2.33368 6.41758 2.33337C6.12107 2.33307 5.87146 2.55529 5.83751 2.84987C5.67932 4.2213 5.27205 5.16213 4.6339 5.80028C3.99575 6.43841 3.05492 6.84569 1.68349 7.00389C1.3889 7.03784 1.16669 7.28745 1.16699 7.58396C1.1673 7.88052 1.39002 8.12961 1.68467 8.16297C3.03291 8.31569 3.99517 8.72292 4.64954 9.36546C5.30035 10.0045 5.71535 10.944 5.83593 12.3017C5.86271 12.6029 6.11523 12.8337 6.41763 12.8334C6.72009 12.833 6.97209 12.6016 6.99817 12.3003C7.11367 10.9656 7.52836 10.005 8.18344 9.34982C8.83858 8.69474 9.79922 8.28005 11.1339 8.16455C11.4352 8.13847 11.6666 7.88647 11.667 7.58402C11.6673 7.28162 11.4365 7.02909 11.1353 7.00232C9.77758 6.88174 8.83812 6.46676 8.19908 5.81592C7.55653 5.16155 7.14931 4.19929 6.99659 2.85105Z"
fill="currentColor"
></path>
</svg>
<span class="text-sm font-semibold text-indigo-500 group-hover:text-indigo-600">
{{'PAC.Copilot.Generate' | translate: {Default: 'Generate'} }}
</span>
</div>
<div class="absolute bottom-0 left-0 w-full flex justify-center h-2 cursor-row-resize"
(mousedown)="onMouseDown($event)">
<div class="w-5 h-[3px] rounded-sm bg-gray-300"></div>
</div>
</div>

<div class="relative">
<div class="px-4 pt-2 bg-white rounded-t-xl text-sm text-gray-700 overflow-y-auto"
[style.height.px]="height"
>
<div #editablePrompt
class="h-full outline-none leading-5 text-sm whitespace-pre-wrap break-words text-gray-700"
contenteditable="true"
role="textbox"
spellcheck="true"
(blur)="onPromptChange(editablePrompt)"
ngmHighlightVar
[regex]="regex"
[content]="prompt()"
customClasses="inline-block text-primary-500 bg-transparent"
>
</div>
</div>
<div class="pl-4 pb-2 flex bg-white rounded-b-xl">
<div class="h-[18px] leading-[18px] px-1 rounded-md bg-gray-100 text-xs text-gray-500">{{promptLength()}}</div>
</div>
<div class="absolute bottom-0 left-0 w-full flex justify-center h-2 cursor-row-resize"
(mousedown)="onMouseDown($event)">
<div class="w-5 h-[3px] rounded-sm bg-gray-300"></div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class CopilotPromptEditorComponent {
}

onPromptChange(editor: HTMLDivElement) {
// console.log(editor.children)
// console.log(editor.innerHTML)
// console.log(formatInnerHTML(editor.innerHTML))
this.prompt.set(formatInnerHTML(editor.innerHTML))
Expand Down
61 changes: 39 additions & 22 deletions apps/cloud/src/app/@shared/xpert/execution/execution.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,53 @@

<div class="relative">
<div class="h-6 leading-6 text-gray-500 text-sm font-medium">{{ 'PAC.Xpert.Metadata' | translate: {Default: 'Metadata'} }}</div>
<div class="py-1">
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.Status' | translate: {Default: 'Status'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span class="uppercase">{{execution().status}}</span>
</div>
<div class="py-1">
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.Status' | translate: {Default: 'Status'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span class="uppercase">{{execution().status}}</span>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.Executor' | translate: {Default: 'Executor'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().createdBy | user }}</span>
</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.Executor' | translate: {Default: 'Executor'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().createdBy | user }}</span>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.StartTime' | translate: {Default: 'Start Time'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().createdAt | date}}</span>
</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.StartTime' | translate: {Default: 'Start Time'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().createdAt | date}}</span>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.ElapsedTime' | translate: {Default: 'Elapsed Time'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().elapsedTime / 1000 | number: '0.0-3'}}s</span>
</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.ElapsedTime' | translate: {Default: 'Elapsed Time'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().elapsedTime / 1000 | number: '0.0-3'}}s</span>
</div>
<div class="flex"><div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.TotalTokens' | translate: {Default: 'Total Tokens'} }}</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">{{ 'PAC.Xpert.TotalTokens' | translate: {Default: 'Total Tokens'} }}</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().totalTokens }} {{ 'PAC.Xpert.Tokens' | translate: {Default: 'Tokens'} }}</span>
</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">
{{ 'PAC.Xpert.AIProvider' | translate: {Default: 'AI Provider'} }}
</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().metadata?.provider || '' }}</span>
</div>
</div>
<div class="flex">
<div class="shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-sm leading-[18px] truncate">
{{ 'PAC.Xpert.AIModel' | translate: {Default: 'AI Model'} }}
</div>
<div class="grow px-2 py-[5px] text-gray-900 text-sm leading-[18px]">
<span>{{ execution().metadata?.model || '' }}</span>
</div>
</div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:host {
@apply flex flex-col justify-start items-stretch gap-4 text-left;
@apply flex flex-col justify-start items-stretch gap-4 text-left pb-4;
}
Loading

0 comments on commit b3fc13d

Please sign in to comment.