mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Merge pull request #18 from R0m1k3/dev
Improve AI text generation on the new post page by parsing product de…
This commit is contained in:
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({
|
||||
mutationFn: (productInfo: string) =>
|
||||
apiRequest('POST', '/api/ai/generate', { productInfo }),
|
||||
mutationFn: (productInfoText: string) => {
|
||||
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) => {
|
||||
const variants = data.variants || [];
|
||||
setGeneratedVariants(variants);
|
||||
|
||||
Reference in new issue
Block a user