@fabric-harness/react
v0.9.0
Published
React provider and hooks for TechFabric Harness agents and finite jobs.
Readme
@fabric-harness/react
React provider and hooks for TechFabric Harness agents and finite jobs.
import { FabricProvider, useFabricAgent } from '@fabric-harness/react';
function Chat() {
const chat = useFabricAgent({ agent: 'support', id: 'customer-42' });
return (
<>
{chat.messages.map((message) => (
<p key={message.id}>
{message.parts
.filter((part) => part.type === 'text')
.map((part) => part.text)
.join('')}
</p>
))}
<button onClick={() => chat.send('Hello')}>Send</button>
<button onClick={() => chat.refresh()}>Refresh</button>
</>
);
}
export function App() {
return (
<FabricProvider options={{ baseUrl: 'http://localhost:4317' }}>
<Chat />
</FabricProvider>
);
}Apache-2.0
