Skip to content

Commit f58e885

Browse files
author
9race22
committed
remove comments
1 parent c0ffe3d commit f58e885

File tree

5 files changed

+13
-150
lines changed

5 files changed

+13
-150
lines changed

minions-application/public/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

minions-application/src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const App: React.FC = () => {
3232
const handleRunTask = async (userQuery: string) => {
3333
setError(null);
3434

35-
// Validate configuration
35+
// validate configuration
3636
if (!config.remoteApiKey) {
3737
setError('Please enter a valid API key for the remote provider');
3838
return;
@@ -54,7 +54,6 @@ const App: React.FC = () => {
5454
}
5555

5656
try {
57-
// Convert reasoningEffort from string to number
5857
const reasoningEffortMap = {
5958
'low': 0,
6059
'medium': 1,

minions-application/src/components/Chat.tsx

Lines changed: 0 additions & 125 deletions
This file was deleted.

minions-application/src/components/ChatInterface.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({ query, setQuery, output,
3838
useEffect(() => {
3939
if (output) {
4040
console.log('ChatInterface received new output:', output);
41-
// Parse the output to extract messages and final answer
41+
4242
const lines = output.split('\n');
4343
const newMessages: Message[] = [];
4444

@@ -59,16 +59,16 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({ query, setQuery, output,
5959
} else if (line.startsWith('Final Answer: ')) {
6060
const answer = line.slice(13);
6161
try {
62-
// Try to parse as JSON
63-
const jsonAnswer = JSON.parse(answer);
64-
// If successful, stringify with proper formatting and syntax highlighting
62+
// Try to parse as JSON if it's a string
63+
const jsonAnswer = typeof answer === 'string' ? JSON.parse(answer) : answer;
64+
// Always stringify the answer to ensure proper display
6565
setFinalAnswer(
6666
<pre className="bg-gray-50 dark:bg-gray-700 p-4 rounded-lg overflow-x-auto">
6767
{JSON.stringify(jsonAnswer, null, 2)}
6868
</pre>
6969
);
7070
} catch {
71-
// If not JSON, use as is
71+
// If not JSON or parsing fails, use as is
7272
setFinalAnswer(answer);
7373
}
7474
} else if (line.startsWith('Execution Time: ')) {
@@ -195,12 +195,12 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({ query, setQuery, output,
195195
if (line.startsWith('Final Answer: ')) {
196196
const answer = line.slice(13);
197197
try {
198-
// Try to parse as JSON
199-
const jsonAnswer = JSON.parse(answer);
200-
// If successful, stringify with proper formatting
198+
// Try to parse as JSON if it's a string
199+
const jsonAnswer = typeof answer === 'string' ? JSON.parse(answer) : answer;
200+
// Always stringify the answer to ensure proper display
201201
return `Final Answer: ${JSON.stringify(jsonAnswer, null, 2)}`;
202202
} catch {
203-
// If not JSON, use as is
203+
// If not JSON or parsing fails, use as is
204204
return line;
205205
}
206206
}

minions-application/src/hooks/useProtocol.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ export function useProtocol(): ProtocolOutput {
99
const [error, setError] = useState<string | null>(null);
1010

1111
const runProtocol = async (input: ProtocolInput): Promise<void> => {
12-
// Reset states
12+
// reset states
1313
setOutput('');
1414
setError(null);
1515
setLoading(true);
1616

1717
try {
18-
// Prepare the request body
1918
const requestBody = {
2019
task: input.query,
21-
context: input.context.join('\n'), // Always send as a list
20+
context: input.context.join('\n'),
2221
doc_metadata: input.fileMetadata || '',
2322
protocol: input.config.protocol,
2423
localProvider: input.config.localProvider,
@@ -36,14 +35,12 @@ export function useProtocol(): ProtocolOutput {
3635
images: input.config.images
3736
};
3837

39-
// Log the request (sanitize sensitive data)
4038
console.log('Sending request:', {
4139
...requestBody,
42-
remote_api_key: '***', // Hide API key in logs
40+
remote_api_key: '***',
4341
context: requestBody.context.slice(0, 300) + '...',
4442
});
4543

46-
// Make the API request with proper error handling
4744
const response = await fetch(`${API_BASE_URL}/run_protocol`, {
4845
method: 'POST',
4946
headers: {
@@ -60,7 +57,6 @@ export function useProtocol(): ProtocolOutput {
6057
console.error('Server error response:', errorData);
6158
errorMessage = errorData.error || errorMessage;
6259
} catch (e) {
63-
// If we can't parse the error JSON, use the status text
6460
console.error('Failed to parse error response:', e);
6561
errorMessage = response.statusText;
6662
}
@@ -70,27 +66,21 @@ export function useProtocol(): ProtocolOutput {
7066
const data = await response.json() as ProtocolResponse;
7167
console.log('Protocol completed with result:', data);
7268

73-
// Format the output with all available information
7469
let formattedOutput = `Final Answer: ${data.output.final_answer}\n`;
7570

76-
// Add execution time
7771
if (data.output.execution_time > 0) {
7872
formattedOutput += `\nExecution Time: ${data.output.execution_time.toFixed(2)}s`;
7973
}
8074

81-
// Add protocol-specific information
8275
if (data.output.meta) {
8376
data.output.meta.forEach((round, index) => {
8477
if (round.remote?.messages) {
8578
formattedOutput += `\n\nRound ${index + 1} Remote Messages:`;
8679
round.remote.messages.forEach(msg => {
8780
try {
88-
// Try to parse as JSON if it's a string
8981
const jsonMsg = typeof msg === 'string' ? JSON.parse(msg) : msg;
90-
// Format the message with proper indentation
9182
formattedOutput += `\n${JSON.stringify(jsonMsg, null, 2)}`;
9283
} catch {
93-
// If not JSON or parsing fails, use as is
9484
formattedOutput += `\n${msg}`;
9585
}
9686
});

0 commit comments

Comments
 (0)