feat: add agent prompt

This commit is contained in:
kangfenmao 2024-07-02 16:35:07 +08:00
parent b56fea49ca
commit 90e3195e29
4 changed files with 19 additions and 3 deletions

View File

@ -16,6 +16,7 @@ interface Props extends AgentSettingPopupShowParams {
const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
const [name, setName] = useState(agent.name)
const [description, setDescription] = useState(agent.description)
const [prompt, setPrompt] = useState(agent.prompt)
const [open, setOpen] = useState(true)
const onOk = () => {
@ -27,12 +28,12 @@ const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
}
const onClose = () => {
resolve({ ...agent, name, description })
resolve({ ...agent, name, description, prompt })
}
return (
<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 />
<Box mt={8} mb={8}>
Description
@ -44,6 +45,16 @@ const AgentSettingPopupContainer: React.FC<Props> = ({ agent, resolve }) => {
onChange={(e) => setDescription(e.target.value)}
autoFocus
/>
<Box mt={8} mb={8}>
Prompt
</Box>
<TextArea
rows={4}
placeholder="Agent Prompt"
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
autoFocus
/>
</Modal>
)
}

View File

@ -7,6 +7,7 @@ export function getDefaultAgent(): Agent {
id: 'default',
name: 'Default Agent',
description: "Hello, I'm Default Agent.",
prompt: '',
topics: [
{
id: uuid(),

View File

@ -14,7 +14,10 @@ interface FetchChatCompletionParams {
export async function fetchChatCompletion({ message, agent, topic, onResponse }: FetchChatCompletionParams) {
const stream = await openaiProvider.chat.completions.create({
model: 'Qwen/Qwen2-7B-Instruct',
messages: [{ role: 'user', content: message.content }],
messages: [
{ role: 'system', content: agent.prompt },
{ role: 'user', content: message.content }
],
stream: true
})

View File

@ -2,6 +2,7 @@ export type Agent = {
id: string
name: string
description: string
prompt: string
topics: Topic[]
}