mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
feat(ui/agents): add NewAgentDialog
antd Modal + Form that posts a new cloud-agent definition. Definition- only — no VM is provisioned at creation time.
This commit is contained in:
parent
a9419c514f
commit
25cbe4c210
1 changed files with 79 additions and 0 deletions
|
|
@ -0,0 +1,79 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Modal, Form, Input, message } from "antd";
|
||||
import { createCloudAgent } from "@/lib/cloud-agents-client";
|
||||
|
||||
interface NewAgentDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onCreated: () => void;
|
||||
accessToken: string | null;
|
||||
}
|
||||
|
||||
export default function NewAgentDialog({
|
||||
open,
|
||||
onClose,
|
||||
onCreated,
|
||||
accessToken,
|
||||
}: NewAgentDialogProps) {
|
||||
const [form] = Form.useForm<{ name: string; model: string; system_prompt?: string }>();
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
setSubmitting(true);
|
||||
await createCloudAgent(accessToken, values);
|
||||
message.success(`Agent "${values.name}" created`);
|
||||
form.resetFields();
|
||||
onCreated();
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
message.error(e.message);
|
||||
}
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="New cloud agent"
|
||||
open={open}
|
||||
onOk={handleOk}
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
onClose();
|
||||
}}
|
||||
okText="Create"
|
||||
confirmLoading={submitting}
|
||||
destroyOnClose
|
||||
data-testid="new-agent-dialog"
|
||||
>
|
||||
<Form form={form} layout="vertical" preserve={false}>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="Name"
|
||||
rules={[{ required: true, message: "Name is required" }]}
|
||||
>
|
||||
<Input placeholder="my-coding-agent" data-testid="new-agent-name" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="model"
|
||||
label="Model"
|
||||
rules={[{ required: true, message: "Model is required" }]}
|
||||
>
|
||||
<Input placeholder="claude-3-5-sonnet-20241022" data-testid="new-agent-model" />
|
||||
</Form.Item>
|
||||
<Form.Item name="system_prompt" label="System prompt (optional)">
|
||||
<Input.TextArea
|
||||
rows={3}
|
||||
placeholder="You are a helpful coding agent."
|
||||
data-testid="new-agent-prompt"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue