diff --git a/backend/main.py b/backend/main.py
index 755afe2..3c2c19c 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -82,7 +82,7 @@ def ask_ai(req: PromptRequest):
"model": "deepseek/deepseek-chat-v3-0324",
"messages": [
- {"role": "system", "content": "You are Tara, a helpful coding assistant. When asked who you are, always answer 'I am Tara, your helpfull coding assistant'."},
+ {"role": "system", "content": "You are Tara, a helpful coding assistant. When asked who you are, always answer 'I am Tara, your helpfull coding assistant'. Don't answer anything that is not related to coding. Also ensure the you return only the code so it can be directly copied to the editor"},
{"role": "user", "content": full_prompt}
]
diff --git a/frontend/src/App.js b/frontend/src/App.js
index c0fd3f1..51799a9 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -8,10 +8,40 @@ function App() {
const [output, setOutput] = useState("");
const [chatLog, setChatLog] = useState([]);
const [promptInput, setPromptInput] = useState("");
+ const [isListening, setIsListening] = useState(false);
const editorRef = useRef(null);
const BACKEND_URL = "https://ai-code-editor-2.onrender.com"; // Railway backend URL
// Railway backend URL
+ // Voice recognition setup
+ const recognitionRef = useRef(null);
+
+ const handleMicClick = () => {
+ if (!('webkitSpeechRecognition' in window || 'SpeechRecognition' in window)) {
+ alert('Speech recognition not supported in this browser.');
+ return;
+ }
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
+ if (!recognitionRef.current) {
+ recognitionRef.current = new SpeechRecognition();
+ recognitionRef.current.continuous = false;
+ recognitionRef.current.interimResults = false;
+ recognitionRef.current.lang = 'en-US';
+ recognitionRef.current.onresult = (event) => {
+ const transcript = event.results[0][0].transcript;
+ setPromptInput(prev => prev + (prev ? ' ' : '') + transcript);
+ setIsListening(false);
+ };
+ recognitionRef.current.onerror = () => {
+ setIsListening(false);
+ };
+ recognitionRef.current.onend = () => {
+ setIsListening(false);
+ };
+ }
+ setIsListening(true);
+ recognitionRef.current.start();
+ };
const handleRun = async () => {
try {
@@ -98,7 +128,15 @@ function App() {
onChange={(e) => setPromptInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && handleAskAI()}
/>
-
+
+