nsthorat commited on
Commit
e1173b9
1 Parent(s): 3a45a01
Dockerfile CHANGED
@@ -9,6 +9,7 @@ RUN useradd -m -u 1000 user
9
  USER user
10
  ENV HOME=/home/user \
11
  PATH=/home/user/.local/bin:$PATH
 
12
  # Set the working directory in the container.
13
  WORKDIR $HOME/app
14
 
 
9
  USER user
10
  ENV HOME=/home/user \
11
  PATH=/home/user/.local/bin:$PATH
12
+
13
  # Set the working directory in the container.
14
  WORKDIR $HOME/app
15
 
data/.cache/lilac/concept/lilac/negative-sentiment/gte-small.pkl DELETED
Binary file (202 kB)
 
data/.cache/lilac/concept/lilac/non-english/gte-small.pkl DELETED
Binary file (331 kB)
 
data/.cache/lilac/concept/lilac/source-code/gte-small.pkl DELETED
Binary file (126 kB)
 
lilac/__init__.py CHANGED
@@ -8,6 +8,8 @@ from .data_loader import create_dataset
8
  from .db_manager import get_dataset, set_default_dataset_cls
9
  from .embeddings import * # noqa: F403
10
  from .embeddings.default_vector_stores import register_default_vector_stores
 
 
11
  from .schema import * # noqa: F403
12
  from .server import start_server, stop_server
13
  from .signals import * # noqa: F403
@@ -39,4 +41,5 @@ __all__ = [
39
  'EmbeddingConfig',
40
  'SignalConfig',
41
  'DatasetSettings',
 
42
  ]
 
8
  from .db_manager import get_dataset, set_default_dataset_cls
9
  from .embeddings import * # noqa: F403
10
  from .embeddings.default_vector_stores import register_default_vector_stores
11
+ from .env import * # noqa: F403
12
+ from .env import LilacEnvironment
13
  from .schema import * # noqa: F403
14
  from .server import start_server, stop_server
15
  from .signals import * # noqa: F403
 
41
  'EmbeddingConfig',
42
  'SignalConfig',
43
  'DatasetSettings',
44
+ 'LilacEnvironment',
45
  ]
lilac/env.py CHANGED
@@ -1,25 +1,64 @@
1
  """Load environment variables from .env file."""
2
  import os
3
- from typing import Any, Literal, Optional, Union, cast
4
 
5
  from dotenv import load_dotenv
 
 
6
 
7
- EnvironmentKeys = Union[Literal['LILAC_DATA_PATH'],
8
- # Authentication on the demo.
9
- Literal['LILAC_AUTH_ENABLED'], Literal['GOOGLE_CLIENT_ID'],
10
- Literal['GOOGLE_CLIENT_SECRET'], Literal['LILAC_OAUTH_SECRET_KEY'],
11
- # DuckDB accessing GCS.
12
- Literal['GCS_REGION'], Literal['GCS_ACCESS_KEY'], Literal['GCS_SECRET_KEY'],
13
- # Embedding API keys.
14
- Literal['OPENAI_API_KEY'], Literal['COHERE_API_KEY'],
15
- Literal['PALM_API_KEY'],
16
- # HuggingFace demos.
17
- Literal['HF_USERNAME'], Literal['HF_STAGING_DEMO_REPO'],
18
- Literal['SPACE_ID'], Literal['HF_ACCESS_TOKEN'],
19
- # DuckDB
20
- Literal['DUCKDB_USE_VIEWS'],
21
- # Debugging
22
- Literal['DEBUG'], Literal['DISABLE_LOGS']]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
 
25
  def _init_env() -> None:
@@ -50,7 +89,7 @@ def _init_env() -> None:
50
  raise ValueError('Missing `LILAC_OAUTH_SECRET_KEY` when `LILAC_AUTH_ENABLED=true`')
51
 
52
 
53
- def env(key: EnvironmentKeys, default: Optional[Any] = None) -> Any:
54
  """Return the value of an environment variable."""
55
  return os.environ.get(key, default)
56
 
 
1
  """Load environment variables from .env file."""
2
  import os
3
+ from typing import Any, Optional, cast
4
 
5
  from dotenv import load_dotenv
6
+ from pydantic import BaseModel
7
+ from pydantic import Field as PydanticField
8
 
9
+
10
+ # NOTE: This is created for documentation, but isn't parsed by pydantic until we update to 2.0.
11
+ class LilacEnvironment(BaseModel):
12
+ """Lilac environment variables.
13
+
14
+ These can be set with operating system environment variables to override behavior.
15
+
16
+ For python, see: https://docs.python.org/3/library/os.html#os.environ
17
+
18
+ For bash, see: https://www.gnu.org/software/bash/manual/bash.html#Environment
19
+ """
20
+ # General Lilac environment variables.
21
+ LILAC_DATA_PATH: str = PydanticField(
22
+ description='The Lilac data path where datasets, concepts, caches are stored.',)
23
+ DEBUG: str = PydanticField(
24
+ description='Turn on Lilac debug mode to log queries and timing information.')
25
+ DISABLE_LOGS: str = PydanticField(description='Disable log() statements to the console.')
26
+
27
+ # API Keys.
28
+ OPENAI_API_KEY: str = PydanticField(
29
+ description='The OpenAI API key, used for computing `openai` embeddings and generating positive '
30
+ 'examples for concept seeding.')
31
+ COHERE_API_KEY: str = PydanticField(
32
+ description='The Cohere API key, used for computing `cohere` embeddings.')
33
+ PALM_API_KEY: str = PydanticField(
34
+ description='The PaLM API key, used for computing `palm` embeddings.')
35
+
36
+ # HuggingFace demo.
37
+ HF_ACCESS_TOKEN: str = PydanticField(
38
+ description='The HuggingFace access token, used for downloading data to a space from a '
39
+ 'private dataset. This is also required if the HuggingFace space is private.')
40
+
41
+ # DuckDB.
42
+ DUCKDB_USE_VIEWS: str = PydanticField(
43
+ description='Whether DuckDB uses views (1), or DuckDB tables (0). Views allow for much less '
44
+ 'RAM consumption, with a runtime query penalty. When using DuckDB tables (0), demos will '
45
+ 'take more RAM but be much faster during query time.')
46
+
47
+ # Authentication.
48
+ LILAC_AUTH_ENABLED: str = PydanticField(
49
+ description='Set to true to enable read-only mode, disabling the ability to add datasets & '
50
+ 'compute dataset signals. When enabled, `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` and '
51
+ '`LILAC_OAUTH_SECRET_KEY` should also be set.')
52
+ GOOGLE_CLIENT_ID: str = PydanticField(
53
+ description=
54
+ 'The Google OAuth client ID. Required when `LILAC_AUTH_ENABLED=true`. Details can be found at '
55
+ 'https://developers.google.com/identity/protocols/oauth2.')
56
+ GOOGLE_CLIENT_SECRET: str = PydanticField(
57
+ description='The Google OAuth client secret. Details can be found at '
58
+ 'https://developers.google.com/identity/protocols/oauth2.')
59
+ LILAC_OAUTH_SECRET_KEY: str = PydanticField(
60
+ description='The Google OAuth random secret key. Details can be found at '
61
+ 'https://developers.google.com/identity/protocols/oauth2.')
62
 
63
 
64
  def _init_env() -> None:
 
89
  raise ValueError('Missing `LILAC_OAUTH_SECRET_KEY` when `LILAC_AUTH_ENABLED=true`')
90
 
91
 
92
+ def env(key: str, default: Optional[Any] = None) -> Any:
93
  """Return the value of an environment variable."""
94
  return os.environ.get(key, default)
95