Skip to content

Commit

Permalink
remove needless assistant:true param from assistant call
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtatranta committed Sep 6, 2024
1 parent c38e436 commit 16e65eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
23 changes: 3 additions & 20 deletions src/LangtailAssistants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,34 +109,17 @@ describe("LangtailAssistants", () => {
});
})

it("should pass assistant: true by default to langtailPrompts.invoke call", async () => {
it("should not pass assistant: true to langtailPrompts.invoke call", async () => {
const { lt, promptsMock } = createLt();
const assistant = "test-assistant";

await lt.invoke({ assistant });

expect(promptsMock.invoke).toHaveBeenCalledWith(
expect.objectContaining({
expect.not.objectContaining({
assistant: true,
prompt: "test-assistant",
})
);
expect(promptsMock.invoke.mock.calls[0][0]).not.toHaveProperty('assistant');
});

it("should pass threadId to langtailPrompts.invoke call when provided", async () => {
const { lt, promptsMock } = createLt();
const assistant = "test-assistant";
const threadId = "test-thread-id";

await lt.invoke({ assistant, threadId });

expect(promptsMock.invoke).toHaveBeenCalledWith(
expect.objectContaining({
assistant: true,
prompt: assistant,
threadId: threadId,
})
);
});

})
3 changes: 1 addition & 2 deletions src/LangtailAssistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ export class LangtailAssistants {
this.langtailPrompts = langtailPrompts
}

invoke<P extends PromptSlug, E extends Environment<P> = undefined, V extends Version<P, E> = undefined, S extends boolean = false>(options: Omit<IRequestParamsStream<P, E, V, S>, "prompt" | "assistant"> & {
invoke<P extends PromptSlug, E extends Environment<P> = undefined, V extends Version<P, E> = undefined, S extends boolean = false>(options: Omit<IRequestParamsStream<P, E, V, S>, "prompt"> & {
assistant: P
}): Promise<S extends true ? StreamResponseType : OpenAIResponseWithHttp> {
const { assistant, ...rest } = options
return this.langtailPrompts.invoke<P, E, V, S>({
...rest,
prompt: assistant,
assistant: true,
})
}
}
1 change: 0 additions & 1 deletion src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
export interface ILangtailExtraProps {
doNotRecord?: boolean
threadId?: string
assistant?: boolean
metadata?: Record<string, any>
}

Expand Down

0 comments on commit 16e65eb

Please sign in to comment.