Skip to content

Commit

Permalink
feat: add system info to the about_user prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
brayo-pip committed Oct 8, 2024
1 parent 945b5ce commit 2b1f6d6
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 217 deletions.
19 changes: 18 additions & 1 deletion gptme/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

import logging
import os
import platform
import subprocess
from collections.abc import Generator, Iterable
from typing import Literal
from distro import name, version as distro_version

from .__version__ import __version__
from .config import get_config
Expand Down Expand Up @@ -143,7 +145,7 @@ def prompt_user() -> Generator[Message, None, None]:
"""
config_prompt = get_config().prompt
about_user = config_prompt.get(
"about_user", "You are interacting with a human programmer."
"about_user", f"You are interacting with a human programmer. I am running a {get_system_info()} system."
)
response_preferences = config_prompt.get("response_preferences", {}).get(
"preferences", []
Expand Down Expand Up @@ -208,6 +210,21 @@ def prompt_tools(examples: bool = True) -> Generator[Message, None, None]:
prompt += "\n\n*End of Tools List.*"
yield Message("system", prompt.strip() + "\n\n")

def get_system_info() -> str:
"""Get system information to include in the prompt."""
if os.name == "posix":
distro = name()
version = distro_version()
elif os.name == "darwin":
distro = "macOS"
version = platform.mac_ver()[0]
elif os.name == "nt":
distro = "Windows"
version = platform.version()
else:
distro = os.name
version = os.uname().version
return f"{distro} {version}"

document_prompt_function(interactive=True)(prompt_gptme)
document_prompt_function()(prompt_user)
Expand Down
Loading

0 comments on commit 2b1f6d6

Please sign in to comment.