mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 04:01:56 +00:00
Clarify when to use artifacts runtime functions vs artifacts tool
Make it clear that runtime functions are ONLY for programmatically generated content (by code), not for content the LLM authors directly. Changes: - Add WHEN TO USE and DO NOT USE sections to runtime provider description - Emphasize that createOrUpdateArtifact is for code-generated content - Point users to artifacts tool for LLM-authored content like summaries
This commit is contained in:
parent
2e56f77599
commit
ab9137542c
1 changed files with 31 additions and 20 deletions
|
|
@ -186,27 +186,38 @@ ${ARTIFACTS_RUNTIME_EXAMPLE}
|
|||
// ============================================================================
|
||||
|
||||
export const ARTIFACTS_RUNTIME_PROVIDER_DESCRIPTION = `
|
||||
Artifact Management (persistent session files you can access/modify programmatically):
|
||||
- await listArtifacts() - Get list of all artifact filenames, returns string[]
|
||||
* Example: const files = await listArtifacts(); // ['data.json', 'notes.md', 'chart.png']
|
||||
- await getArtifact(filename) - Read artifact content, returns string or object
|
||||
* Auto-parses .json files to objects, otherwise returns raw string content
|
||||
* Example: const data = await getArtifact('data.json'); // Returns parsed object
|
||||
* Example: const markdown = await getArtifact('notes.md'); // Returns string
|
||||
- await createOrUpdateArtifact(filename, content, mimeType?) - Create or update a persistent artifact
|
||||
* Automatically creates if new, updates if exists
|
||||
* Auto-stringifies objects for .json files
|
||||
* Example: await createOrUpdateArtifact('data.json', {items: []}) // Auto-stringifies
|
||||
* Example: await createOrUpdateArtifact('research-notes.md', '# Research Notes\\n', 'text/markdown')
|
||||
* Full content replacement (not diff-based) when updating
|
||||
- await deleteArtifact(filename) - Delete an artifact
|
||||
* Example: await deleteArtifact('old-notes.md')
|
||||
Artifact Management from within executed code (HTML/JavaScript REPL).
|
||||
|
||||
Powerful pattern for evolving data:
|
||||
const files = await listArtifacts();
|
||||
const data = files.includes('data.json') ? await getArtifact('data.json') : {items: []};
|
||||
data.items.push(newScrapedItem);
|
||||
await createOrUpdateArtifact('data.json', data);
|
||||
WHEN TO USE THESE FUNCTIONS:
|
||||
- ONLY when writing code that programmatically generates/transforms data
|
||||
- Examples: Web scraping results, processed CSV data, generated charts saved as JSON
|
||||
- The artifact content is CREATED BY THE CODE, not by you directly
|
||||
|
||||
DO NOT USE THESE FUNCTIONS FOR:
|
||||
- Summaries or notes YOU write (use artifacts tool instead)
|
||||
- Content YOU author directly (use artifacts tool instead)
|
||||
|
||||
Functions:
|
||||
- await listArtifacts() - Get list of all artifact filenames, returns string[]
|
||||
* Example: const files = await listArtifacts(); // ['data.json', 'notes.md']
|
||||
|
||||
- await getArtifact(filename) - Read artifact content, returns string or object
|
||||
* Auto-parses .json files to objects
|
||||
* Example: const data = await getArtifact('data.json'); // Returns parsed object
|
||||
|
||||
- await createOrUpdateArtifact(filename, content, mimeType?) - Create/update artifact FROM CODE
|
||||
* ONLY use when the content is generated programmatically by your code
|
||||
* Auto-stringifies objects for .json files
|
||||
* Example: await createOrUpdateArtifact('scraped-data.json', results)
|
||||
* Example: await createOrUpdateArtifact('chart.png', base64ImageData, 'image/png')
|
||||
|
||||
- await deleteArtifact(filename) - Delete an artifact
|
||||
* Example: await deleteArtifact('temp.json')
|
||||
|
||||
Example - Scraping data and saving it:
|
||||
const response = await fetch('https://api.example.com/data');
|
||||
const data = await response.json();
|
||||
await createOrUpdateArtifact('api-results.json', data);
|
||||
|
||||
Binary data must be converted to a base64 string before passing to createOrUpdateArtifact.
|
||||
Example:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue