Skip to content

Commit

Permalink
Merge pull request #11 from Braffolk/dev
Browse files Browse the repository at this point in the history
Permission fixes and model updates
  • Loading branch information
Braffolk authored Jan 22, 2025
2 parents 695507d + e04e76a commit 9784a1c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ Thumbs.db
.env

build/
build/*
build/*
coverage/
coverage/*
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default {
],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
},
testTimeout: 10000,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcp-summarization-functions",
"version": "0.1.1",
"version": "0.1.2",
"description": "Provides summarised output from various actions that could otherwise eat up tokens and cause crashes",
"type": "module",
"main": "build/index.js",
Expand All @@ -10,6 +10,7 @@
"scripts": {
"preinstall": "node -e \"if (process.versions.node < '22.0.0') { console.error('Requires Node.js 22 or higher. Current version: ' + process.versions.node); process.exit(1); }\"",
"build": "tsc",
"postbuild": "node -e \"if (process.platform !== 'win32') { require('fs').chmodSync('build/index.js', '755'); }\"",
"start": "node build/index.js",
"watch": "tsc -w",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
Expand Down
15 changes: 8 additions & 7 deletions src/__tests__/models/claude.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mockSuccessResponse = {
// Import after mocking
import { AnthropicModel, createAnthropicModel } from '../../models/anthropic.js';
import { ModelConfig, SummarizationOptions } from '../../types/models.js';
import { constructPrompt, getBaseSummarizationInstructions } from '../../models/prompts.js';
import { constructPrompt, getBaseSummarizationInstructions, getFinalInstructions } from '../../models/prompts.js';

describe('AnthropicModel', () => {
const MOCK_API_KEY = 'dummy-key';
Expand Down Expand Up @@ -95,11 +95,12 @@ describe('AnthropicModel', () => {
it('should summarize content successfully', async () => {
const content = 'Test content';
const type = 'text';
const expectedPrompt = `${getBaseSummarizationInstructions(type)}
${content}
Summary:`;
const expectedPrompt = [
getBaseSummarizationInstructions(type),
...getFinalInstructions(),
content,
'Summary:'
].join('\n\n');

const summary = await model.summarize(content, type);

Expand All @@ -113,7 +114,7 @@ Summary:`;
'x-api-key': MOCK_API_KEY
},
body: JSON.stringify({
model: 'claude-3-5-sonnet-20241022',
model: 'claude-3-5-haiku-20241022',
max_tokens: 1024,
messages: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/models/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AnthropicModel implements SummarizationModel {
throw new Error('API key is required for Anthropic model');
}

const model = config.model || 'claude-3-5-sonnet-20241022';
const model = config.model || 'claude-3-5-haiku-20241022';
const maxTokens = config.maxTokens !== undefined ? config.maxTokens : 1024;

// Validate model name
Expand Down
2 changes: 1 addition & 1 deletion src/models/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GeminiModel implements SummarizationModel {
throw new Error('API key is required for Gemini model');
}

const model = config.model || 'gemini-pro';
const model = config.model || 'gemini-1.5-flash';
const maxTokens = config.maxTokens !== undefined ? config.maxTokens : 1024;

// Validate model name
Expand Down
2 changes: 1 addition & 1 deletion src/models/openai-compatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class OpenAICompatible implements SummarizationModel {
throw new Error('API key is required for OpenAI compatible models');
}

const model = config.model;
const model = config.model || 'gpt-4o-mini';
const maxTokens = config.maxTokens !== undefined ? config.maxTokens : 1024;

// Validate model name
Expand Down
8 changes: 5 additions & 3 deletions src/models/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ export function getBaseSummarizationInstructions(type: string): string {
return `Summarize the following ${type} in a clear, concise way that would be useful for an AI agent. Focus on the most important information and maintain technical accuracy. Always keep your summary shorter than 4096 tokens.`;
}

export function getFinalInstructions(): string[] {
return ["Please do not include any commentary, questions or text other than the relevant summary itself."];
}

/**
* Combines all instructions into a complete prompt
*/
function constructFullInstructions(type: string, options?: SummarizationOptions): string {
const baseInstructions = getBaseSummarizationInstructions(type);
const hintInstructions = getHintInstructions(options?.hint);
const formatInstructions = getFormatInstructions(options?.output_format);
const finalInstructions = [
"Please do not include any commentary, questions or text other than the relevant summary itself."
];
const finalInstructions = getFinalInstructions();

return [
baseInstructions,
Expand Down

0 comments on commit 9784a1c

Please sign in to comment.