ausername-12345 commited on
Commit ·
a281e3b
1
Parent(s): d4d67c9
remove function calling (unsupported by API proxy), use plain chat only
Browse files- src/agent.js +2 -25
- src/inferenceClient.js +1 -5
src/agent.js
CHANGED
|
@@ -77,13 +77,7 @@ function systemPrompt() {
|
|
| 77 |
|
| 78 |
return [
|
| 79 |
`You are ${AGENT_NAME}, a sharp, direct AI assistant with a personality.`,
|
| 80 |
-
'Short sentences, no filler.
|
| 81 |
-
'For new capabilities, use propose_tool - the user must approve before it runs, so tell them, dont pretend it ran.',
|
| 82 |
-
'Dont repeat a failing tool call; a fix may already be queued.',
|
| 83 |
-
'Editing public/ takes effect on next page load. Backend edits need a Space restart which you should tell the user.',
|
| 84 |
-
'',
|
| 85 |
-
'Approved tools:',
|
| 86 |
-
toolSummary,
|
| 87 |
].join('\n');
|
| 88 |
}
|
| 89 |
|
|
@@ -199,10 +193,9 @@ function createAgent(io) {
|
|
| 199 |
setStatus('thinking');
|
| 200 |
const apiMessages = [{ role: 'system', content: systemPrompt() }, ...llmHistory];
|
| 201 |
|
| 202 |
-
const toolDefs = [...BUILTIN_TOOLS, PROPOSE_TOOL, ...toolManager.getApprovedToolDefs()];
|
| 203 |
let message;
|
| 204 |
try {
|
| 205 |
-
message = await inferenceClient.chat(apiMessages
|
| 206 |
} catch (err) {
|
| 207 |
setStatus('idle');
|
| 208 |
pushLog(makeLogEntry('assistant', { content: `I couldn't reach the Inference Port API: ${err.message}` }));
|
|
@@ -210,22 +203,6 @@ function createAgent(io) {
|
|
| 210 |
}
|
| 211 |
|
| 212 |
llmHistory.push(message);
|
| 213 |
-
|
| 214 |
-
if (message.tool_calls && message.tool_calls.length) {
|
| 215 |
-
if (message.content) {
|
| 216 |
-
pushLog(makeLogEntry('assistant', { content: message.content }));
|
| 217 |
-
}
|
| 218 |
-
for (const call of message.tool_calls) {
|
| 219 |
-
const output = await runToolCall(call);
|
| 220 |
-
llmHistory.push({
|
| 221 |
-
role: 'tool',
|
| 222 |
-
tool_call_id: call.id,
|
| 223 |
-
content: JSON.stringify(output),
|
| 224 |
-
});
|
| 225 |
-
}
|
| 226 |
-
continue;
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
setStatus('idle');
|
| 230 |
pushLog(makeLogEntry('assistant', { content: message.content || '...' }));
|
| 231 |
return;
|
|
|
|
| 77 |
|
| 78 |
return [
|
| 79 |
`You are ${AGENT_NAME}, a sharp, direct AI assistant with a personality.`,
|
| 80 |
+
'Short sentences, no filler.',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
].join('\n');
|
| 82 |
}
|
| 83 |
|
|
|
|
| 193 |
setStatus('thinking');
|
| 194 |
const apiMessages = [{ role: 'system', content: systemPrompt() }, ...llmHistory];
|
| 195 |
|
|
|
|
| 196 |
let message;
|
| 197 |
try {
|
| 198 |
+
message = await inferenceClient.chat(apiMessages);
|
| 199 |
} catch (err) {
|
| 200 |
setStatus('idle');
|
| 201 |
pushLog(makeLogEntry('assistant', { content: `I couldn't reach the Inference Port API: ${err.message}` }));
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
llmHistory.push(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
setStatus('idle');
|
| 207 |
pushLog(makeLogEntry('assistant', { content: message.content || '...' }));
|
| 208 |
return;
|
src/inferenceClient.js
CHANGED
|
@@ -27,15 +27,11 @@ if (!API_KEY) {
|
|
| 27 |
console.warn('[inferenceClient] INFERENCE_API_KEY is not set - chat requests will fail.');
|
| 28 |
}
|
| 29 |
|
| 30 |
-
async function chat(messages
|
| 31 |
const body = {
|
| 32 |
model: currentModel,
|
| 33 |
messages,
|
| 34 |
};
|
| 35 |
-
if (tools && tools.length) {
|
| 36 |
-
body.tools = tools;
|
| 37 |
-
body.tool_choice = 'auto';
|
| 38 |
-
}
|
| 39 |
|
| 40 |
let res;
|
| 41 |
try {
|
|
|
|
| 27 |
console.warn('[inferenceClient] INFERENCE_API_KEY is not set - chat requests will fail.');
|
| 28 |
}
|
| 29 |
|
| 30 |
+
async function chat(messages) {
|
| 31 |
const body = {
|
| 32 |
model: currentModel,
|
| 33 |
messages,
|
| 34 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
let res;
|
| 37 |
try {
|