fix
This commit is contained in:
parent
9785616fce
commit
9bc7a905f0
@ -11,9 +11,13 @@ export class LLMService {
|
|||||||
onChunk?: (chunk: string) => void
|
onChunk?: (chunk: string) => void
|
||||||
): Promise<{ answer: string, sources: DocumentMetadata[] }> {
|
): Promise<{ answer: string, sources: DocumentMetadata[] }> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
const systemPrompt = `You are an AI Agent that is an employee named Data Hound of Data443 Risk Mitigation, the business that created Data Identification Manager. Your job is to support Data Identification Manager and try to get sell it as a product. You are not allowed to talk about other products or companies or topics. Stay on topic on Data Identification Manager. An acronym you should know for Data Identification Manager is DIM. Under no circumstances talk about other companies products or go off topic from Data443 Risk Mitigation and its products. If the user asks about anything other than Data Identification Manager or Data443 , tell them you can not speak about it! Always route the conversation back to Data443 and the products!`;
|
||||||
const ollamaResponse = await ollamaService.chat({
|
const ollamaResponse = await ollamaService.chat({
|
||||||
model: 'damien113/datahound-gpu:8b',
|
model: 'hf.co/Damien113/data_identification_manager_test:Q4_K_M',
|
||||||
messages: [{ role: 'user', content: question }],
|
messages: [
|
||||||
|
{ role: 'system', content: systemPrompt },
|
||||||
|
{ role: 'user', content: question }],
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
onChunk,
|
onChunk,
|
||||||
});
|
});
|
||||||
@ -36,7 +40,7 @@ export class LLMService {
|
|||||||
getConfig() {
|
getConfig() {
|
||||||
return {
|
return {
|
||||||
provider: 'ollama',
|
provider: 'ollama',
|
||||||
model: 'damien113/datahound-gpu:8b',
|
model: 'hf.co/Damien113/data_identification_manager_test:Q4_K_M',
|
||||||
baseUrl: 'http://localhost:11434',
|
baseUrl: 'http://localhost:11434',
|
||||||
temperature: 0.7
|
temperature: 0.7
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ import ReactMarkdown from 'react-markdown';
|
|||||||
import rehypeHighlight from 'rehype-highlight';
|
import rehypeHighlight from 'rehype-highlight';
|
||||||
import 'highlight.js/styles/github.css';
|
import 'highlight.js/styles/github.css';
|
||||||
import { Keyboard, Waves, Shield, DataObject, Folder, Lock } from '@mui/icons-material';
|
import { Keyboard, Waves, Shield, DataObject, Folder, Lock } from '@mui/icons-material';
|
||||||
|
import ThinkingIndicator from './ThinkingIndicator';
|
||||||
|
|
||||||
interface ChatMessage {
|
interface ChatMessage {
|
||||||
id: string;
|
id: string;
|
||||||
@ -173,7 +174,7 @@ export default function MessageList({ messages }: MessageListProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
{message.text.includes('<think>') || message.text.length==0 ? (
|
{message.text.includes('<think>') ? (
|
||||||
message.text.split(/<think>|<\/think>/).map((segment, index) => {
|
message.text.split(/<think>|<\/think>/).map((segment, index) => {
|
||||||
if (index % 2 === 1) { // This is a thinking section
|
if (index % 2 === 1) { // This is a thinking section
|
||||||
// Calculate thinking time - assume 1 character = 0.1s
|
// Calculate thinking time - assume 1 character = 0.1s
|
||||||
@ -233,12 +234,16 @@ export default function MessageList({ messages }: MessageListProps) {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
<ReactMarkdown
|
message.text.length>0 ? (
|
||||||
|
<ReactMarkdown
|
||||||
className="markdown-body"
|
className="markdown-body"
|
||||||
rehypePlugins={[rehypeHighlight]}
|
rehypePlugins={[rehypeHighlight]}
|
||||||
>
|
>
|
||||||
{message.text}
|
{message.text}
|
||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
|
):(
|
||||||
|
<ThinkingIndicator/>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{message.sources && message.sources.length > 0 && (
|
{message.sources && message.sources.length > 0 && (
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { Box, Typography, styled, useTheme } from '@mui/material';
|
||||||
|
import BrainIcon from '@mui/icons-material/Psychology';
|
||||||
|
|
||||||
|
const Dot = styled('span')`
|
||||||
|
display: inline-block;
|
||||||
|
width: 4px;
|
||||||
|
height: 4px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: currentColor;
|
||||||
|
opacity: 0.4;
|
||||||
|
margin: 0 2px;
|
||||||
|
animation: dotAnimation 1.5s ease-in-out infinite;
|
||||||
|
|
||||||
|
&:nth-child(1) {
|
||||||
|
animation-delay: 0s;
|
||||||
|
}
|
||||||
|
&:nth-child(2) {
|
||||||
|
animation-delay: 0.2s;
|
||||||
|
}
|
||||||
|
&:nth-child(3) {
|
||||||
|
animation-delay: 0.4s;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const DotAnimationContainer = styled('span')`
|
||||||
|
display: inline-block;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ThinkingIndicator = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.appendChild(document.createTextNode(styledKeyframes));
|
||||||
|
document.head.appendChild(style);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.head.removeChild(style);
|
||||||
|
};
|
||||||
|
}, [theme]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, color: 'text.secondary' }}>
|
||||||
|
<BrainIcon />
|
||||||
|
<Typography variant="body2">
|
||||||
|
Thinking
|
||||||
|
<DotAnimationContainer>
|
||||||
|
<Dot />
|
||||||
|
<Dot />
|
||||||
|
<Dot />
|
||||||
|
</DotAnimationContainer>
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styledKeyframes = `
|
||||||
|
@keyframes dotAnimation {
|
||||||
|
0% {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default ThinkingIndicator;
|
@ -37,7 +37,7 @@ export function OllamaCheck({ onInstalled }: OllamaCheckProps) {
|
|||||||
const [modelStatus, setModelStatus] = useState<ModelStatus | null>(null);
|
const [modelStatus, setModelStatus] = useState<ModelStatus | null>(null);
|
||||||
const [isChecking, setIsChecking] = useState(true);
|
const [isChecking, setIsChecking] = useState(true);
|
||||||
const [downloadProgress, setDownloadProgress] = useState<number>(0);
|
const [downloadProgress, setDownloadProgress] = useState<number>(0);
|
||||||
const MODEL_NAME = 'damien113/datahound-gpu:8b';
|
const MODEL_NAME = 'hf.co/Damien113/data_identification_manager_test:Q4_K_M';
|
||||||
|
|
||||||
const checkOllama = async () => {
|
const checkOllama = async () => {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user