system prompt suspport
This commit is contained in:
16
ai_client.py
16
ai_client.py
@@ -48,6 +48,18 @@ _SYSTEM_PROMPT = (
|
||||
"need to re-read files that are already provided in the <context> block."
|
||||
)
|
||||
|
||||
|
||||
_custom_system_prompt: str = ""
|
||||
|
||||
def set_custom_system_prompt(prompt: str):
|
||||
global _custom_system_prompt
|
||||
_custom_system_prompt = prompt
|
||||
|
||||
def _get_combined_system_prompt() -> str:
|
||||
if _custom_system_prompt.strip():
|
||||
return f"{_SYSTEM_PROMPT}\n\n[USER SYSTEM PROMPT]\n{_custom_system_prompt}"
|
||||
return _SYSTEM_PROMPT
|
||||
|
||||
# ------------------------------------------------------------------ comms log
|
||||
|
||||
_comms_log: list[dict] = []
|
||||
@@ -403,7 +415,7 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, file_items:
|
||||
_gemini_chat = _gemini_client.chats.create(
|
||||
model=_model,
|
||||
config=types.GenerateContentConfig(
|
||||
system_instruction=_SYSTEM_PROMPT,
|
||||
system_instruction=_get_combined_system_prompt(),
|
||||
tools=[_gemini_tool_declaration()]
|
||||
)
|
||||
)
|
||||
@@ -635,7 +647,7 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item
|
||||
system=[
|
||||
{
|
||||
"type": "text",
|
||||
"text": _SYSTEM_PROMPT,
|
||||
"text": _get_combined_system_prompt(),
|
||||
"cache_control": {"type": "ephemeral"},
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user