usage-instructions #8
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "llm-chat"
|
name = "llm-chat"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
description = "A general CLI interface for large language models."
|
description = "A general CLI interface for large language models."
|
||||||
authors = ["Paul Harrison <paul@harrison.sh>"]
|
authors = ["Paul Harrison <paul@harrison.sh>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from pydantic import field_validator
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ class Model(StrEnum):
|
||||||
|
|
||||||
DEFAULT_MODEL = Model.GPT3
|
DEFAULT_MODEL = Model.GPT3
|
||||||
DEFAULT_TEMPERATURE = 0.7
|
DEFAULT_TEMPERATURE = 0.7
|
||||||
DEFAULT_HISTORY_DIR = Path().absolute() / ".history"
|
DEFAULT_HISTORY_DIR = Path.home() / ".llm_chat"
|
||||||
|
|
||||||
|
|
||||||
class OpenAISettings(BaseSettings):
|
class OpenAISettings(BaseSettings):
|
||||||
|
@ -31,3 +32,10 @@ class OpenAISettings(BaseSettings):
|
||||||
frozen=True,
|
frozen=True,
|
||||||
use_enum_values=True,
|
use_enum_values=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@field_validator("history_dir")
|
||||||
|
def history_dir_must_exist(cls, history_dir: Path) -> Path:
|
||||||
|
"""Ensure that the history directory exists."""
|
||||||
|
if not history_dir.exists():
|
||||||
|
history_dir.mkdir(parents=True)
|
||||||
|
return history_dir
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -7,3 +8,9 @@ import pytest
|
||||||
def mock_openai_api_key() -> None:
|
def mock_openai_api_key() -> None:
|
||||||
"""Set a fake OpenAI API key."""
|
"""Set a fake OpenAI API key."""
|
||||||
os.environ["OPENAI_API_KEY"] = "dummy_key"
|
os.environ["OPENAI_API_KEY"] = "dummy_key"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def mock_history_dir(tmp_path: Path) -> None:
|
||||||
|
"""Set a fake history directory."""
|
||||||
|
os.environ["OPENAI_HISTORY_DIR"] = str(tmp_path / ".llm_chat")
|
||||||
|
|
Loading…
Reference in New Issue