mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-20 06:05:12 +01:00
Set voice starters to make prompt out of the transcript
This commit is contained in:
@@ -29,6 +29,7 @@ ALLOWED_TELEGRAM_USER_IDS=USER_ID_1,USER_ID_2
|
||||
# MAX_HISTORY_SIZE=15
|
||||
# MAX_CONVERSATION_AGE_MINUTES=180
|
||||
# VOICE_REPLY_WITH_TRANSCRIPT_ONLY=false
|
||||
# VOICE_REPLY_PROMPTS="Hi bot;Hey bot;Hi chat;Hey chat"
|
||||
# N_CHOICES=1
|
||||
# TEMPERATURE=1.0
|
||||
# PRESENCE_PENALTY=0.0
|
||||
|
||||
@@ -82,6 +82,7 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di
|
||||
| `MAX_HISTORY_SIZE` | Max number of messages to keep in memory, after which the conversation will be summarised to avoid excessive token usage | `15` |
|
||||
| `MAX_CONVERSATION_AGE_MINUTES` | Maximum number of minutes a conversation should live since the last message, after which the conversation will be reset | `180` |
|
||||
| `VOICE_REPLY_WITH_TRANSCRIPT_ONLY` | Whether to answer to voice messages with the transcript only or with a ChatGPT response of the transcript | `false` |
|
||||
| `VOICE_REPLY_PROMPTS` | A semicolon separated list of phrases ('Hi bot;Hello chat'). If the transcript starts with any of them - it will be treated as a prompt | -
|
||||
| `N_CHOICES` | Number of answers to generate for each input message. **Note**: setting this to a number higher than 1 will not work properly if `STREAM` is enabled | `1` |
|
||||
| `TEMPERATURE` | Number between 0 and 2. Higher values will make the output more random | `1.0` |
|
||||
| `PRESENCE_PENALTY` | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far | `0.0` |
|
||||
|
||||
@@ -68,6 +68,7 @@ def main():
|
||||
'stream': os.environ.get('STREAM', 'true').lower() == 'true',
|
||||
'proxy': os.environ.get('PROXY', None),
|
||||
'voice_reply_transcript': os.environ.get('VOICE_REPLY_WITH_TRANSCRIPT_ONLY', 'false').lower() == 'true',
|
||||
'voice_reply_prompts': () if os.environ.get('VOICE_REPLY_PROMPTS', None) is None else os.environ.get('VOICE_REPLY_PROMPTS').split(";"),
|
||||
'ignore_group_transcriptions': os.environ.get('IGNORE_GROUP_TRANSCRIPTIONS', 'true').lower() == 'true',
|
||||
'group_trigger_keyword': os.environ.get('GROUP_TRIGGER_KEYWORD', ''),
|
||||
'token_price': float(os.environ.get('TOKEN_PRICE', 0.002)),
|
||||
|
||||
@@ -321,7 +321,10 @@ class ChatGPTTelegramBot:
|
||||
if str(user_id) not in allowed_user_ids and 'guests' in self.usage:
|
||||
self.usage["guests"].add_transcription_seconds(audio_track.duration_seconds, transcription_price)
|
||||
|
||||
if self.config['voice_reply_transcript']:
|
||||
# check if transcript starts with any of the prefixes
|
||||
response_to_transcription = any(transcript.startswith(prefix) for prefix in self.config['voice_reply_prompts'])
|
||||
|
||||
if self.config['voice_reply_transcript'] and not response_to_transcription:
|
||||
|
||||
# Split into chunks of 4096 characters (Telegram's message limit)
|
||||
transcript_output = f"_{localized_text('transcript', bot_language)}:_\n\"{transcript}\""
|
||||
|
||||
Reference in New Issue
Block a user