minchyeom commited on
Commit
cab015a
·
1 Parent(s): a99a8f0

Remove unused CLI application files and documentation

Browse files
cli_app/README.md DELETED
@@ -1,31 +0,0 @@
1
- # Windows CLI Application
2
-
3
- This folder contains a standalone command line interface for interacting with
4
- `llm-backend`. The application uses [Typer](https://typer.tiangolo.com/) for a
5
- simple user experience and can be packaged into a single Windows executable
6
- using [PyInstaller](https://www.pyinstaller.org/).
7
-
8
- ## Running from source
9
-
10
- ```bash
11
- python -m cli_app --user yourname
12
- ```
13
-
14
- ## Building the executable
15
-
16
- 1. Install PyInstaller:
17
-
18
- ```bash
19
- pip install pyinstaller
20
- ```
21
-
22
- 2. Build the app:
23
-
24
- ```bash
25
- pyinstaller --onefile -n StarletteAI cli_app/main.py
26
- ```
27
-
28
- The resulting `StarletteAI.exe` will appear in the `dist` directory.
29
-
30
- The executable can be distributed on Windows 10/11 systems without requiring a
31
- Python installation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cli_app/__init__.py DELETED
File without changes
cli_app/__main__.py DELETED
@@ -1,4 +0,0 @@
1
- from .main import app
2
-
3
- if __name__ == "__main__":
4
- app()
 
 
 
 
 
cli_app/main.py DELETED
@@ -1,88 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import asyncio
4
- from typing import AsyncIterator, List, Dict
5
-
6
- import httpx
7
- import typer
8
- from colorama import Fore, Style, init
9
-
10
- API_URL = "http://localhost:8000"
11
-
12
- app = typer.Typer(add_completion=False, help="Chat with the LLM backend API")
13
-
14
-
15
- async def _get_sessions_info(user: str, server: str) -> List[Dict[str, str]]:
16
- async with httpx.AsyncClient(base_url=server) as client:
17
- resp = await client.get(f"/sessions/{user}/info")
18
- if resp.status_code == 404:
19
- # Fallback to basic list for older API versions
20
- resp = await client.get(f"/sessions/{user}")
21
- resp.raise_for_status()
22
- names = resp.json().get("sessions", [])
23
- return [{"name": n, "last_message": ""} for n in names]
24
- resp.raise_for_status()
25
- return resp.json().get("sessions", [])
26
-
27
-
28
- async def _stream_chat(
29
- user: str, session: str, prompt: str, server: str
30
- ) -> AsyncIterator[str]:
31
- async with httpx.AsyncClient(base_url=server, timeout=None) as client:
32
- async with client.stream(
33
- "POST",
34
- "/chat/stream",
35
- json={"user": user, "session": session, "prompt": prompt},
36
- ) as resp:
37
- resp.raise_for_status()
38
- async for line in resp.aiter_lines():
39
- if line:
40
- yield line
41
-
42
-
43
- async def _chat_loop(user: str, server: str) -> None:
44
- init(autoreset=True)
45
- sessions = await _get_sessions_info(user, server)
46
- session = "default"
47
- if sessions:
48
- typer.echo("Existing sessions:")
49
- for idx, info in enumerate(sessions, 1):
50
- snippet = f" - {info['last_message'][:40]}" if info.get("last_message") else ""
51
- typer.echo(f" {idx}. {info['name']}{snippet}")
52
- choice = typer.prompt(
53
- "Select session number or enter new name", default=str(len(sessions))
54
- )
55
- if choice.isdigit() and 1 <= int(choice) <= len(sessions):
56
- session = sessions[int(choice) - 1]["name"]
57
- else:
58
- session = choice.strip() or session
59
- else:
60
- session = typer.prompt("Session name", default=session)
61
-
62
- typer.echo(
63
- f"Chatting as {Fore.GREEN}{user}{Style.RESET_ALL} in session '{session}'"
64
- )
65
-
66
- while True:
67
- try:
68
- msg = typer.prompt(f"{Fore.CYAN}You{Style.RESET_ALL}")
69
- except EOFError:
70
- break
71
- if msg.strip().lower() in {"exit", "quit"}:
72
- break
73
- async for part in _stream_chat(user, session, msg, server):
74
- typer.echo(f"{Fore.YELLOW}{part}{Style.RESET_ALL}")
75
-
76
-
77
- @app.callback(invoke_without_command=True)
78
- def main(
79
- user: str = typer.Option("default", "--user", "-u"),
80
- server: str = typer.Option(API_URL, "--server", "-s"),
81
- ) -> None:
82
- """Start an interactive chat session."""
83
-
84
- asyncio.run(_chat_loop(user, server))
85
-
86
-
87
- if __name__ == "__main__": # pragma: no cover - manual execution
88
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
sample/note.pdf DELETED
Binary file (71.1 kB)
 
sample/test.txt DELETED
@@ -1,4 +0,0 @@
1
- This is a test file.
2
- Blah blah blah.
3
- Hello, world!
4
- Python is awesome!