Skip to content

Commit e93e3e8

Browse files
authored
cli: store prompt and config under ~/.pydantic-ai (#1701)
1 parent e7ce675 commit e93e3e8

File tree

1 file changed

+10
-2
lines changed
  • pydantic_ai_slim/pydantic_ai

1 file changed

+10
-2
lines changed

pydantic_ai_slim/pydantic_ai/_cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
__all__ = 'cli', 'cli_exit'
4343

4444

45+
PYDANTIC_AI_HOME = Path.home() / '.pydantic-ai'
46+
"""The home directory for PydanticAI CLI.
47+
48+
This folder is used to store the prompt history and configuration.
49+
"""
50+
51+
PROMPT_HISTORY_PATH = PYDANTIC_AI_HOME / 'prompt-history.txt'
52+
53+
4554
class SimpleCodeBlock(CodeBlock):
4655
"""Customised code blocks in markdown.
4756
@@ -167,9 +176,8 @@ def cli(args_list: Sequence[str] | None = None, *, prog_name: str = 'pai') -> in
167176
pass
168177
return 0
169178

170-
history = Path.home() / f'.{prog_name}-prompt-history.txt'
171179
# doing this instead of `PromptSession[Any](history=` allows mocking of PromptSession in tests
172-
session: PromptSession[Any] = PromptSession(history=FileHistory(str(history)))
180+
session: PromptSession[Any] = PromptSession(history=FileHistory(str(PROMPT_HISTORY_PATH)))
173181
try:
174182
return asyncio.run(run_chat(session, stream, cli_agent, console, code_theme, prog_name))
175183
except KeyboardInterrupt: # pragma: no cover

0 commit comments

Comments
 (0)