Skip to content
Snippets Groups Projects
Commit c8194693 authored by Marcus Schiesser's avatar Marcus Schiesser
Browse files

test: fix openai mock

parent 1008b775
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,14 @@ import {
type StorageContext,
} from "llamaindex";
import { rmSync } from "node:fs";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
vi.mock("llamaindex/llm/open_ai", () => {
return {
getOpenAISession: vi.fn().mockImplementation(() => null),
};
});
import { mockServiceContext } from "../utility/mockServiceContext.js";
describe("SummaryIndex", () => {
......
......@@ -4,9 +4,15 @@ import {
VectorStoreIndex,
storageContextFromDefaults,
} from "llamaindex";
import { beforeAll, describe, expect, test } from "vitest";
import { beforeAll, describe, expect, test, vi } from "vitest";
import { mockServiceContext } from "../utility/mockServiceContext.js";
vi.mock("llamaindex/llm/open_ai", () => {
return {
getOpenAISession: vi.fn().mockImplementation(() => null),
};
});
describe.sequential("VectorStoreIndex", () => {
let serviceContext: ServiceContext;
let storageContext: StorageContext;
......
......@@ -5,7 +5,14 @@ import {
SimpleToolNodeMapping,
VectorStoreIndex,
} from "llamaindex";
import { beforeAll, describe, expect, test } from "vitest";
import { beforeAll, describe, expect, test, vi } from "vitest";
vi.mock("llamaindex/llm/open_ai", () => {
return {
getOpenAISession: vi.fn().mockImplementation(() => null),
};
});
import { mockServiceContext } from "../utility/mockServiceContext.js";
describe("ObjectIndex", () => {
......
......@@ -9,15 +9,6 @@ import {
mockLlmGeneration,
} from "../utility/mockOpenAI.js";
import { vi } from "vitest";
// Mock the OpenAI getOpenAISession function during testing
vi.mock("llamaindex/llm/open_ai", () => {
return {
getOpenAISession: vi.fn().mockImplementation(() => null),
};
});
export function mockServiceContext() {
const embeddingModel = new OpenAIEmbedding();
const llm = new OpenAI();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment