| |
| |
|
|
| import React from 'react'; |
|
|
| |
| interface PromptProps { |
| language?: 'bn' | 'en'; |
| style?: 'news' | 'opinion' | 'headline' | 'summary'; |
| topic?: string; |
| context?: string; |
| } |
|
|
| |
| |
| |
|
|
| export const NewsTemplate: React.FC<PromptProps> = ({ |
| language = 'bn', |
| style = 'news', |
| topic = 'সাম্প্রতিক ঘটনাবলী', |
| context = 'বাংলাদেশী প্রেক্ষাপট' |
| }) => { |
| const prompts = { |
| bn: { |
| news: ` |
| <news-article> |
| <headline>${topic} সম্পর্কে নতুন প্রতিবেদন</headline> |
| <context>${context}</context> |
| <instructions> |
| আপনি একজন পেশাদার সাংবাদিক। নিচের নির্দেশনা অনুসরণ করে খবর লিখুন: |
| 1. স্পষ্ট এবং বাস্তবসম্মত ভাষা ব্যবহার করুন |
| 2. তথ্যগুলো বিশ্বস্ত উৎস থেকে নিশ্চিত করুন |
| 3. পাঠকদের জন্য উপযুক্ত টোন বজায় রাখুন |
| </instructions> |
| <format> |
| <lead>প্রথম প্যারাগ্রাফে মূল বার্তা দিন</lead> |
| <body>বিস্তারিত তথ্য এবং বিশ্লেষণ যোগ করুন</body> |
| <quote>সংশ্লিষ্ট ব্যক্তির উদ্ধৃতি অন্তর্ভুক্ত করুন</quote> |
| </format> |
| </news-article>`, |
| opinion: ` |
| <opinion-piece> |
| <topic>${topic}</topic> |
| <position>মতামত ভিত্তিক বিশ্লেষণ প্রস্তুত করুন</position> |
| <context>${context}</context> |
| <instructions> |
| একটি বুদ্ধিদীপ্ত মতামত প্রবন্ধ লিখুন যা: |
| 1. ব্যক্তিগত দৃষ্টিভঙ্গি প্রকাশ করে |
| 2. যুক্তি ও প্রমাণ ভিত্তিক |
| 3. পাঠকদের চিন্তায় উদ্দীপনা জোগায় |
| </instructions> |
| </opinion-piece>`, |
| headline: ` |
| <headline-generator> |
| <topic>${topic}</topic> |
| <context>${context}</context> |
| <instructions> |
| আকর্ষণীয় এবং তথ্যবহুল হেডলাইন তৈরি করুন: |
| 1. ১০-১৫ শব্দের মধ্যে রাখুন |
| 2. মূল খবরের ইঙ্গিত দিন |
| 3. পাঠকদের আগ্রহ বাড়ানোর উদ্দেশ্যে লিখুন |
| </instructions> |
| </headline-generator>` |
| }, |
| en: { |
| news: ` |
| <news-article> |
| <headline>New report on ${topic}</headline> |
| <context>${context}</context> |
| <instructions> |
| You are a professional journalist. Follow these guidelines to write news: |
| 1. Use clear and factual language |
| 2. Verify information from reliable sources |
| 3. Maintain appropriate tone for readers |
| </instructions> |
| <format> |
| <lead>Provide main message in first paragraph</lead> |
| <body>Add detailed information and analysis</body> |
| <quote>Include relevant person quotes</quote> |
| </format> |
| </news-article>`, |
| opinion: ` |
| <opinion-piece> |
| <topic>${topic}</topic> |
| <position>Provide opinion-based analysis</position> |
| <context>${context}</context> |
| <instructions> |
| Write an insightful opinion piece that: |
| 1. Expresses personal perspective |
| 2. Is based on reasoning and evidence |
| 3. Stimulates reader thinking |
| </instructions> |
| </opinion-piece>`, |
| headline: ` |
| <headline-generator> |
| <topic>${topic}</topic> |
| <context>${context}</context> |
| <instructions> |
| Create attractive and informative headlines: |
| 1. Keep within 10-15 words |
| 2. Indicate main news |
| 3. Aim to increase reader interest |
| </instructions> |
| </headline-generator>` |
| } |
| }; |
| |
| return <>{prompts[language][style]}</>; |
| }; |
|
|
| |
| |
| |
|
|
| export const NewsComponents: React.FC<{ |
| components: Array<{ |
| type: 'lead' | 'body' | 'quote' | 'conclusion'; |
| content: string; |
| source?: string; |
| }>; |
| }> = ({ components }) => { |
| const renderedComponents = components.map((comp, index) => { |
| switch (comp.type) { |
| case 'lead': |
| return ( |
| <lead key={index}> |
| {comp.content} |
| </lead> |
| ); |
| case 'quote': |
| return ( |
| <quote key={index} source={comp.source}> |
| "{comp.content}" |
| </quote> |
| ); |
| case 'conclusion': |
| return ( |
| <conclusion key={index}> |
| {comp.content} |
| </conclusion> |
| ); |
| default: |
| return ( |
| <body key={index}> |
| {comp.content} |
| </body> |
| ); |
| } |
| }); |
| |
| return <>{renderedComponents}</>; |
| }; |
|
|
| |
| |
| |
|
|
| export const generateNewsPrompt: React.FC<{ |
| topic: string; |
| language?: 'bn' | 'en'; |
| style?: 'news' | 'opinion' | 'headline'; |
| includeSources?: boolean; |
| maxLength?: number; |
| }> = ({ |
| topic, |
| language = 'bn', |
| style = 'news', |
| includeSources = true, |
| maxLength = 200 |
| }) => { |
| const basePrompt = NewsTemplate({ language, style, topic }); |
| |
| if (includeSources) { |
| return ( |
| <production-news> |
| {basePrompt} |
| <source-requirement> |
| সত্যায়িত তথ্য এবং উৎস উল্লেখ করুন |
| </source-requirement> |
| <length-control> |
| সর্বোচ্চ {maxLength} শব্দে সীমাবদ্ধ রাখুন |
| </length-control> |
| </production-news> |
| ); |
| } |
| |
| return <production-news>{basePrompt}</production-news>; |
| }; |
|
|
| |
| |
| export const NewsTemplates = { |
| breaking: NewsTemplate, |
| analysis: NewsTemplate, |
| sports: NewsTemplate, |
| economy: NewsTemplate, |
| politics: NewsTemplate, |
| opinion: NewsTemplate, |
| headline: NewsTemplate |
| } as const; |
|
|
| export default NewsTemplate; |