diff --git a/.github/workflows/pr-chromatic-tests.yml b/.github/workflows/pr-chromatic-tests.yml index 1ebb75981..79de81da8 100644 --- a/.github/workflows/pr-chromatic-tests.yml +++ b/.github/workflows/pr-chromatic-tests.yml @@ -8,6 +8,8 @@ on: push env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + GEN_AI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + MOCK_LLM_RESPONSE: true jobs: playwright-tests: diff --git a/backend/onyx/configs/app_configs.py b/backend/onyx/configs/app_configs.py index d121d0517..67f106b00 100644 --- a/backend/onyx/configs/app_configs.py +++ b/backend/onyx/configs/app_configs.py @@ -617,3 +617,8 @@ POD_NAMESPACE = os.environ.get("POD_NAMESPACE") DEV_MODE = os.environ.get("DEV_MODE", "").lower() == "true" TEST_ENV = os.environ.get("TEST_ENV", "").lower() == "true" + +# Set to true to mock LLM responses for testing purposes +MOCK_LLM_RESPONSE = ( + os.environ.get("MOCK_LLM_RESPONSE") if os.environ.get("MOCK_LLM_RESPONSE") else None +) diff --git a/backend/onyx/llm/chat_llm.py b/backend/onyx/llm/chat_llm.py index 51afd02d6..589f83adf 100644 --- a/backend/onyx/llm/chat_llm.py +++ b/backend/onyx/llm/chat_llm.py @@ -26,6 +26,7 @@ from langchain_core.messages.tool import ToolMessage from langchain_core.prompt_values import PromptValue from onyx.configs.app_configs import LOG_DANSWER_MODEL_INTERACTIONS +from onyx.configs.app_configs import MOCK_LLM_RESPONSE from onyx.configs.model_configs import ( DISABLE_LITELLM_STREAMING, ) @@ -387,6 +388,7 @@ class DefaultMultiLLM(LLM): try: return litellm.completion( + mock_response=MOCK_LLM_RESPONSE, # model choice model=f"{self.config.model_provider}/{self.config.deployment_name or self.config.model_name}", # NOTE: have to pass in None instead of empty string for these diff --git a/backend/onyx/setup.py b/backend/onyx/setup.py index d7e3253cd..07c376664 100644 --- a/backend/onyx/setup.py +++ b/backend/onyx/setup.py @@ -37,6 +37,7 @@ from onyx.document_index.vespa.index import VespaIndex from onyx.indexing.models import IndexingSetting from onyx.key_value_store.factory import get_kv_store from onyx.key_value_store.interface import KvKeyNotFoundError +from onyx.llm.llm_provider_options import OPEN_AI_MODEL_NAMES from onyx.natural_language_processing.search_nlp_models import EmbeddingModel from onyx.natural_language_processing.search_nlp_models import warm_up_bi_encoder from onyx.natural_language_processing.search_nlp_models import warm_up_cross_encoder @@ -279,6 +280,7 @@ def setup_postgres(db_session: Session) -> None: if GEN_AI_API_KEY and fetch_default_provider(db_session) is None: # Only for dev flows logger.notice("Setting up default OpenAI LLM for dev.") + llm_model = GEN_AI_MODEL_VERSION or "gpt-4o-mini" fast_model = FAST_GEN_AI_MODEL_VERSION or "gpt-4o-mini" model_req = LLMProviderUpsertRequest( @@ -292,8 +294,8 @@ def setup_postgres(db_session: Session) -> None: fast_default_model_name=fast_model, is_public=True, groups=[], - display_model_names=[llm_model, fast_model], - model_names=[llm_model, fast_model], + display_model_names=OPEN_AI_MODEL_NAMES, + model_names=OPEN_AI_MODEL_NAMES, ) new_llm_provider = upsert_llm_provider( llm_provider=model_req, db_session=db_session diff --git a/backend/tests/unit/onyx/llm/test_chat_llm.py b/backend/tests/unit/onyx/llm/test_chat_llm.py index 50151febd..0e3620292 100644 --- a/backend/tests/unit/onyx/llm/test_chat_llm.py +++ b/backend/tests/unit/onyx/llm/test_chat_llm.py @@ -9,6 +9,7 @@ from litellm.types.utils import ChatCompletionDeltaToolCall from litellm.types.utils import Delta from litellm.types.utils import Function as LiteLLMFunction +from onyx.configs.app_configs import MOCK_LLM_RESPONSE from onyx.llm.chat_llm import DefaultMultiLLM @@ -143,6 +144,7 @@ def test_multiple_tool_calls(default_multi_llm: DefaultMultiLLM) -> None: temperature=0.0, # Default value from GEN_AI_TEMPERATURE timeout=30, parallel_tool_calls=False, + mock_response=MOCK_LLM_RESPONSE, ) @@ -287,4 +289,5 @@ def test_multiple_tool_calls_streaming(default_multi_llm: DefaultMultiLLM) -> No temperature=0.0, # Default value from GEN_AI_TEMPERATURE timeout=30, parallel_tool_calls=False, + mock_response=MOCK_LLM_RESPONSE, ) diff --git a/web/playwright.config.ts b/web/playwright.config.ts index 403871a9d..fb81b9ab8 100644 --- a/web/playwright.config.ts +++ b/web/playwright.config.ts @@ -2,12 +2,13 @@ import { defineConfig, devices } from "@playwright/test"; export default defineConfig({ globalSetup: require.resolve("./tests/e2e/global-setup"), - + timeout: 600000, // 10 minutes timeout projects: [ { name: "admin", use: { ...devices["Desktop Chrome"], + viewport: { width: 1280, height: 720 }, storageState: "admin_auth.json", }, testIgnore: ["**/codeUtils.test.ts"], diff --git a/web/src/app/admin/assistants/AssistantEditor.tsx b/web/src/app/admin/assistants/AssistantEditor.tsx index 190de914d..e3d394114 100644 --- a/web/src/app/admin/assistants/AssistantEditor.tsx +++ b/web/src/app/admin/assistants/AssistantEditor.tsx @@ -720,7 +720,6 @@ export function AssistantEditor({ name="description" label="Description" placeholder="Use this Assistant to help draft professional emails" - data-testid="assistant-description-input" className="[&_input]:placeholder:text-text-muted/50" /> diff --git a/web/src/app/chat/ChatIntro.tsx b/web/src/app/chat/ChatIntro.tsx index 87cfd2ac8..8e1807d3d 100644 --- a/web/src/app/chat/ChatIntro.tsx +++ b/web/src/app/chat/ChatIntro.tsx @@ -4,7 +4,7 @@ import { OnyxIcon } from "@/components/icons/icons"; export function ChatIntro({ selectedPersona }: { selectedPersona: Persona }) { return ( -