Making UI progress; seeding lkml RAG
This commit is contained in:
parent
dcb4d35d07
commit
a062edb3dc
@ -20,6 +20,8 @@ import MenuIcon from '@mui/icons-material/Menu';
|
|||||||
import IconButton from '@mui/material/IconButton';
|
import IconButton from '@mui/material/IconButton';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import CssBaseline from '@mui/material/CssBaseline';
|
import CssBaseline from '@mui/material/CssBaseline';
|
||||||
|
import AddIcon from '@mui/icons-material/AddCircle';
|
||||||
|
import SendIcon from '@mui/icons-material/Send';
|
||||||
|
|
||||||
import PropagateLoader from "react-spinners/PropagateLoader";
|
import PropagateLoader from "react-spinners/PropagateLoader";
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
@ -69,7 +71,7 @@ interface ControlsParams {
|
|||||||
toggleRag: (tool: Tool) => void,
|
toggleRag: (tool: Tool) => void,
|
||||||
setRags: (rags: Tool[]) => void,
|
setRags: (rags: Tool[]) => void,
|
||||||
setSystemPrompt: (prompt: string) => void,
|
setSystemPrompt: (prompt: string) => void,
|
||||||
reset: (types: ("rags" | "tools" | "history" | "system-prompt")[]) => Promise<void>
|
reset: (types: ("rags" | "tools" | "history" | "system-prompt")[], message: string) => Promise<void>
|
||||||
};
|
};
|
||||||
|
|
||||||
const Controls = ({ tools, rags, systemPrompt, toggleTool, toggleRag, setSystemPrompt, reset }: ControlsParams) => {
|
const Controls = ({ tools, rags, systemPrompt, toggleTool, toggleRag, setSystemPrompt, reset }: ControlsParams) => {
|
||||||
@ -125,7 +127,7 @@ const Controls = ({ tools, rags, systemPrompt, toggleTool, toggleRag, setSystemP
|
|||||||
/>
|
/>
|
||||||
<div style={{ display: "flex", flexDirection: "row", gap: "8px", paddingTop: "8px" }}>
|
<div style={{ display: "flex", flexDirection: "row", gap: "8px", paddingTop: "8px" }}>
|
||||||
<Button variant="contained" disabled={editSystemPrompt === systemPrompt} onClick={() => { setSystemPrompt(editSystemPrompt); }}>Set</Button>
|
<Button variant="contained" disabled={editSystemPrompt === systemPrompt} onClick={() => { setSystemPrompt(editSystemPrompt); }}>Set</Button>
|
||||||
<Button variant="outlined" onClick={() => { reset(["system-prompt"]); }} color="error">Reset</Button>
|
<Button variant="outlined" onClick={() => { reset(["system-prompt"], "System prompt reset."); }} color="error">Reset</Button>
|
||||||
</div>
|
</div>
|
||||||
</AccordionActions>
|
</AccordionActions>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@ -173,8 +175,8 @@ const Controls = ({ tools, rags, systemPrompt, toggleTool, toggleRag, setSystemP
|
|||||||
}</FormGroup>
|
}</FormGroup>
|
||||||
</AccordionActions>
|
</AccordionActions>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
<Button onClick={() => { reset(["history"]); }}>Clear Chat History</Button>
|
<Button onClick={() => { reset(["history"], "History cleared."); }}>Clear Chat History</Button>
|
||||||
<Button onClick={() => { reset(["rags", "tools", "system-prompt"]) }}>Reset to defaults</Button>
|
<Button onClick={() => { reset(["rags", "tools", "system-prompt"], "Default settings restored.") }}>Reset to defaults</Button>
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +388,7 @@ const App = () => {
|
|||||||
|
|
||||||
}, [systemPrompt, setServerSystemPrompt, serverSystemPrompt, loc, sessionId, setSnack]);
|
}, [systemPrompt, setServerSystemPrompt, serverSystemPrompt, loc, sessionId, setSnack]);
|
||||||
|
|
||||||
const reset = async (types: ("rags" | "tools" | "history" | "system-prompt")[]) => {
|
const reset = async (types: ("rags" | "tools" | "history" | "system-prompt")[], message: string = "Update successful.") => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(getConnectionBase(loc) + `/api/reset/${sessionId}`, {
|
const response = await fetch(getConnectionBase(loc) + `/api/reset/${sessionId}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@ -419,7 +421,7 @@ const App = () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setSnack("Update successful.", "success");
|
setSnack(message, "success");
|
||||||
} else {
|
} else {
|
||||||
throw Error(`${{ status: response.status, message: response.statusText }}`);
|
throw Error(`${{ status: response.status, message: response.statusText }}`);
|
||||||
}
|
}
|
||||||
@ -477,7 +479,7 @@ const App = () => {
|
|||||||
type MessageList = Message[];
|
type MessageList = Message[];
|
||||||
|
|
||||||
const onNew = async () => {
|
const onNew = async () => {
|
||||||
reset(["rags", "tools", "history", "system-prompt"]);
|
reset(["rags", "tools", "history", "system-prompt"], "New chat started.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendQuery = async () => {
|
const sendQuery = async () => {
|
||||||
@ -643,6 +645,16 @@ const App = () => {
|
|||||||
>
|
>
|
||||||
<MenuIcon />
|
<MenuIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
aria-label="new_chat"
|
||||||
|
edge="start"
|
||||||
|
onClick={onNew}
|
||||||
|
sx={{ mr: 2 }}
|
||||||
|
>
|
||||||
|
<AddIcon />
|
||||||
|
</IconButton>
|
||||||
<Typography variant="h6" noWrap component="div">
|
<Typography variant="h6" noWrap component="div">
|
||||||
Ketr-Chat
|
Ketr-Chat
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -729,7 +741,7 @@ const App = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box className="Query" style={{ display: "flex", flexDirection: "row" }}>
|
<Box className="Query" sx={{ display: "flex", flexDirection: "row", p: 1 }}>
|
||||||
<TextField
|
<TextField
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
disabled={processing}
|
disabled={processing}
|
||||||
@ -743,8 +755,7 @@ const App = () => {
|
|||||||
id="QueryInput"
|
id="QueryInput"
|
||||||
/>
|
/>
|
||||||
<AccordionActions>
|
<AccordionActions>
|
||||||
<Button variant="contained" onClick={sendQuery}>Send</Button>
|
<Button sx={{ m: 0 }} variant="contained" onClick={sendQuery}><SendIcon /></Button>
|
||||||
<Button variant="outlined" onClick={onNew}>New</Button>
|
|
||||||
</AccordionActions>
|
</AccordionActions>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -330,7 +330,7 @@ tools = [ {
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"function": {
|
"function": {
|
||||||
"name": "get_current_datetime",
|
"name": "get_current_datetime",
|
||||||
"description": "Get the current date and time in a specified timezone",
|
"description": "Get the current date and time in a specified timezone. For example if a user asks 'What time is it in Poland?' you would pass the Warsaw timezone to get_current_datetime.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user