Skip to main content

Installation

npm install artifactuse

Syntax Highlighting (Optional)

For code syntax highlighting in the panel, add Prism.js:
npm install prismjs
// If using npm, import in your app entry
import Prism from 'prismjs'
import 'prismjs/components/prism-javascript'
import 'prismjs/components/prism-typescript'
import 'prismjs/components/prism-python'
import 'prismjs/themes/prism-tomorrow.css' // or any theme you prefer

Basic Usage

<template>
  <div class="app-container">
    <div class="chat">
      <ArtifactuseAgentMessage 
        v-for="msg in messages"
        :key="msg.id"
        :content="msg.content"
        :message-id="msg.id"
        @form-submit="handleFormSubmit"
        @social-copy="handleSocialCopy"
      />
      
      <ArtifactusePanelToggle />
    </div>
    
    <ArtifactusePanel @ai-request="handleAIRequest" />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { 
  ArtifactuseAgentMessage, 
  ArtifactusePanel, 
  ArtifactusePanelToggle,
  provideArtifactuse 
} from 'artifactuse/vue'
import 'artifactuse/styles'

provideArtifactuse({
  theme: 'dark',
  // branding: true, // Set to false to hide "Powered by Artifactuse" (requires license)
})

const messages = ref([])

function handleFormSubmit({ formId, values }) {
  console.log('Form submitted:', formId, values)
}

function handleSocialCopy({ platform, text }) {
  console.log('Copied:', platform, text)
}

async function handleAIRequest({ prompt, context }) {
  const response = await yourAI.chat(prompt)
}
</script>

<style>
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

#app {
  height: 100%;
}

.app-container {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.chat {
  flex: 1;
  padding: 20px;
  min-width: 0;
  overflow-y: auto;
}
</style>

Add AI Prompts

Install the prompts package to teach your AI how to generate artifacts:
npm install @artifactuse/prompts
import { canvasPrompt, videoPrompt } from '@artifactuse/prompts'

const systemPrompt = `
You are a helpful assistant.

${canvasPrompt}
${videoPrompt}
`

const response = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'system', content: systemPrompt },
    { role: 'user', content: 'Create a YouTube thumbnail' }
  ]
})

Next Steps