Skip to content

Commit

Permalink
✨ project template
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Sep 29, 2023
1 parent 8812fcd commit 2d7fce4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions llm_term/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
LLM CLI
"""

from typing import Optional, Tuple
from __future__ import annotations

import click
import rich.traceback
Expand Down Expand Up @@ -85,8 +85,8 @@
)
def cli(
model: str,
chat: Tuple[str, ...],
system: Optional[str],
chat: tuple[str, ...],
system: str | None,
api_key: str,
stream: bool,
console: int,
Expand Down
10 changes: 6 additions & 4 deletions llm_term/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Helper functions for the CLI
"""

from __future__ import annotations

from datetime import datetime, timezone
from pathlib import Path
from textwrap import dedent
from typing import Any, Dict, Generator, List, Optional
from typing import Any, Generator

import click
import openai
Expand Down Expand Up @@ -54,7 +56,7 @@ def check_credentials(api_key: str) -> None:
raise click.ClickException(msg)


def setup_system_message(model: str, message: Optional[str] = None) -> Message:
def setup_system_message(model: str, message: str | None = None) -> Message:
"""
Set up the system message
"""
Expand Down Expand Up @@ -86,7 +88,7 @@ def chat_session(
history_file = Path().home() / ".llm-term-history.txt"
history = FileHistory(str(history_file))
session: PromptSession = PromptSession(history=history, erase_when_done=True)
messages: List[Message] = [system_message]
messages: list[Message] = [system_message]
if chat_message.strip() != "":
messages.append(Message(role="user", content=chat_message))
message_counter = 0
Expand Down Expand Up @@ -142,7 +144,7 @@ def print_response(


def render_streamed_response(
response: Generator[Dict[str, Any], None, None], console: Console, panel: bool
response: Generator[dict[str, Any], None, None], console: Console, panel: bool
) -> Message:
"""
Render the streamed response and a spinner
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ select = [
"YTT"
]
target-version = "py38"
unfixable = [
# Don't touch unused imports
"F401"
]

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all"
Expand Down

0 comments on commit 2d7fce4

Please sign in to comment.