Project Knowledge

The files and custom instructions an assistant reads in every chat of a project, with Add and a drop zone.

Project knowledge

  • Customer feedback transcript.pdf402 KB · Added this minute
  • Survey results.docx86 KB · Added 18 hours ago

2 files · 488 KB

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/project-knowledge

Usage

import { ProjectKnowledge } from "./ui/uicontext/components/chat/ProjectKnowledge.ts"import type { KnowledgeFile } from "./ui/uicontext/components/domain/Chat.ts"
const Message = UiSchema.TaggedEnum({	AddedKnowledge: { files: Schema.Array(Schema.instanceOf(File)) },	RemovedKnowledge: { id: Schema.String },	SavedInstructions: { instructions: Schema.String },})// the project owns its files and instructions: upload what's added, store what's savedexport const Knowledge = (h: Html.H<typeof Message.Type>, files: ReadonlyArray<KnowledgeFile>, instructions: string, now: string) =>	ProjectKnowledge(h, {		props: { files, instructions, now },		onEmit: {			RequestedAdd: ({ files: added }) => Message.AddedKnowledge({ files: added }),			RequestedRemove: ({ id }) => Message.RemovedKnowledge({ id }),			RequestedInstructions: ({ instructions: text }) => Message.SavedInstructions({ instructions: text }),		},	})

API reference

Props

ProjectKnowledge props
NameTypeDescription
filesrequiredKnowledgeFile[]—
instructionsrequiredstringThe project's custom instructions; empty for none
nowrequiredstringThe present, ISO, for "Added 2 hours ago"
labelstringThe card's heading: "Project knowledge" by default
agentIdstringThe id agents see this card by
addingnumberFiles on their way in, shown as a status line

Events

ProjectKnowledge events
EventPayloadDescription
RequestedAdd{ files: Files }Files picked or dropped, to add to the project
RequestedRemove{ id: string }—
RequestedInstructions{ instructions: string }Store these as the project's instructions; empty clears them

Agent actions

What agents can do with ProjectKnowledge
ActionDescription
SubmittedInstructionsSet the project's custom instructions: how the assistant should behave and answer in this project. Empty clears them.
ClickedRemoveFileRemove a file from the project, by id

Accessibility

  • Add is a real file input behind a label, so it works from the keyboard and with a screen reader. Dropping files on the card does the same.
  • Long file names are cut in the middle so the extension stays; the full name is the row's tooltip.
  • Instructions count their characters as you type and refuse to save past the limit; Escape cancels.

Source