Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Do not clone this repository because we are going to use a different template.
We recommend opening the react template
using a provisioning tool like Codespaces (recommended) or Gitpod. Alternatively, you can clone the GitHub repository on your local computer using the git clone
command.
This is the repository you need to open or clone:
https://github.com/4GeeksAcademy/react-hello
⚠ You will need to have Node.js installed if you do it locally, but all of that is already installed on Codespaces or Gitpod!
Example:
1 const handleTranslate = async ({ text, targetLanguage }) => { 2 const prompt = `Translate the following text to ${targetLanguage}:\n\n"${text}"`; 3 4 try { 5 const response = await fetch('https://api.openai.com/v1/completions', { 6 method: 'POST', 7 headers: { 8 'Authorization': `Bearer YOUR_OPENAI_API_KEY`, 9 'Content-Type': 'application/json', 10 }, 11 body: JSON.stringify({ 12 model: 'text-davinci-003', 13 prompt: prompt, 14 max_tokens: 1000, 15 temperature: 0, 16 }), 17 }); 18 19 const data = await response.json(); 20 const translation = data.choices[0].text.trim(); 21 setTranslatedText(translation); 22 } catch (error) { 23 console.error('Error translating text:', error); 24 } 25 };
Note: Remember to replace
'YOUR_OPENAI_API_KEY'
with your actual OpenAI API key.
Source Language Selection: Allow users to select the source language of the text.
Language Detection: Implement automatic language detection for the source text.
Support Multiple Target Languages: Add more language options for translation.
History: Keep a history of translations so users can revisit them.
Error Handling: Add robust error handling to manage API errors, network issues, or invalid inputs.
Styling: Enhance your app's appearance using CSS or styling libraries like Bootstrap or Material-UI.
Accessibility: Ensure your app is accessible to all users, including those using screen readers.
Explore different enhancements to make your translator app more interactive and user-friendly!
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
Difficulty
intermediate
Average duration
4 hrs
Technologies
Javascript
React.js
Generative AI
prompt-engineer
In order to prepare better for completing this exercises, we suggest the following materials