Skip to content

Commit

Permalink
fix: incorrect response_preference key in config
Browse files Browse the repository at this point in the history
- Fix incorrect response_preferences key (was using nested preferences)
- Add prompt field to project config in gptme.toml
- Simplify response preferences handling
- Support project-specific prompts in project config
  • Loading branch information
ErikBjare committed Dec 2, 2024
1 parent b48f151 commit 748be0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions gptme.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
prompt = "This is gptme"
files = ["README.md", "Makefile"]
#files = ["README.md", "Makefile", "gptme/cli.py", "docs/*.rst", "docs/*.md"]

Expand Down
1 change: 1 addition & 0 deletions gptme/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def dict(self) -> dict:
class ProjectConfig:
"""Project-level configuration, such as which files to include in the context by default."""

prompt: str | None = None
files: list[str] = field(default_factory=list)
rag: dict = field(default_factory=dict)

Expand Down
21 changes: 10 additions & 11 deletions gptme/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,18 @@ def prompt_user() -> Generator[Message, None, None]:
about_user = config_prompt.get(
"about_user", "You are interacting with a human programmer."
)
response_preferences = config_prompt.get("response_preferences", {}).get(
"preferences", []
)

response_prefs = (
"\n".join(f"- {pref}" for pref in response_preferences)
if response_preferences
else "No specific preferences set."
)
config_prompt.get("response_preference")
or config_prompt.get("preferences")
or "No specific preferences set."
).strip()

prompt_content = f"""# About User
{about_user}
## User's Response Preferences
{response_prefs}
"""
yield Message("system", prompt_content)
Expand All @@ -176,11 +173,13 @@ def prompt_project() -> Generator[Message, None, None]:
if not projectdir:
return

project_config = get_project_config(projectdir)
config_prompt = get_config().prompt
project = projectdir.name
project_info = config_prompt.get("project", {}).get(
project, "No specific project context provided."
)
project_info = project_config and project_config.prompt
if not project_info:
# TODO: remove project preferences in global config? use only project config
project_info = config_prompt.get("project", {}).get(project)

yield Message(
"system",
Expand Down

0 comments on commit 748be0b

Please sign in to comment.