Skip to content

Commit

Permalink
Merge pull request #14 from xpert-ai/develop
Browse files Browse the repository at this point in the history
V3.0.5
  • Loading branch information
tiven-w authored Dec 23, 2024
2 parents 9c7695b + 6c0cc56 commit 6495031
Show file tree
Hide file tree
Showing 249 changed files with 6,815 additions and 1,341 deletions.
2 changes: 1 addition & 1 deletion .deploy/api/package-prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/langgraph": "0.2.17",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
"@nestjs/common": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion .deploy/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/langgraph": "0.2.17",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
"@nestjs/common": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion .deploy/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@foblex/utils": "^1.1.0",
"@langchain/community": "0.3.11",
"@langchain/core": "0.3.13",
"@langchain/langgraph": "0.2.17",
"@langchain/langgraph": "0.2.33",
"@langchain/ollama": "0.1.0",
"@langchain/openai": "0.3.11",
"@microsoft/fetch-event-source": "^2.0.1",
Expand Down
4 changes: 4 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,7 @@ SEARCHAPI_API_KEY=
EXASEARCH_API_KEY=

# Features Toggles

# Tests
OLLAMA_URL=http://localhost:11434
OLLAMA_EMBEDDINGS_MODEL=qwen2.5
7 changes: 0 additions & 7 deletions apps/cloud/src/app/@core/animations/if.animations.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/cloud/src/app/@core/animations/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './list.animations'
export * from './route.animations'
export * from './animations.service'
export * from './if.animations'
export { IfAnimation } from '@metad/core'
1 change: 1 addition & 0 deletions apps/cloud/src/app/@core/constants/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const API_COPILOT_KNOWLEDGE = API_PREFIX + '/copilot-knowledge'
export const API_COPILOT_ROLE = API_PREFIX + '/copilot-role'
export const API_COPILOT_MODEL = API_PREFIX + '/copilot-model'
export const API_COPILOT_PROVIDER = API_PREFIX + '/copilot-provider'
export const API_COPILOT_STORE = API_PREFIX + '/copilot-store'
export const API_XPERT_ROLE = API_PREFIX + '/xpert'
export const API_XPERT_TOOLSET = API_PREFIX + '/xpert-toolset'
export const API_XPERT_TOOL = API_PREFIX + '/xpert-tool'
Expand Down
8 changes: 8 additions & 0 deletions apps/cloud/src/app/@core/providers/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ export function injectLanguage() {
)
)
}

export function injectTranslate(key?: string) {
const translate = inject(TranslateService)

return toSignal(
translate.stream(key)
)
}
10 changes: 10 additions & 0 deletions apps/cloud/src/app/@core/services/chat-message-feedback.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core'
import { API_PREFIX, OrganizationBaseCrudService } from '@metad/cloud/state'
import { IChatMessageFeedback } from '../types'

@Injectable({ providedIn: 'root' })
export class ChatMessageFeedbackService extends OrganizationBaseCrudService<IChatMessageFeedback> {
constructor() {
super(API_PREFIX + '/chat-message-feedback')
}
}
10 changes: 10 additions & 0 deletions apps/cloud/src/app/@core/services/chat-message.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@angular/core'
import { API_PREFIX, OrganizationBaseCrudService } from '@metad/cloud/state'
import { IChatMessage } from '../types'

@Injectable({ providedIn: 'root' })
export class ChatMessageService extends OrganizationBaseCrudService<IChatMessage> {
constructor() {
super(API_PREFIX + '/chat-message')
}
}
15 changes: 15 additions & 0 deletions apps/cloud/src/app/@core/services/copilot-store.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { inject, Injectable } from '@angular/core'
import { OrganizationBaseCrudService } from '@metad/cloud/state'
import { NGXLogger } from 'ngx-logger'
import { API_COPILOT_STORE } from '../constants/app.constants'
import { ICopilotStore } from '../types'

