Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
[web] Fix for minified templates
Browse files Browse the repository at this point in the history
  • Loading branch information
maxijonson committed Jul 3, 2023
1 parent 3e2d62a commit e366ac8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
2 changes: 2 additions & 0 deletions packages/web/src/components/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const CodeEditor = ({
name,
parameters,
}: CodeEditorProps) => {
// Use this line during development of function templates to see what the code property of the template should contain
// console.log(JSON.stringify(value));
const hasInit = React.useRef(false);
const editor = useEditor(
{
Expand Down
8 changes: 1 addition & 7 deletions packages/web/src/utils/functionTemplates/asyncTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CallableFunction, CallableFunctionNumber } from "gpt-turbo";
import type { FunctionTemplate } from ".";
import getFunctionBody from "../getFunctionBody";

const asyncTemplate = new CallableFunction(
"wait",
Expand All @@ -18,10 +17,5 @@ export default {
...asyncTemplate.toJSON(),
template: "async",
displayName: "Async",
code: getFunctionBody((ms: number) => {
return (async () => {
await new Promise((res) => setTimeout(res, ms));
return ms;
})();
}),
code: "return (async () => {\n await new Promise((res) => setTimeout(res, ms))\n return ms;\n})();",
} satisfies FunctionTemplate;
14 changes: 1 addition & 13 deletions packages/web/src/utils/functionTemplates/fetchTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CallableFunctionNumber,
} from "gpt-turbo";
import type { FunctionTemplate } from ".";
import getFunctionBody from "../getFunctionBody";

const fetchTemplate = new CallableFunction(
"fetch",
Expand Down Expand Up @@ -33,16 +32,5 @@ export default {
...fetchTemplate.toJSON(),
template: "fetch",
displayName: "Fetch",
code: getFunctionBody((entityType: string, id?: number) => {
return (async () => {
const baseUrl = "https://jsonplaceholder.typicode.com";
const url = id
? `${baseUrl}/${entityType}/${id}`
: `${baseUrl}/${entityType}`;

const response = await fetch(url);
const json = await response.json();
return id ? json : json.slice(0, 5);
})();
}),
code: 'return (async ()=>{\n const baseUrl = "https://jsonplaceholder.typicode.com";\n const url = id ? `${baseUrl}/${entityType}/${id}` : `${baseUrl}/${entityType}`;\n const response = await fetch(url);\n const json = await response.json();\n return id ? json : json.slice(0, 5);\n})();',
} satisfies FunctionTemplate;
16 changes: 0 additions & 16 deletions packages/web/src/utils/getFunctionBody.ts

This file was deleted.

0 comments on commit e366ac8

Please sign in to comment.