mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
453097ff18
Flatten langgraph-python, langgraph-js, and mcp-apps starters so npm install && npm run dev works out of the box. Replace Turborepo with concurrently, move apps/* to root, update Dockerfiles, READMEs, and entrypoints. Also remove stray pnpm-lock.yaml from a2a-a2ui and ms-agent-framework-dotnet starters.
38 lines
859 B
TypeScript
38 lines
859 B
TypeScript
import { useAgent } from "@copilotkit/react-core/v2";
|
|
import { useCallback, useState } from "react";
|
|
|
|
export const HeadlessChat = () => {
|
|
const { agent } = useAgent();
|
|
const [message, setMessage] = useState("");
|
|
|
|
const sendMessage = useCallback(
|
|
(message: string) => {
|
|
agent.addMessage({
|
|
role: "user",
|
|
id: crypto.randomUUID(),
|
|
content: message,
|
|
});
|
|
agent.runAgent();
|
|
setMessage("");
|
|
},
|
|
[agent],
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<h1>Chat</h1>
|
|
{agent.messages.map((message) => (
|
|
<div key={message.id}>
|
|
<p>{JSON.stringify(message.content)}</p>
|
|
</div>
|
|
))}
|
|
<input
|
|
type="text"
|
|
value={message}
|
|
onChange={(e) => setMessage(e.target.value)}
|
|
/>
|
|
<button onClick={() => sendMessage(message)}>Send</button>
|
|
</div>
|
|
);
|
|
};
|