-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
352 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { SaveOutlined } from '@ant-design/icons'; | ||
import { FlowWithPanel } from '@difizen/magent-flow'; | ||
import { | ||
BaseView, | ||
ViewInstance, | ||
inject, | ||
prop, | ||
useInject, | ||
view, | ||
ViewOption, | ||
transient, | ||
} from '@difizen/mana-app'; | ||
import { Flex } from 'antd'; | ||
import { forwardRef } from 'react'; | ||
|
||
import { AgentManager } from '../../modules/agent/index.js'; | ||
import type { AgentModel } from '../../modules/agent/index.js'; | ||
|
||
import './index.less'; | ||
|
||
const viewId = 'magent-agent-flow'; | ||
|
||
const AgentFlowComponent = forwardRef<HTMLDivElement>( | ||
function AgentConfigViewComponent(props, ref) { | ||
const instance = useInject<AgentFlowView>(ViewInstance); | ||
|
||
return ( | ||
<div ref={ref} className={viewId}> | ||
<FlowWithPanel /> | ||
</div> | ||
); | ||
}, | ||
); | ||
|
||
export interface AgentConfigViewOption { | ||
agentId: string; | ||
} | ||
@transient() | ||
@view(viewId) | ||
export class AgentFlowView extends BaseView { | ||
agentId: string; | ||
override view = AgentFlowComponent; | ||
|
||
@prop() agent: AgentModel; | ||
protected agentManager: AgentManager; | ||
constructor( | ||
@inject(ViewOption) option: AgentConfigViewOption, | ||
@inject(AgentManager) agentManager: AgentManager, | ||
) { | ||
super(); | ||
this.agentId = option.agentId; | ||
this.agentManager = agentManager; | ||
this.initAgent(option.agentId); | ||
} | ||
|
||
get modelOptions() { | ||
// TODO 大模型optios列表和对应存取值要怎么取? | ||
return ( | ||
this.agent?.llm?.model_name?.map((item) => { | ||
return { | ||
label: item, | ||
value: item, | ||
}; | ||
}) || [] | ||
); | ||
} | ||
|
||
protected initAgent = (agentId = this.agentId) => { | ||
if (agentId) { | ||
const agent = this.agentManager.getOrCreateAgent({ id: agentId }); | ||
agent.fetchInfo(); | ||
this.agent = agent; | ||
return agent; | ||
} | ||
return undefined; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { ViewRender } from '@difizen/mana-app'; | ||
import { ViewInstance, singleton, useInject, view } from '@difizen/mana-app'; | ||
import { BoxPanel } from '@difizen/mana-react'; | ||
import { forwardRef, useEffect } from 'react'; | ||
import { useMatch } from 'react-router-dom'; | ||
|
||
import type { AgentConfigManager } from '../../modules/agent/agent-config-manager.js'; | ||
import { AgentView } from '../agent-dev/chat-view.js'; | ||
|
||
import { AgentFlowView } from './agent-flow-view.js'; | ||
|
||
import './index.less'; | ||
|
||
const viewId = 'magent-agent-flow-dev'; | ||
export const slot = `${viewId}-slot`; | ||
|
||
const AgentFlowDevComponent = forwardRef<HTMLDivElement>( | ||
function AgentsViewComponent(props, ref) { | ||
const instance = useInject<AgentFlowDevView>(ViewInstance); | ||
const match = useMatch('/agent/:agentId/flow'); | ||
const agentId = match?.params?.agentId; | ||
instance.agentId = agentId; | ||
|
||
useEffect(() => { | ||
instance.openChat(instance.sessions?.active); | ||
}, [instance, instance.sessions?.active]); | ||
|
||
return ( | ||
<div ref={ref} className={`${viewId}-layout`}> | ||
<BoxPanel className={`${viewId}-layout-container`} direction="left-to-right"> | ||
{instance.agentFlow && <ViewRender view={instance.agentFlow} />} | ||
{/* <BoxPanel.Pane className={`${viewId}-layout-config`}> | ||
{instance.agentFlow && <ViewRender view={instance.agentFlow} />} | ||
</BoxPanel.Pane> | ||
<BoxPanel.Pane className={`${viewId}-layout-chat-dev`} flex={1}> | ||
<div className={`${viewId}-layout-chat-dev-header`}> | ||
<h3>预览</h3> | ||
</div> | ||
<div className={`${viewId}-layout-chat-dev-content`}> | ||
{instance.chat && <ViewRender view={instance.chat} />} | ||
</div> | ||
</BoxPanel.Pane> */} | ||
</BoxPanel> | ||
</div> | ||
); | ||
}, | ||
); | ||
|
||
@singleton() | ||
@view(viewId) | ||
export class AgentFlowDevView extends AgentView { | ||
protected agentConfigManager: AgentConfigManager; | ||
|
||
agentFlow?: AgentFlowView; | ||
|
||
override view = AgentFlowDevComponent; | ||
|
||
protected override initialize() { | ||
super.initialize(); | ||
this.initAgentFlowView(); | ||
} | ||
|
||
protected initAgentFlowView = async () => { | ||
if (!this.agentId) { | ||
return; | ||
} | ||
const agentFlow = await this.viewManager.getOrCreateView(AgentFlowView, { | ||
agentId: this.agentId, | ||
}); | ||
this.agentFlow = agentFlow; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
.magent-agent-chat-layout { | ||
height: 100%; | ||
|
||
&-container { | ||
gap: 16px; | ||
box-sizing: border-box; | ||
padding: 12px 24px; | ||
} | ||
|
||
&-history { | ||
width: 260px; | ||
} | ||
|
||
&-chat { | ||
max-width: calc(100% - 276px); | ||
} | ||
} | ||
|
||
.magent-agent-flow-dev-layout { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.magent-agent-dev-layout { | ||
height: 100%; | ||
|
||
&-container { | ||
gap: 16px; | ||
box-sizing: border-box; | ||
padding: 12px 24px; | ||
} | ||
|
||
&-config { | ||
width: 55%; | ||
} | ||
|
||
&-chat-dev { | ||
height: 100%; | ||
min-width: 520px; | ||
width: 520px; | ||
background-color: var(--mana-color-bg-container); | ||
border-radius: 8px; | ||
|
||
&-header { | ||
padding: 0 24px; | ||
height: 64px; | ||
border-bottom: 1px solid var(--mana-color-border); | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
h3 { | ||
margin: 0; | ||
} | ||
} | ||
|
||
&-content { | ||
height: calc(100% - 64px); | ||
} | ||
} | ||
} | ||
|
||
.magent-debug { | ||
width: 622px; | ||
} | ||
|
||
.magent-debug-header { | ||
background-color: #f7f7fa; | ||
border-bottom: 1px solid rgba(29, 28, 35, 8%); | ||
padding: 16px 24px; | ||
} | ||
|
||
.magent-select-container { | ||
padding: 24px 24px 4px; | ||
width: 100%; | ||
|
||
:global { | ||
background-color: rgba(139, 139, 149, 15%); | ||
color: rgba(75, 74, 88, 100%); | ||
} | ||
} | ||
|
||
.magent-summary-container { | ||
padding: 16px 24px 24px; | ||
position: relative; | ||
width: 100%; | ||
} | ||
|
||
.magent-summary-title-container { | ||
margin-bottom: 16px; | ||
} | ||
|
||
.magent-summary-title-data { | ||
color: #1d1c23; | ||
font-size: 14px; | ||
font-weight: 600; | ||
margin-right: 8px; | ||
} | ||
|
||
.magent-des-item { | ||
display: flex; | ||
font-size: 13px; | ||
line-height: 22px; | ||
text-align: left; | ||
} | ||
|
||
.magent-des-key { | ||
color: rgba(29, 28, 35, 35%); | ||
margin-right: 4px; | ||
} | ||
|
||
.magent-des-value { | ||
color: rgba(29, 28, 35, 80%); | ||
} | ||
|
||
.magent-des-icon { | ||
margin-left: 6px; | ||
cursor: pointer; | ||
} | ||
|
||
.magent-agent-flow { | ||
height: 100%; | ||
width: 100%; | ||
overflow-y: auto; | ||
display: flex; | ||
justify-items: center; | ||
flex-direction: column; | ||
background-color: var(--mana-color-bg-container); | ||
box-sizing: border-box; | ||
border-radius: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './module.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createSlotPreference, ManaModule } from '@difizen/mana-app'; | ||
|
||
import { AgentConfigViewModule } from '../agent-config/module.js'; | ||
|
||
import { AgentFlowView } from './agent-flow-view.js'; | ||
import { AgentFlowDevView, slot } from './flow-dev-view.js'; | ||
|
||
export const AgentFlowModule = ManaModule.create() | ||
.register( | ||
AgentFlowView, | ||
AgentFlowDevView, | ||
createSlotPreference({ | ||
slot: slot, | ||
view: AgentFlowDevView, | ||
}), | ||
) | ||
.dependOn(AgentConfigViewModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const AgentLayoutSlots = { | ||
history: 'magent-agent-chat-history', | ||
config: 'magent-agent-dev-config', | ||
chat: 'magent-agent-chat', | ||
}; |
Oops, something went wrong.