Skip to content

Commit

Permalink
Merge pull request #58 from langtail/remove-assistant-param
Browse files Browse the repository at this point in the history
remove needless assistant:true param from assistant call
  • Loading branch information
vojtatranta authored Sep 6, 2024
2 parents c38e436 + f15648a commit 82c0dad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
27 changes: 4 additions & 23 deletions src/LangtailAssistants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe("LangtailAssistants", () => {

expect(promptsMock.invoke).toHaveBeenCalledWith(
expect.objectContaining({
assistant: true,
prompt: assistant,
})
);
Expand Down Expand Up @@ -91,7 +90,6 @@ describe("LangtailAssistants", () => {
});

expect(promptsMock.invoke).toHaveBeenCalledWith({
assistant: true,
prompt: assistant,
messages,
});
Expand All @@ -109,34 +107,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,
})
);
});

})
})
5 changes: 2 additions & 3 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 82c0dad

Please sign in to comment.