File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
templates/components/engines/typescript/agent/tools Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2023 FoundryLabs, Inc.
2
+ * Copyright 2023 FoundryLabs, Inc., LlamaIndex Inc.
3
3
* Portions of this file are copied from the e2b project (https://github.com/e2b-dev/ai-artifacts)
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -149,9 +149,12 @@ export class ArtifactTool implements BaseTool<ArtifactParameter> {
149
149
] ;
150
150
try {
151
151
const response = await Settings . llm . chat ( { messages } ) ;
152
- const artifact = JSON . parse (
153
- response . message . content . toString ( ) ,
154
- ) as Artifact ;
152
+ const content = response . message . content . toString ( ) ;
153
+ const jsonContent = content
154
+ . replace ( / ^ ` ` ` j s o n \s * | \s * ` ` ` $ / g, "" )
155
+ . replace ( / ^ ` + | ` + $ / g, "" )
156
+ . trim ( ) ;
157
+ const artifact = JSON . parse ( jsonContent ) as Artifact ;
155
158
return artifact ;
156
159
} catch ( error ) {
157
160
console . log ( "Failed to generate artifact" , error ) ;
You can’t perform that action at this time.
0 commit comments