Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (50 loc) · 1.69 KB
/
Copy pathmain.py
File metadata and controls
63 lines (50 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Run the devReflections CLI journaling workflow."""
from ollama import ResponseError
from dev_reflections.journal import (
choose_starter_prompt,
generate_question,
save_entry,
)
def main(): # pylint: disable=too-many-return-statements
"""Collect a journal entry, reflect with AI, and save the result."""
print("Welcome to devReflections!\n")
starter_prompt = choose_starter_prompt()
if starter_prompt == "":
return
if starter_prompt:
print(f"\nStarter prompt: {starter_prompt}")
entry = input("\nWrite your journal entry:\n").strip()
if not entry:
print("Journal entry cannot be empty. Please try again.")
return
try:
print("\nThinking...\n")
question = generate_question(entry)
except ResponseError as error:
print(f"Could not generate a reflection question: {error}")
return
except ConnectionError:
print("Could not connect to Ollama. Make sure Ollama is running.")
return
except (FileNotFoundError, ValueError) as error:
print(f"An error occurred: {error}")
return
print(f"Reflection question: {question}\n")
answer = input("Your answer:\n").strip()
if not answer:
print("Answer cannot be empty. Please try again.")
return
try:
file_path = save_entry(
entry,
question,
answer,
starter_prompt=starter_prompt,
)
print(f"\nYour reflection has been saved to {file_path}.")
except OSError as error:
print(f"Could not save your entry: {error}")
return
print("Thank you for reflecting and growing.")
if __name__ == "__main__":
main()