Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/core/src/pipes/pipes.issue-155.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {describe, expect, it, vi} from 'vitest';
import {Pipe, type RunResponse} from './pipes';

describe('Pipe without tools', () => {
it('runs when the pipe omits the optional tools array', async () => {
const pipe = new Pipe({
apiKey: 'test-api-key',
model: 'openai:gpt-4o-mini',
name: 'without-tools',
prod: true,
tools: undefined,
} as any);
const response: RunResponse = {
completion: 'done',
id: 'response-id',
object: 'chat.completion',
created: 0,
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: {role: 'assistant', content: 'done'},
logprobs: null,
finish_reason: 'stop',
},
],
usage: {prompt_tokens: 1, completion_tokens: 1, total_tokens: 2},
system_fingerprint: null,
};
const post = vi.fn().mockResolvedValue(response);
(pipe as any).request = {post};

await expect(pipe.run({messages: []})).resolves.toEqual(response);
expect(post).toHaveBeenCalledOnce();
});
});
2 changes: 1 addition & 1 deletion packages/core/src/pipes/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class Pipe {
const providerString = this.pipe.model.split(':')[0];
const modelProvider = getProvider(providerString);
const isAnthropic = modelProvider === ANTHROPIC;
const hasTools = this.pipe.tools.length > 0;
const hasTools = this.hasTools;

// For SDK
// Run the given pipe name
Expand Down