@Injectable({ providedIn: 'root' })
export class CopilotStoreService extends OrganizationBaseCrudService<ICopilotStore> {
readonly #logger = inject(NGXLogger)

constructor() {
super(API_COPILOT_STORE)
}

}
5 changes: 4 additions & 1 deletion apps/cloud/src/app/@core/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from './configuration-schema.service'
export * from './copilot-example.service'
export * from './copilot-model.service'
export * from './copilot-usage.service'
export * from './copilot-store.service'
export * from './custom-smtp.service'
export * from './email-template.service'
export * from './employees.service'
Expand Down Expand Up @@ -53,4 +54,6 @@ export * from './xpert-agent.service'
export * from './xpert-agent-execution.service'
export * from './copilot-provider.service'
export * from './copilot-server.service'
export * from './api-key.service'
export * from './api-key.service'
export * from './chat-message.service'
export * from './chat-message-feedback.service'
1 change: 0 additions & 1 deletion apps/cloud/src/app/@core/services/xpert-agent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class XpertAgentService extends XpertWorkspaceBaseCrudService<IXpertAgent
chatAgent(data: TChatAgentParams) {
return this.fetchEventSource(this.baseUrl + this.apiBaseUrl + `/chat`, JSON.stringify({
...data,
xpert: pick(data.xpert, 'id', 'name', 'copilotId', 'copilotModel')
}))
}
}
29 changes: 17 additions & 12 deletions apps/cloud/src/app/@core/services/xpert.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { toParams } from '@metad/ocap-angular/core'
import { NGXLogger } from 'ngx-logger'
import { BehaviorSubject, tap } from 'rxjs'
import { API_XPERT_ROLE } from '../constants/app.constants'
import { IUser, IXpert, IXpertAgentExecution, OrderTypeEnum, TChatRequest, TXpertTeamDraft, XpertTypeEnum } from '../types'
import { ICopilotStore, IUser, IXpert, IXpertAgentExecution, OrderTypeEnum, TChatRequest, TDeleteResult, TXpertTeamDraft, XpertTypeEnum } from '../types'
import { XpertWorkspaceBaseCrudService } from './xpert-workspace.service'
import { injectApiBaseUrl } from '../providers'
import { injectFetchEventSource } from './fetch-event-source'
import { SearchItem } from '@langchain/langgraph-checkpoint'

