-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ijwfly/feature/user-system-prompt-configu…
…ration User info in system prompt
- Loading branch information
Showing
10 changed files
with
77 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Optional | ||
|
||
from app.bot.utils import send_telegram_message | ||
from app.functions.base import OpenAIFunction, OpenAIFunctionParams | ||
from pydantic import Field | ||
|
||
|
||
class SaveUserSettingsParams(OpenAIFunctionParams): | ||
settings_text: str = Field(..., description='full list of user info and settings which will apear in <UserSettings> block in system prompt') | ||
|
||
|
||
class SaveUserSettings(OpenAIFunction): | ||
PARAMS_SCHEMA = SaveUserSettingsParams | ||
|
||
async def run(self, params: SaveUserSettingsParams) -> Optional[str]: | ||
self.user.system_prompt_settings = params.settings_text.strip() | ||
await self.db.update_user(self.user) | ||
if self.user.system_prompt_settings: | ||
await send_telegram_message(self.message, f'Saved User Info:\n{params.settings_text}') | ||
else: | ||
await send_telegram_message(self.message, f'Cleared User Info') | ||
return 'success' | ||
|
||
@classmethod | ||
def get_name(cls) -> str: | ||
return "save_user_settings" | ||
|
||
@classmethod | ||
def get_description(cls) -> str: | ||
return "Save user info or user settings when user asks to do so. Rewrite the text of the UserSettings in system prompt." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CREATE SCHEMA IF NOT EXISTS chatgpttg; | ||
|
||
ALTER TABLE chatgpttg.user ADD COLUMN IF NOT EXISTS system_prompt_settings text; | ||
ALTER TABLE chatgpttg.user ADD COLUMN IF NOT EXISTS system_prompt_settings_enabled BOOLEAN NOT NULL DEFAULT false; |