Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪄 feat: Code Artifacts #3798

Merged
merged 74 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
953341b
feat: Add CodeArtifacts component to Beta settings tab
danny-avila Aug 19, 2024
7161981
chore: Update npm dependency to @codesandbox/sandpack-react@2.18.2
danny-avila Aug 19, 2024
f7a3e6f
WIP: artifacts first pass
danny-avila Aug 20, 2024
45472b7
WIP first pass remark-directive
danny-avila Aug 21, 2024
753eb9a
chore: revert markdown to original component + new artifacts rendering
danny-avila Aug 22, 2024
5cecaef
refactor: first pass rewrite
danny-avila Aug 22, 2024
de5204a
refactor: add throttling
danny-avila Aug 22, 2024
a57b76b
first pass styling
danny-avila Aug 23, 2024
c2544ef
style: Add Radix Tabs, more styling changes
danny-avila Aug 23, 2024
20bf718
feat: second pass
danny-avila Aug 23, 2024
3f4a2bc
style: code styling
danny-avila Aug 23, 2024
cb3f558
fix: package markdown fixes
danny-avila Aug 23, 2024
80b43c7
feat: Add useEffect hook to Artifacts component for visibility contro…
danny-avila Aug 23, 2024
7638fe5
fix: only set artifact if there is content
danny-avila Aug 23, 2024
805198b
refactor: typing and make latest artifact active if the number of art…
danny-avila Aug 23, 2024
244d6af
feat: artifacts + shadcnui
danny-avila Aug 23, 2024
5034912
feat: Add Copy Code button to Artifacts component
danny-avila Aug 23, 2024
5473c93
feat: first pass streaming updates
danny-avila Aug 23, 2024
fee629e
refactor: optimize ordering of artifacts in Artifacts component
danny-avila Aug 23, 2024
a5932b8
refactor: optimize ordering of artifacts and add latest artifact acti…
danny-avila Aug 23, 2024
504b08e
refactor: add order prop to Artifact
danny-avila Aug 23, 2024
0f4f44b
feat: update to latest, use update time for ordering
danny-avila Aug 24, 2024
1559d39
refactor: optimize ordering of artifacts and activate latest artifact…
danny-avila Aug 24, 2024
cd2b0fe
wip: remove thinking text and artifact formatting if empty
danny-avila Aug 24, 2024
8188c60
refactor: optimize Markdown rendering and add support for code artifacts
danny-avila Aug 24, 2024
922a45b
feat: global state for current artifact Id and set on artifact previe…
danny-avila Aug 24, 2024
9f51089
refactor: Rename CodePreview component to ArtifactButton
danny-avila Aug 24, 2024
399dd85
refactor: apply growth to artifact frame so artifact preview can take…
danny-avila Aug 24, 2024
7f71577
refactor: remove artifactIdsState
danny-avila Aug 24, 2024
8d1fb55
refactor: nullify artifact state and reset on empty conversation
danny-avila Aug 24, 2024
cd1ff74
feat: reset artifact state on conversation change
danny-avila Aug 24, 2024
cb56bb7
feat: artifacts system prompt in backend
danny-avila Aug 24, 2024
f8d14f1
refactor: update UI artifact toggle label to match localization key
danny-avila Aug 24, 2024
3dc4cab
style: remove ArtifactButton inline-block styling
danny-avila Aug 24, 2024
6c95a01
feat: memoize ArtifactPreview, add html support
danny-avila Aug 24, 2024
1656f52
refactor: abstract out components
danny-avila Aug 24, 2024
13f3ac4
chore: bump react-resizable-panel
danny-avila Aug 25, 2024
bdeea36
refactor: resizable panel order props
danny-avila Aug 25, 2024
cfc04a2
fix: side panel resizing crashes
danny-avila Aug 25, 2024
1bc4ff3
style: temporarily remove scrolling, add better styling
danny-avila Aug 25, 2024
21b144e
chore: remove thinking for now
danny-avila Aug 25, 2024
163aa02
chore: preprocess artifacts for now
danny-avila Aug 25, 2024
82864b2
feat: Add auto scrolling to CodeMarkdown (artifacts)
danny-avila Aug 25, 2024
82c2b2f
feat: autoswitch to preview
danny-avila Aug 25, 2024
55e5bd6
feat: auto switch to code, adjust prompt, remove unused code
danny-avila Aug 25, 2024
59a1f13
feat: refresh button
danny-avila Aug 25, 2024
7bb41a5
feat: open/close artifacts
danny-avila Aug 25, 2024
c46f05f
wip: mermaid
danny-avila Aug 25, 2024
4806a99
refactor: w-fit Artifact button
danny-avila Aug 25, 2024
d5db279
chore: organize code
danny-avila Aug 25, 2024
8faf0c1
feat: first pass mermaid
danny-avila Aug 25, 2024
2648cd5
refactor: improve panning logic in MermaidDiagram component
danny-avila Aug 25, 2024
0768586
feat: center/zoom on first render
danny-avila Aug 25, 2024
9b52dc4
refactor: add centering with reset button
danny-avila Aug 25, 2024
1cc6b9f
style: mermaid styling
danny-avila Aug 25, 2024
08bdc0f
refactor: add back MermaidDiagram
danny-avila Aug 25, 2024
8385b7c
fix: static/html template
danny-avila Aug 26, 2024
ae337c2
fix: mermaid
danny-avila Aug 26, 2024
545ac62
add examples to artifacts prompt
danny-avila Aug 26, 2024
c2a8faa
refactor: fix CodeBar plugin prop logic
danny-avila Aug 26, 2024
5fd9d76
refactor: remove unnecessary mention of artifacts when not requested
danny-avila Aug 26, 2024
a80e2ff
fix: remove preprocessCodeArtifacts function and fix imports
danny-avila Aug 26, 2024
6b53a7b
feat: improve artifacts guidelines and remove unnecessary mentions
danny-avila Aug 26, 2024
2c0f40b
refactor: improve artifacts guidelines and remove unnecessary mentions
danny-avila Aug 26, 2024
f855bf6
chore: uninstall unused packages
danny-avila Aug 27, 2024
236336b
chore: bump vite
danny-avila Aug 27, 2024
1257648
chore: update three dependency to version 0.167.1
danny-avila Aug 27, 2024
4815423
refactor: move beta settings, add additional artifacts toggles
danny-avila Aug 27, 2024
da8a8a2
feat: artifacts mode toggles
danny-avila Aug 27, 2024
9a5d255
refactor: adjust prompt
danny-avila Aug 27, 2024
a13b208
feat: shadcnui instructions
danny-avila Aug 27, 2024
c91d91c
feat: code artifacts custom prompt mode
danny-avila Aug 27, 2024
e8db71a
chore: Update artifacts UI labels and instructions localizations
danny-avila Aug 27, 2024
2ccdf75
refactor: Remove unused code in Markdown component
danny-avila Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/app/clients/AnthropicClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ class AnthropicClient extends BaseClient {
identityPrefix = `${identityPrefix}\nYou are ${this.options.modelLabel}`;
}

