Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/embed_papers/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _get_client(self) -> Any:
key = self.resolved_api_key
if not key:
raise CacheMissRequiresApiKeyError(
"Embeddings cache not found. Set OPENAI_API_KEY (or pass api_key) to create conference cache."
"OpenAI API key required to compute embeddings. Set OPENAI_API_KEY (or pass api_key)."
)

from openai import OpenAI
Expand Down Expand Up @@ -309,7 +309,7 @@ def compute_embeddings(self, force: bool = False) -> np.ndarray:

if self.require_api_key_on_cache_miss and not self.resolved_api_key:
raise CacheMissRequiresApiKeyError(
"No cache for this venue/model and no API key found. Set OPENAI_API_KEY to build cache."
"No cached embeddings for this venue/model and no API key found. Set OPENAI_API_KEY to build cache."
)

_log(f"Computing embeddings ({self.model_name})...")
Expand Down
7 changes: 7 additions & 0 deletions src/embed_papers/viewer/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import os
from html import escape
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -337,6 +338,12 @@ def _render_sidebar_form() -> dict[str, Any] | None:
st.error("Upload a valid examples JSON file before running search.")
return None

if not os.getenv("OPENAI_API_KEY"):
st.error(
"OPENAI_API_KEY is required to embed queries/examples. Set it in your shell and restart the app."
)
return None

return {
"conference": conference,
"year": int(year),
Expand Down