Compare commits
No commits in common. "76bee1aed99c2033ad162b6d2a2373ddbfa485ef" and "b859c8bb953952b788bc72531da75616d0e24aff" have entirely different histories.
76bee1aed9
...
b859c8bb95
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "llm-chat"
|
name = "llm-chat"
|
||||||
version = "1.1.5"
|
version = "1.1.3"
|
||||||
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"
|
||||||
|
|
|
@ -8,7 +8,13 @@ from rich.markdown import Markdown
|
||||||
|
|
||||||
from llm_chat.chat import ChatProtocol, get_chat, get_chat_class
|
from llm_chat.chat import ChatProtocol, get_chat, get_chat_class
|
||||||
from llm_chat.models import Message, Role
|
from llm_chat.models import Message, Role
|
||||||
from llm_chat.settings import Model, OpenAISettings
|
from llm_chat.settings import (
|
||||||
|
DEFAULT_HISTORY_DIR,
|
||||||
|
DEFAULT_MODEL,
|
||||||
|
DEFAULT_TEMPERATURE,
|
||||||
|
Model,
|
||||||
|
OpenAISettings,
|
||||||
|
)
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
||||||
|
@ -100,15 +106,15 @@ def chat(
|
||||||
),
|
),
|
||||||
] = None,
|
] = None,
|
||||||
model: Annotated[
|
model: Annotated[
|
||||||
Optional[Model],
|
Model,
|
||||||
typer.Option(..., "--model", "-m", help="Model to use.", show_choices=True),
|
typer.Option(..., "--model", "-m", help="Model to use.", show_choices=True),
|
||||||
] = None,
|
] = DEFAULT_MODEL,
|
||||||
temperature: Annotated[
|
temperature: Annotated[
|
||||||
Optional[float],
|
float,
|
||||||
typer.Option(
|
typer.Option(
|
||||||
..., "--temperature", "-t", help="Model temperature (i.e. creativeness)."
|
..., "--temperature", "-t", help="Model temperature (i.e. creativeness)."
|
||||||
),
|
),
|
||||||
] = None,
|
] = DEFAULT_TEMPERATURE,
|
||||||
context: Annotated[
|
context: Annotated[
|
||||||
list[Path],
|
list[Path],
|
||||||
typer.Option(
|
typer.Option(
|
||||||
|
@ -126,14 +132,17 @@ def chat(
|
||||||
),
|
),
|
||||||
] = [],
|
] = [],
|
||||||
history_dir: Annotated[
|
history_dir: Annotated[
|
||||||
Optional[Path],
|
Path,
|
||||||
typer.Option(
|
typer.Option(
|
||||||
...,
|
...,
|
||||||
"--history-dir",
|
"--history-dir",
|
||||||
"-d",
|
"-d",
|
||||||
help="Path to the directory where conversation history will be saved.",
|
help="Path to the directory where conversation history will be saved.",
|
||||||
|
exists=True,
|
||||||
|
dir_okay=True,
|
||||||
|
file_okay=False,
|
||||||
),
|
),
|
||||||
] = None,
|
] = DEFAULT_HISTORY_DIR,
|
||||||
name: Annotated[
|
name: Annotated[
|
||||||
str,
|
str,
|
||||||
typer.Option(
|
typer.Option(
|
||||||
|
@ -146,16 +155,17 @@ def chat(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Start a chat session."""
|
"""Start a chat session."""
|
||||||
# TODO: Add option to provide context string as an argument.
|
# TODO: Add option to provide context string as an argument.
|
||||||
args: dict[str, Any] = {}
|
|
||||||
if api_key is not None:
|
if api_key is not None:
|
||||||
args |= {"api_key": api_key}
|
settings = OpenAISettings(
|
||||||
if model is not None:
|
api_key=api_key,
|
||||||
args |= {"model": model}
|
model=model,
|
||||||
if temperature is not None:
|
temperature=temperature,
|
||||||
args |= {"temperature": temperature}
|
history_dir=history_dir,
|
||||||
if history_dir is not None:
|
)
|
||||||
args |= {"history_dir": history_dir}
|
else:
|
||||||
settings = OpenAISettings(**args)
|
settings = OpenAISettings(
|
||||||
|
model=model, temperature=temperature, history_dir=history_dir
|
||||||
|
)
|
||||||
|
|
||||||
context_messages = [load_context(path) for path in context]
|
context_messages = [load_context(path) for path in context]
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Model(StrEnum):
|
||||||
|
|
||||||
DEFAULT_MODEL = Model.GPT3
|
DEFAULT_MODEL = Model.GPT3
|
||||||
DEFAULT_TEMPERATURE = 0.7
|
DEFAULT_TEMPERATURE = 0.7
|
||||||
DEFAULT_HISTORY_DIR = Path.home() / ".llm_chat" / "history"
|
DEFAULT_HISTORY_DIR = Path.home() / ".llm_chat"
|
||||||
|
|
||||||
|
|
||||||
class OpenAISettings(BaseSettings):
|
class OpenAISettings(BaseSettings):
|
||||||
|
|
Loading…
Reference in New Issue