Skip to content

Commit

Permalink
Add process-flow template
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Aug 30, 2024
1 parent 236e275 commit dd63476
Show file tree
Hide file tree
Showing 30 changed files with 105 additions and 25 deletions.
2 changes: 1 addition & 1 deletion api/prompt/_shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function handleRateLimit(
redis: kv,
limiter: isPro
? Ratelimit.slidingWindow(3, "1m")
: Ratelimit.fixedWindow(3, "30d"),
: Ratelimit.fixedWindow(2, "30d"),
});

const rateLimitKey = isPro ? `pro_${customerId}` : `unauth_${ip}`;
Expand Down
Binary file modified app/public/template-screenshots/code-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/decision-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/mindmap-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/network-diagram-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/org-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/pert-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/playful-mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/public/template-screenshots/process-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_code-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_decision-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_flowchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_knowledge-graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_mindmap-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_network-diagram-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_network-diagram-icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_org-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_pert-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/public/template-screenshots/thumb_playful-mindmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 5 additions & 20 deletions app/scripts/screenshot-templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ async function main() {

await screenshotTemplates(filteredTemplates);
await createThumbnails(filteredTemplates);
await createTemplatesIndex(templates); // Always create index with all templates
console.log(
"Don't forget to add the new templates to `shared/src/templates.ts` file."
);
}

/**
Expand Down Expand Up @@ -75,8 +77,8 @@ async function takeScreenshot(browser, template) {
console.error("Error loading template", error);
}

// wait a few seconds
await page.waitForTimeout(3000);
// wait 3 seconds
await new Promise((resolve) => setTimeout(resolve, 3000));

// get the full page link
const screenshotLink = await page.evaluate(() => {
Expand Down Expand Up @@ -137,21 +139,4 @@ async function createThumbnails(templates) {
}
}

async function createTemplatesIndex(templates) {
console.log("Creating templates index...");
const indexPath = path.join(__dirname, "../../shared/templates.ts");
const indexContent = `export const templates = ${JSON.stringify(
templates,
null,
2
)} as const;`;

try {
await writeFile(indexPath, indexContent, "utf8");
console.log("✅ Created templates index file");
} catch (error) {
console.error("Error creating templates index file:", error);
}
}

main().catch(console.error);
2 changes: 2 additions & 0 deletions app/src/components/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ function getGraphUpdater({
// Because the graph has no positions yet
if (layout.name === "fcose") {
if (isFirstRender.current) {
// @ts-ignore
layout.animate = false;
// @ts-ignore
layout.randomize = true;
// @ts-ignore
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/LoadTemplateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export function LoadTemplateDialog() {
});
}, [template, replaceContent, reset]);

console.log(templates);

return (
<Dialog.Root
open={open}
Expand Down
90 changes: 90 additions & 0 deletions app/src/lib/templates/process-flow-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { FFTheme } from "../FFTheme";

export const content = `
Start Process
Step 1: Initial Assessment
Decision Point
Yes: Proceed to Step 2
Step 2: Detailed Analysis
Review Documentation [href="https://docs.example.com"]
Conduct Analysis
Generate Report
Share Results [href="https://results.example.com"]
No: Request More Information
Contact Client [href="mailto:[email protected]"]
(Initial Assessment)
Step 3: Final Decision
Approve: Complete Process
Reject: Provide Feedback
(Start Process)
`;

export const theme: FFTheme = {
layoutName: "dagre",
direction: "DOWN",
spacingFactor: 1.1,

background: "#fbfbfb",
fontFamily: "Inter",

shape: "roundrectangle",
nodeBackground: "#e6e6e6",
nodeForeground: "#333333",
padding: 15,
borderWidth: 0,
borderColor: "#cccccc",
textMaxWidth: 150,
lineHeight: 1.3,
textMarginY: 0,
useFixedHeight: false,
fixedHeight: 60,

curveStyle: "bezier",
edgeWidth: 2,
edgeColor: "#888888",
sourceArrowShape: "none",
targetArrowShape: "triangle",
sourceDistanceFromNode: 0,
targetDistanceFromNode: 5,
arrowScale: 1,
edgeTextSize: 0.9,
rotateEdgeLabel: false,
};

export const cytoscapeStyle = `@import url('https://fonts.googleapis.com/css2?family=Inter:wght@700&display=swap');
:childless {
font-weight: bold;
}
/** Start */
:childless[in_degree < 1][out_degree > 0] {
background-color: #50c878;
border-color: #3da75d;
}
/** Decision Point */
:childless[out_degree > 1] {
shape: diamond;
background-color: #ffa500;
height: $width;
text-margin-y: 2;
border-color: #cc8400;
}
/** Terminal */
:childless[out_degree < 1][in_degree > 0] {
background-color: #ff6347;
color: white;
border-color: #e74c3c;
}
/** Links */
:childless[href] {
background-color: #4a90e2;
color: white;
text-decoration: underline;
cursor: pointer;
border-color: #3a7ac5;
}
`;
9 changes: 5 additions & 4 deletions shared/src/templates.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export const templates = [
"code-flow",
"process-flow",
"flowchart",
"decision-flow",
"pert-light",
"default",
"flowchart",
"org-chart",
"knowledge-graph",
"mindmap-dark",
"mindmap",
"mindmap-dark",
"network-diagram-dark",
"network-diagram-icons",
"org-chart",
"pert-light",
"playful-mindmap",
] as const;

0 comments on commit dd63476

Please sign in to comment.