Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improved implementation

Steven Teydb67c0497230
diff --git a/apps/web/app/api/ai/completion/route.ts b/apps/web/app/api/ai/completion/route.ts
index 9e7bfeaffe..d315ed6ca4 100644
--- a/apps/web/app/api/ai/completion/route.ts
+++ b/apps/web/app/api/ai/completion/route.ts
@@ -37,7 +37,7 @@ export async function POST(req: NextRequest) {
content: prompt,
},
],
- model: "claude-3-haiku-20240307",
+ model: "claude-3-sonnet-20240229",
stream: true,
max_tokens: 300,
});
diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsx
index d33420a15b..08d53cd197 100644
--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx
@@ -195,7 +195,7 @@ function AddEditLinkModal({
- Meta title: ${data.title}
- Meta description: ${data.description}.
- Only respond with the short link slug without quotation marks or special characters.
+ Only respond with the short link slug and nothing else. Don't use quotation marks or special characters (dash and slash are allowed).
Make sure your answer does not exist in this list of generated slugs: ${generatedKeys.join(", ")}`,
);
diff --git a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
index 1f978c534b..66f40c5a24 100644
--- a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
@@ -62,13 +62,13 @@ export default function OGSection({
const generateTitle = async () => {
completeTitle(
- `Generate an SEO-optimized meta title tag (max 120 characters) for the following URL:
+ `You are an SEO expert. Generate an SEO-optimized meta title (max 120 characters) for the following URL:
- URL: ${data.url}
- Meta title: ${data.title}
- Meta description: ${data.description}.
- Only respond with the title tag without quotation marks or special characters.
+ Only respond with the title without quotation marks or special characters.
`,
);
};
@@ -103,13 +103,13 @@ export default function OGSection({
const generateDescription = async () => {
completeDescription(
- `Generate an SEO-optimized meta description tag (max 240 characters) for the following URL:
+ `You are an SEO expert. Generate an SEO-optimized meta description (max 240 characters) for the following URL:
- URL: ${data.url}
- Meta title: ${data.title}
- Meta description: ${data.description}.
- Only respond with the description tag without quotation marks or special characters.`,
+ Only respond with the description without quotation marks or special characters.`,
);
};
diff --git a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
index b9fd2594e0..4b37baaf24 100644
--- a/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/tags-section.tsx
@@ -23,9 +23,8 @@ export default function TagsSection({
data: LinkWithTagsProps;
setData: Dispatch<SetStateAction<LinkWithTagsProps>>;
}) {
- const { id } = useWorkspace();
const { tags: availableTags } = useTags();
- const { url, title, description, tags } = data;
+ const { id: linkId, url, title, description, tags } = data;
const [inputValue, setInputValue] = useState("");
@@ -58,12 +57,13 @@ export default function TagsSection({
});
useEffect(() => {
- // only show the completion if all the required fields are filled and not exceeded AI
if (
+ !linkId &&
url &&
title &&
description &&
!exceededAI &&
+ tags.length === 0 &&
suggestedTags.length === 0 &&
availableTags &&
availableTags.length > 0
@@ -87,7 +87,7 @@ export default function TagsSection({
const createTag = async (tag: string) => {
setCreatingTag(true);
setInputValue("");
- fetch(`/api/tags?workspaceId=${id}`, {
+ fetch(`/api/tags?workspaceId=${workspaceId}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -95,7 +95,7 @@ export default function TagsSection({
body: JSON.stringify({ tag }),
}).then(async (res) => {
if (res.ok) {
- await mutate(`/api/tags?workspaceId=${id}`);
+ await mutate(`/api/tags?workspaceId=${workspaceId}`);
const newTag = await res.json();
setData({ ...data, tags: [...tags, newTag] });
toast.success(`Successfully created tag!`);