code cleanup and test fix
This commit is contained in:
@@ -844,7 +844,6 @@ async function* streamSSEResponse(response, originalModel) {
|
|||||||
yield { type: 'message_stop' };
|
yield { type: 'message_stop' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List available models
|
* List available models
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -399,7 +399,6 @@ export function convertAnthropicToGoogle(anthropicRequest) {
|
|||||||
const isClaudeModel = modelName.toLowerCase().includes('claude');
|
const isClaudeModel = modelName.toLowerCase().includes('claude');
|
||||||
const isClaudeThinkingModel = isClaudeModel && modelName.toLowerCase().includes('thinking');
|
const isClaudeThinkingModel = isClaudeModel && modelName.toLowerCase().includes('thinking');
|
||||||
|
|
||||||
|
|
||||||
const googleRequest = {
|
const googleRequest = {
|
||||||
contents: [],
|
contents: [],
|
||||||
generationConfig: {}
|
generationConfig: {}
|
||||||
@@ -629,7 +628,6 @@ export function convertGoogleToAnthropic(googleResponse, model) {
|
|||||||
// Handle the response wrapper
|
// Handle the response wrapper
|
||||||
const response = googleResponse.response || googleResponse;
|
const response = googleResponse.response || googleResponse;
|
||||||
|
|
||||||
|
|
||||||
const candidates = response.candidates || [];
|
const candidates = response.candidates || [];
|
||||||
const firstCandidate = candidates[0] || {};
|
const firstCandidate = candidates[0] || {};
|
||||||
const content = firstCandidate.content || {};
|
const content = firstCandidate.content || {};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { TOKEN_REFRESH_INTERVAL_MS, ANTIGRAVITY_AUTH_PORT } from './constants.js
|
|||||||
|
|
||||||
// Cache for the extracted token
|
// Cache for the extracted token
|
||||||
let cachedToken = null;
|
let cachedToken = null;
|
||||||
let cachedConfig = null;
|
|
||||||
let tokenExtractedAt = null;
|
let tokenExtractedAt = null;
|
||||||
|
|
||||||
// Antigravity's SQLite database path
|
// Antigravity's SQLite database path
|
||||||
@@ -131,7 +130,6 @@ export async function getToken() {
|
|||||||
if (needsRefresh()) {
|
if (needsRefresh()) {
|
||||||
const data = await getTokenData();
|
const data = await getTokenData();
|
||||||
cachedToken = data.apiKey;
|
cachedToken = data.apiKey;
|
||||||
cachedConfig = data;
|
|
||||||
tokenExtractedAt = Date.now();
|
tokenExtractedAt = Date.now();
|
||||||
}
|
}
|
||||||
return cachedToken;
|
return cachedToken;
|
||||||
@@ -142,7 +140,6 @@ export async function getToken() {
|
|||||||
*/
|
*/
|
||||||
export async function forceRefresh() {
|
export async function forceRefresh() {
|
||||||
cachedToken = null;
|
cachedToken = null;
|
||||||
cachedConfig = null;
|
|
||||||
tokenExtractedAt = null;
|
tokenExtractedAt = null;
|
||||||
return getToken();
|
return getToken();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,25 +204,27 @@ async function runTests() {
|
|||||||
// ===== TURN 3: Final tool result and response =====
|
// ===== TURN 3: Final tool result and response =====
|
||||||
if (messages.length >= 4) {
|
if (messages.length >= 4) {
|
||||||
const lastAssistant = messages[messages.length - 1];
|
const lastAssistant = messages[messages.length - 1];
|
||||||
const toolUseBlock = lastAssistant.content?.find(b => b.type === 'tool_use');
|
const toolUseBlocks = lastAssistant.content?.filter(b => b.type === 'tool_use') || [];
|
||||||
|
|
||||||
if (toolUseBlock) {
|
if (toolUseBlocks.length > 0) {
|
||||||
console.log('\nTURN 3: Provide file content, expect final response');
|
console.log('\nTURN 3: Provide file content, expect final response');
|
||||||
console.log('-'.repeat(40));
|
console.log('-'.repeat(40));
|
||||||
|
|
||||||
|
// Provide tool_result for ALL tool_use blocks (API requires this)
|
||||||
|
const toolResults = toolUseBlocks.map((toolUseBlock, idx) => ({
|
||||||
|
type: 'tool_result',
|
||||||
|
tool_use_id: toolUseBlock.id,
|
||||||
|
content: JSON.stringify({
|
||||||
|
name: idx === 0 ? 'my-project' : 'core-package',
|
||||||
|
dependencies: idx === 0
|
||||||
|
? { express: '^4.18.2', cors: '^2.8.5' }
|
||||||
|
: { lodash: '^4.17.21' }
|
||||||
|
}, null, 2)
|
||||||
|
}));
|
||||||
|
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: [{
|
content: toolResults
|
||||||
type: 'tool_result',
|
|
||||||
tool_use_id: toolUseBlock.id,
|
|
||||||
content: JSON.stringify({
|
|
||||||
name: 'my-project',
|
|
||||||
dependencies: {
|
|
||||||
express: '^4.18.2',
|
|
||||||
cors: '^2.8.5'
|
|
||||||
}
|
|
||||||
}, null, 2)
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const turn3 = await makeRequest({
|
const turn3 = await makeRequest({
|
||||||
@@ -248,8 +250,10 @@ async function runTests() {
|
|||||||
console.log(` Response: "${analysis.text[0].text.substring(0, 100)}..."`);
|
console.log(` Response: "${analysis.text[0].text.substring(0, 100)}..."`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const passed = analysis.hasThinking && analysis.hasText;
|
// Thinking is optional for final responses - model may skip it for simple tasks
|
||||||
results.push({ name: 'Turn 3: Thinking + Text response', passed });
|
const passed = analysis.hasText;
|
||||||
|
const thinkingNote = analysis.hasThinking ? ' (with thinking)' : ' (no thinking - normal for simple tasks)';
|
||||||
|
results.push({ name: 'Turn 3: Text response' + thinkingNote, passed });
|
||||||
if (!passed) allPassed = false;
|
if (!passed) allPassed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user