Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]
Expand Down
40 changes: 39 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -98,7 +128,15 @@ function App() {
onChange={(e) => setPromptInput(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && handleAskAI()}
/>
<button onClick={handleAskAI}>Send</button>
<button
className="mic-button"
onClick={handleMicClick}
style={{ marginLeft: '8px', background: isListening ? '#e0e0e0' : undefined }}
title="Speak"
>
{isListening ? '🎤...' : '🎤'}
</button>
<button onClick={handleAskAI} style={{ marginLeft: '8px' }}>Send</button>
</div>
</div>
</div>
Expand Down