feat: add agent prompt
This commit is contained in:
parent
b56fea49ca
commit
90e3195e29
@ -16,6 +16,7 @@ interface Props extends AgentSettingPopupShowParams {
|
|||||||
const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
|
const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
|
||||||
const [name, setName] = useState(agent.name)
|
const [name, setName] = useState(agent.name)
|
||||||
const [description, setDescription] = useState(agent.description)
|
const [description, setDescription] = useState(agent.description)
|
||||||
|
const [prompt, setPrompt] = useState(agent.prompt)
|
||||||
const [open, setOpen] = useState(true)
|
const [open, setOpen] = useState(true)
|
||||||
|
|
||||||
const onOk = () => {
|
const onOk = () => {
|
||||||
@ -27,12 +28,12 @@ const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
resolve({ ...agent, name, description })
|
resolve({ ...agent, name, description, prompt })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal title={agent.name} open={open} onOk={onOk} onCancel={handleCancel} afterClose={onClose}>
|
<Modal title={agent.name} open={open} onOk={onOk} onCancel={handleCancel} afterClose={onClose}>
|
||||||
<Box mb={8}>Agent name</Box>
|
<Box mb={8}>Name</Box>
|
||||||
<Input placeholder="Agent Name" value={name} onChange={(e) => setName(e.target.value)} autoFocus />
|
<Input placeholder="Agent Name" value={name} onChange={(e) => setName(e.target.value)} autoFocus />
|
||||||
<Box mt={8} mb={8}>
|
<Box mt={8} mb={8}>
|
||||||
Description
|
Description
|
||||||
@ -44,6 +45,16 @@ const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
|
|||||||
onChange={(e) => setDescription(e.target.value)}
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
|
<Box mt={8} mb={8}>
|
||||||
|
Prompt
|
||||||
|
</Box>
|
||||||
|
<TextArea
|
||||||
|
rows={4}
|
||||||
|
placeholder="Agent Prompt"
|
||||||
|
value={prompt}
|
||||||
|
onChange={(e) => setPrompt(e.target.value)}
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export function getDefaultAgent(): Agent {
|
|||||||
id: 'default',
|
id: 'default',
|
||||||
name: 'Default Agent',
|
name: 'Default Agent',
|
||||||
description: "Hello, I'm Default Agent.",
|
description: "Hello, I'm Default Agent.",
|
||||||
|
prompt: '',
|
||||||
topics: [
|
topics: [
|
||||||
{
|
{
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
|
|||||||
@ -14,7 +14,10 @@ interface FetchChatCompletionParams {
|
|||||||
export async function fetchChatCompletion({ message, agent, topic, onResponse }: FetchChatCompletionParams) {
|
export async function fetchChatCompletion({ message, agent, topic, onResponse }: FetchChatCompletionParams) {
|
||||||
const stream = await openaiProvider.chat.completions.create({
|
const stream = await openaiProvider.chat.completions.create({
|
||||||
model: 'Qwen/Qwen2-7B-Instruct',
|
model: 'Qwen/Qwen2-7B-Instruct',
|
||||||
messages: [{ role: 'user', content: message.content }],
|
messages: [
|
||||||
|
{ role: 'system', content: agent.prompt },
|
||||||
|
{ role: 'user', content: message.content }
|
||||||
|
],
|
||||||
stream: true
|
stream: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ export type Agent = {
|
|||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
|
prompt: string
|
||||||
topics: Topic[]
|
topics: Topic[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user