Fix AI chatbot role mapping, add markdown formatting, update system prompts, and handle OpenRouter API errors

This commit is contained in:
Atharv1705
2026-07-20 12:14:58 +05:30
parent 756547a22c
commit c2e22902c8
168 changed files with 11556 additions and 2 deletions
+33
View File
@@ -0,0 +1,33 @@
import { createContext, useContext, useState, useEffect } from 'react';
const ThemeContext = createContext();
export function ThemeProvider({ children }) {
const [theme, setTheme] = useState(() => {
return localStorage.getItem('theme') || 'light';
});
useEffect(() => {
if (theme === 'dark') {
document.documentElement.classList.add('dark-theme');
document.body.classList.add('dark-theme');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.classList.remove('dark-theme');
document.body.classList.remove('dark-theme');
localStorage.setItem('theme', 'light');
}
}, [theme]);
const toggleTheme = () => {
setTheme(prev => prev === 'dark' ? 'light' : 'dark');
};
return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
);
}
export const useTheme = () => useContext(ThemeContext);