@Injectable({ providedIn: 'root' })
export class XpertService extends XpertWorkspaceBaseCrudService<IXpert> {
Expand Down Expand Up @@ -83,10 +84,6 @@ export class XpertService extends XpertWorkspaceBaseCrudService<IXpert> {
return this.httpClient.delete<void>(this.apiBaseUrl + `/${id}/managers/${userId}`)
}

getMyAll(params: PaginationParams<IXpert>) {
return this.httpClient.get<{items: IXpert[]}>(this.apiBaseUrl + `/my`, { params: toHttpParams(params) })
}

getMyCopilots(relations?: string[]) {
return this.getMyAll({ relations, where: {latest: true, type: XpertTypeEnum.Copilot }, order: {updatedAt: OrderTypeEnum.DESC} })
}
Expand All @@ -98,15 +95,23 @@ export class XpertService extends XpertWorkspaceBaseCrudService<IXpert> {
importDSL(dslObject: Record<string, any>) {
return this.httpClient.post(this.apiBaseUrl + `/import`, dslObject)
}

getAllMemory(id: string, types: string[]) {
return this.httpClient.get<{items: ICopilotStore[]}>(this.apiBaseUrl + `/${id}/memory`, {
params: {
types: types?.join(':')
}
})
}
searchMemory(id: string, body: {text: string; isDraft: boolean;}) {
return this.httpClient.post<SearchItem[]>(this.apiBaseUrl + `/${id}/memory/search`, body)
}

clearMemory(id: string) {
return this.httpClient.delete<TDeleteResult>(this.apiBaseUrl + `/${id}/memory`,)
}
}

export function injectXpertService() {
return inject(XpertService)
}

export function convertToUrlPath(title: string) {
return title
?.toLowerCase() // 转换为小写
.replace(/\s+/g, '-') // 替换空格为 -
.replace(/[^a-z0-9-]/g, '') // 移除非字母数字字符
}
2 changes: 0 additions & 2 deletions apps/cloud/src/app/@core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export {
convertStoryWidgetResult
} from '@metad/cloud/state'

export { IXpert as IXpertRole } from '@metad/contracts'

export const uid10 = new ShortUniqueId({ length: 10 })
export const uuid = new ShortUniqueId({ length: 10 })

Expand Down
1 change: 0 additions & 1 deletion apps/cloud/src/app/@shared/copilot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './knowledgebase-list/list.component'
export * from './toolset-list/list.component'
export * from './loading/loading.component'
export * from './toolset-card/toolset.component'
export * from './xpert-role-list/list.component'
export * from './copilot-model-select/select.component'
export * from './stored-message/message.component'
export * from './knowledgebase-card/knowledgebase.component'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@
<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 shrink-0 text-text-quaternary hover:text-text-tertiary"
<div class="p-[1px] w-4 h-4 flex items-center shrink-0 text-text-quaternary hover:text-text-tertiary"
[matTooltip]="tooltip()"
matTooltipPosition="above"
>
<svg
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="currentColor"
class="w-full h-full"
>
<path
d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM13 13.3551V14H11V12.5C11 11.9477 11.4477 11.5 12 11.5C12.8284 11.5 13.5 10.8284 13.5 10C13.5 9.17157 12.8284 8.5 12 8.5C11.2723 8.5 10.6656 9.01823 10.5288 9.70577L8.56731 9.31346C8.88637 7.70919 10.302 6.5 12 6.5C13.933 6.5 15.5 8.067 15.5 10C15.5 11.5855 14.4457 12.9248 13 13.3551Z"
></path>
</svg>
<i class="ri-question-line"></i>
</div>
</div>
<div class="flex items-center">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CdkMenuModule } from '@angular/cdk/menu'
import { CommonModule } from '@angular/common'
import { ChangeDetectionStrategy, Component, computed, ElementRef, HostListener, inject, input, model, viewChild } from '@angular/core'
import { ChangeDetectionStrategy, Component, computed, effect, ElementRef, HostListener, inject, input, model, numberAttribute, viewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { MatDialog } from '@angular/material/dialog'
import { MatTooltipModule } from '@angular/material/tooltip'
Expand All @@ -22,18 +22,28 @@ export class CopilotPromptEditorComponent {

readonly regex = `{{(.*?)}}`

readonly initHeight = input<number>(210)
readonly initHeight = input<number, number | string>(210, {
transform: numberAttribute
})
readonly tooltip = input<string>()

readonly prompt = model<string>()
readonly promptLength = computed(() => this.prompt()?.length)


height = this.initHeight(); // 初始高度
height = this.initHeight();
private isResizing = false;
private startY = 0;
private startHeight = 0;

constructor() {
effect(() => {
if (this.initHeight()) {
this.height = this.initHeight()
}
})
}

generate() {
this.#dialog.open(CopilotPromptGeneratorComponent, {
panelClass: 'large'
Expand Down Expand Up @@ -83,9 +93,11 @@ function formatInnerHTML(htmlContent: string) {
.replace(/<\/?p[^>]*>/gi, '') // 移除 <p> 标签
.replace(/<\/?span[^>]*>/gi, '') // 移除 <span> 标签
.replace(/<mark[^>]*>(.*?)<\/mark>/gi, '$1') // 保留 <mark> 内的内容
.replace(/<div[^>]*>/gi, '') // 移除 <div> 标签及带 class 的 <div> 标签
.replace(/<\/div>/gi, '\n') // 将 </div> 替换成换行符

// Step 2: 替换 HTML 转义字符
formattedText = formattedText.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&')
// // Step 2: 替换 HTML 转义字符
// formattedText = formattedText.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&')

// Step 3: 返回转换后的文本内容
return formattedText
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, forwardRef, inject, Input, ViewChild } from '@angular/core'
import { Component, computed, ElementRef, forwardRef, inject, Input, ViewChild } from '@angular/core'
import { ControlValueAccessor, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
import { matchValidator } from '@metad/cloud/auth'
import { AuthService } from '@metad/cloud/state'
Expand All @@ -7,7 +7,8 @@ import { FORMLY_ROW, FORMLY_W_1_2 } from '@metad/story/designer'
import { FormlyFieldConfig } from '@ngx-formly/core'
import { firstValueFrom, map } from 'rxjs'
import { LANGUAGES, RoleService, Store } from '../../../../@core'
import { TranslationBaseComponent } from '../../../language/translation-base.component'
import { TranslationBaseComponent } from '../../../language/'
import { DisplayBehaviour } from '@metad/ocap-core'

@Component({
selector: 'pac-user-basic-info-form',
Expand All @@ -22,6 +23,8 @@ import { TranslationBaseComponent } from '../../../language/translation-base.com
]
})
export class BasicInfoFormComponent extends TranslationBaseComponent implements ControlValueAccessor {
eDisplayBehaviour = DisplayBehaviour

readonly #store = inject(Store)
readonly #roleService = inject(RoleService)
readonly #authService = inject(AuthService)
Expand Down Expand Up @@ -53,6 +56,10 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
model = {} as any
fields: FormlyFieldConfig[] = []

get invalid() {
return this.form.invalid
}

onChange: (value: any) => any

writeValue(obj: any): void {
Expand Down Expand Up @@ -157,6 +164,7 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
options: this.roles$,
appearance: 'fill',
valueKey: 'key',
displayBehaviour: DisplayBehaviour.descriptionOnly
}
},
{
Expand Down
Loading

0 comments on commit 6495031

Please sign in to comment.