15
15
from .__version__ import __version__
16
16
from .config import get_config , get_project_config
17
17
from .dirs import get_project_git_dir
18
+ from .llm .models import get_model
18
19
from .message import Message
19
20
from .tools import ToolFormat
20
21
from .util import document_prompt_function
@@ -28,13 +29,14 @@ def get_prompt(
28
29
prompt : PromptType | str = "full" ,
29
30
interactive : bool = True ,
30
31
tool_format : ToolFormat = "markdown" ,
32
+ model : str | None = None ,
31
33
) -> Message :
32
34
"""
33
35
Get the initial system prompt.
34
36
"""
35
37
msgs : Iterable
36
38
if prompt == "full" :
37
- msgs = prompt_full (interactive , tool_format )
39
+ msgs = prompt_full (interactive , tool_format , model )
38
40
elif prompt == "short" :
39
41
msgs = prompt_short (interactive , tool_format )
40
42
else :
@@ -56,10 +58,10 @@ def _join_messages(msgs: list[Message]) -> Message:
56
58
57
59
58
60
def prompt_full (
59
- interactive : bool , tool_format : ToolFormat
61
+ interactive : bool , tool_format : ToolFormat , model : str | None
60
62
) -> Generator [Message , None , None ]:
61
63
"""Full prompt to start the conversation."""
62
- yield from prompt_gptme (interactive )
64
+ yield from prompt_gptme (interactive , model )
63
65
yield from prompt_tools (tool_format = tool_format )
64
66
if interactive :
65
67
yield from prompt_user ()
@@ -79,7 +81,9 @@ def prompt_short(
79
81
yield from prompt_project ()
80
82
81
83
82
- def prompt_gptme (interactive : bool ) -> Generator [Message , None , None ]:
84
+ def prompt_gptme (
85
+ interactive : bool , model : str | None = None
86
+ ) -> Generator [Message , None , None ]:
83
87
"""
84
88
Base system prompt for gptme.
85
89
@@ -90,20 +94,23 @@ def prompt_gptme(interactive: bool) -> Generator[Message, None, None]:
90
94
- Not mention tools which may not be loaded (browser, vision)
91
95
- Mention the ability to self-correct and ask clarifying questions
92
96
"""
97
+ model_meta = get_model (model )
98
+
99
+ # use <thinking> tags as a fallback if the model doesn't natively support reasoning
100
+ use_thinking_tags = not model_meta .supports_reasoning
93
101
94
102
default_base_prompt = f"""
95
- You are gptme v{ __version__ } , a general-purpose AI assistant powered by LLMs.
103
+ You are gptme v{ __version__ } , a general-purpose AI assistant powered by LLMs. { ( 'Currently using model: ' + model_meta . full ) if model_meta else '' }
96
104
You are designed to help users with programming tasks, such as writing code, debugging, and learning new concepts.
97
105
You can run code, execute terminal commands, and access the filesystem on the local machine.
98
106
You will help the user with writing code, either from scratch or in existing projects.
99
- You will think step by step when solving a problem, in `<thinking>` tags.
107
+ { ' You will think step by step when solving a problem, in `<thinking>` tags.' if use_thinking_tags else '' }
100
108
Break down complex tasks into smaller, manageable steps.
101
109
102
- You have the ability to self-correct.
103
- If you receive feedback that your output or actions were incorrect, you should:
110
+ You have the ability to self-correct. { '''If you receive feedback that your output or actions were incorrect, you should:
104
111
- acknowledge the mistake
105
112
- analyze what went wrong in `<thinking>` tags
106
- - provide a corrected response
113
+ - provide a corrected response''' if use_thinking_tags else '' }
107
114
108
115
You should learn about the context needed to provide the best help,
109
116
such as exploring the current working directory and reading the code using terminal tools.
@@ -125,7 +132,7 @@ def prompt_gptme(interactive: bool) -> Generator[Message, None, None]:
125
132
126
133
Maintain a professional and efficient communication style. Be concise but thorough in your explanations.
127
134
128
- Use `<thinking>` tags to think before you answer.
135
+ { ' Use `<thinking>` tags to think before you answer.' if use_thinking_tags else '' }
129
136
""" .strip ()
130
137
131
138
interactive_prompt = """
0 commit comments