let promptPrefix = (this.options.promptPrefix || '').trim();
let promptPrefix = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}
if (promptPrefix) {
// If the prompt prefix doesn't end with the end token, add it.
if (!promptPrefix.endsWith(`${this.endToken}`)) {
Expand Down Expand Up @@ -820,6 +823,7 @@ class AnthropicClient extends BaseClient {
getSaveOptions() {
return {
maxContextTokens: this.options.maxContextTokens,
artifacts: this.options.artifacts,
promptPrefix: this.options.promptPrefix,
modelLabel: this.options.modelLabel,
promptCache: this.options.promptCache,
Expand Down
29 changes: 24 additions & 5 deletions api/app/clients/GoogleClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,13 @@ class GoogleClient extends BaseClient {
parameters: this.modelOptions,
};

if (this.options.promptPrefix) {
payload.instances[0].context = this.options.promptPrefix;
let promptPrefix = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}

if (promptPrefix) {
payload.instances[0].context = promptPrefix;
}

if (this.options.examples.length > 0) {
Expand Down Expand Up @@ -445,7 +450,10 @@ class GoogleClient extends BaseClient {
identityPrefix = `${identityPrefix}\nYou are ${this.options.modelLabel}`;
}

let promptPrefix = (this.options.promptPrefix || '').trim();
let promptPrefix = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}
if (promptPrefix) {
// If the prompt prefix doesn't end with the end token, add it.
if (!promptPrefix.endsWith(`${this.endToken}`)) {
Expand Down Expand Up @@ -670,11 +678,16 @@ class GoogleClient extends BaseClient {
contents: _payload,
};

let promptPrefix = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}

if (this.options?.promptPrefix?.length) {
requestOptions.systemInstruction = {
parts: [
{
text: this.options.promptPrefix,
text: promptPrefix,
},
],
};
Expand Down Expand Up @@ -767,11 +780,16 @@ class GoogleClient extends BaseClient {
contents: _payload,
};

let promptPrefix = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}

if (this.options?.promptPrefix?.length) {
requestOptions.systemInstruction = {
parts: [
{
text: this.options.promptPrefix,
text: promptPrefix,
},
],
};
Expand Down Expand Up @@ -842,6 +860,7 @@ class GoogleClient extends BaseClient {

getSaveOptions() {
return {
artifacts: this.options.artifacts,
promptPrefix: this.options.promptPrefix,
modelLabel: this.options.modelLabel,
iconURL: this.options.iconURL,
Expand Down
4 changes: 4 additions & 0 deletions api/app/clients/OpenAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class OpenAIClient extends BaseClient {

getSaveOptions() {
return {
artifacts: this.options.artifacts,
maxContextTokens: this.options.maxContextTokens,
chatGptLabel: this.options.chatGptLabel,
promptPrefix: this.options.promptPrefix,
Expand Down Expand Up @@ -463,6 +464,9 @@ class OpenAIClient extends BaseClient {
let promptTokens;

promptPrefix = (promptPrefix || this.options.promptPrefix || '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
promptPrefix = `${promptPrefix ?? ''}\n${this.options.artifactsPrompt}`.trim();
}

if (this.options.attachments) {
const attachments = await this.options.attachments;
Expand Down
9 changes: 8 additions & 1 deletion api/app/clients/PluginsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PluginsClient extends OpenAIClient {

getSaveOptions() {
return {
artifacts: this.options.artifacts,
chatGptLabel: this.options.chatGptLabel,
promptPrefix: this.options.promptPrefix,
tools: this.options.tools,
Expand Down Expand Up @@ -145,16 +146,22 @@ class PluginsClient extends OpenAIClient {

// initialize agent
const initializer = this.functionsAgent ? initializeFunctionsAgent : initializeCustomAgent;

let customInstructions = (this.options.promptPrefix ?? '').trim();
if (typeof this.options.artifactsPrompt === 'string' && this.options.artifactsPrompt) {
customInstructions = `${customInstructions ?? ''}\n${this.options.artifactsPrompt}`.trim();
}

this.executor = await initializer({
model,
signal,
pastMessages,
tools: this.tools,
customInstructions,
verbose: this.options.debug,
returnIntermediateSteps: true,
customName: this.options.chatGptLabel,
currentDateString: this.currentDateString,
customInstructions: this.options.promptPrefix,
callbackManager: CallbackManager.fromHandlers({
async handleAgentAction(action, runId) {
handleAction(action, runId, onAgentAction);
Expand Down
Loading
Loading