mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-24 15:38:10 +02:00
Improve AI text generation on the new post page by parsing product details
Update `new-post.tsx` to parse product information from text input before sending to `/api/ai/generate` endpoint. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/sjuGm8z
This commit is contained in:
1 parent
874e0ad171
commit
0ab89b77c8
2 files changed
+11
-2
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 243 KiB |
@@ -35,8 +35,17 @@ export default function NewPost() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const generateTextMutation = useMutation({
|
const generateTextMutation = useMutation({
|
||||||
mutationFn: (productInfo: string) =>
|
mutationFn: (productInfoText: string) => {
|
||||||
apiRequest('POST', '/api/ai/generate', { productInfo }),
|
const productInfo = {
|
||||||
|
name: productInfoText.match(/Produit:\s*(.+?)(?:\n|$)/i)?.[1] ||
|
||||||
|
productInfoText.match(/Nom:\s*(.+?)(?:\n|$)/i)?.[1] ||
|
||||||
|
productInfoText,
|
||||||
|
price: productInfoText.match(/Prix:\s*(.+?)(?:\n|$)/i)?.[1] || "",
|
||||||
|
description: productInfoText.match(/Description:\s*(.+?)(?:\n|$)/i)?.[1] || "",
|
||||||
|
features: productInfoText.match(/Caractéristiques:\s*(.+?)(?:\n|$)/i)?.[1]?.split(",") || [],
|
||||||
|
};
|
||||||
|
return apiRequest('POST', '/api/ai/generate', productInfo);
|
||||||
|
},
|
||||||
onSuccess: (data: any) => {
|
onSuccess: (data: any) => {
|
||||||
const variants = data.variants || [];
|
const variants = data.variants || [];
|
||||||
setGeneratedVariants(variants);
|
setGeneratedVariants(variants);
|
||||||
|
|||||||
Reference in new issue
Block a user