Skip to content

Commit

Permalink
Merge pull request #15 from techulus/develop
Browse files Browse the repository at this point in the history
Use ManagePrompt
  • Loading branch information
arjunkomath authored Feb 19, 2024
2 parents ddad252 + 6f9742a commit 33be647
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 145 deletions.
2 changes: 1 addition & 1 deletion apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ContentSecurityPolicy = `
style-src 'self' data: 'unsafe-inline' maxcdn.bootstrapcdn.com;
img-src 'self' * data: blob:;
font-src 'self' data: maxcdn.bootstrapcdn.com;
connect-src 'self' wss: *.supabase.co *.changes.page;
connect-src 'self' wss: *.supabase.co *.changes.page manageprompt.com;
worker-src 'self' blob:;
report-to default
`;
Expand Down
28 changes: 28 additions & 0 deletions apps/web/pages/api/ai/mp-auth-webhook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { IErrorResponse } from "@changes-page/supabase/types/api";
import type { NextApiRequest, NextApiResponse } from "next";

const managePromptAuthWebhook = async (
req: NextApiRequest,
res: NextApiResponse<{ success: boolean; ttl: number } | IErrorResponse>
) => {
if (req.method === "POST") {
const { workflowId } = req.body;

if (workflowId === process.env.MANAGEPROMPT_CHANGEGPT_WORKFLOW_ID) {
res.status(200).json({ success: true, ttl: 86400 });
return;
}

res.status(401).json({
error: {
statusCode: 401,
message: "Invalid workflowId",
},
});
} else {
res.setHeader("Allow", "POST");
res.status(405).end("Method Not Allowed");
}
};

export default managePromptAuthWebhook;
58 changes: 0 additions & 58 deletions apps/web/pages/api/free-tools/change-gpt.ts

This file was deleted.

20 changes: 14 additions & 6 deletions apps/web/pages/free-tools/ai-changelog-generator.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SpinnerWithSpacing } from "@changes-page/ui";
import { LightningBoltIcon, RefreshIcon } from "@heroicons/react/solid";
import classNames from "classnames";
import { InferGetStaticPropsType } from "next";
import { useCallback, useState } from "react";
import { SpinnerWithSpacing } from "@changes-page/ui";
import {
createToastWrapper,
notifyError,
Expand All @@ -12,7 +13,11 @@ import MarketingHeaderComponent from "../../components/marketing/marketing-heade
import { track } from "../../utils/analytics";
import usePrefersColorScheme from "../../utils/hooks/usePrefersColorScheme";

export default function AIChangelogGenerator({ title, description }) {
export default function AIChangelogGenerator({
title,
description,
modelStreamUrl,
}: InferGetStaticPropsType<typeof getStaticProps>) {
const theme = usePrefersColorScheme();

const [content, setContent] = useState("");
Expand All @@ -33,15 +38,17 @@ export default function AIChangelogGenerator({ title, description }) {

setLoading(true);

const response = await fetch("/api/free-tools/change-gpt", {
const response = await fetch(modelStreamUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content,
addIntroOutro,
soundCasual,
intro: addIntroOutro
? "Add a short intro and outro, make sure its generic and polite."
: "Do not add any introduction or additional content at the beginnning or end.",
tone: soundCasual ? "casual" : "formal",
}),
});

Expand Down Expand Up @@ -70,7 +77,7 @@ export default function AIChangelogGenerator({ title, description }) {
}

setCompleted(true);
}, [content, addIntroOutro, soundCasual]);
}, [content, addIntroOutro, soundCasual, modelStreamUrl]);

return (
<div className="bg-gray-800 min-h-screen">
Expand Down Expand Up @@ -296,6 +303,7 @@ export async function getStaticProps() {
title: "ChangeCraftAI: Free Changelog Generator",
description:
"Say goodbye to the tedious task of writing changelog and release notes. Our revolutionary tool powered by GPT-3 automatically generates them for you, and it's completely free!",
modelStreamUrl: `https://manageprompt.com/api/run/${process.env.MANAGEPROMPT_CHANGEGPT_WORKFLOW_ID}/stream`,
},
};
}
80 changes: 0 additions & 80 deletions apps/web/utils/open-ai.ts

This file was deleted.

0 comments on commit 33be647

Please sign in to comment.