deep-foundation / russian-laws-bot

The Unlicense
2 stars 3 forks source link

Start command is sent to GPT-4 API #2

Open Konard opened 9 months ago

Konard commented 9 months ago
gitpod /workspace/russian-laws-bot (main) $ python main.py
2024-02-13 13:27:21,998 - aiogram.dispatcher - INFO - Start polling
2024-02-13 13:27:22,105 - aiogram.dispatcher - INFO - Run polling for bot @russian_laws_bot id=6522975675 - 'russian-laws-bot'
2024-02-13 13:30:23,435 - __main__ - INFO - ---------
Received message: message_id=59 date=datetime.datetime(2024, 2, 13, 13, 30, 23, tzinfo=TzInfo(UTC)) chat=Chat(id=1339837872, type='private', title=None, username='drakonard', first_name='Konstantin', last_name='Dyachenko', is_forum=None, photo=None, active_usernames=None, available_reactions=None, accent_color_id=None, background_custom_emoji_id=None, profile_accent_color_id=None, profile_background_custom_emoji_id=None, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None, bio=None, has_private_forwards=None, has_restricted_voice_and_video_messages=None, join_to_send_messages=None, join_by_request=None, description=None, invite_link=None, pinned_message=None, permissions=None, slow_mode_delay=None, message_auto_delete_time=None, has_aggressive_anti_spam_enabled=None, has_hidden_members=None, has_protected_content=None, has_visible_history=None, sticker_set_name=None, can_set_sticker_set=None, linked_chat_id=None, location=None) message_thread_id=None from_user=User(id=1339837872, is_bot=False, first_name='Konstantin', last_name='Dyachenko', username='drakonard', language_code='en', is_premium=True, added_to_attachment_menu=None, can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None) sender_chat=None forward_origin=None is_topic_message=None is_automatic_forward=None reply_to_message=None external_reply=None quote=None via_bot=None edit_date=None has_protected_content=None media_group_id=None author_signature=None text='/start' entities=[MessageEntity(type='bot_command', offset=0, length=6, url=None, user=None, language=None, custom_emoji_id=None)] link_preview_options=None animation=None audio=None document=None photo=None sticker=None story=None video=None video_note=None voice=None caption=None caption_entities=None has_media_spoiler=None contact=None dice=None game=None poll=None venue=None location=None new_chat_members=None left_chat_member=None new_chat_title=None new_chat_photo=None delete_chat_photo=None group_chat_created=None supergroup_chat_created=None channel_chat_created=None message_auto_delete_timer_changed=None migrate_to_chat_id=None migrate_from_chat_id=None pinned_message=None invoice=None successful_payment=None users_shared=None chat_shared=None connected_website=None write_access_allowed=None passport_data=None proximity_alert_triggered=None forum_topic_created=None forum_topic_edited=None forum_topic_closed=None forum_topic_reopened=None general_forum_topic_hidden=None general_forum_topic_unhidden=None giveaway_created=None giveaway=None giveaway_winners=None giveaway_completed=None video_chat_scheduled=None video_chat_started=None video_chat_ended=None video_chat_participants_invited=None web_app_data=None reply_markup=None forward_date=None forward_from=None forward_from_chat=None forward_from_message_id=None forward_sender_name=None forward_signature=None user_shared=None
2024-02-13 13:30:23,437 - __main__ - INFO - ---------
Completion request messages:
[
    {
        "role": "user",
        "content": "\n\n---\n/start"
    }
]
2024-02-13 13:30:27,297 - openai - INFO - message='OpenAI API response' path=https://deep-ai.openai.azure.com/openai/deployments/gpt-4-128k/chat/completions?api-version=2023-03-15-preview processing_ms=None request_id=e0cce350-df5b-4a99-a0ad-8feb4b57fdf6 response_code=200
2024-02-13 13:30:27,299 - __main__ - INFO - ---------
Completion responce:
{
    "id": "chatcmpl-8rn9brbgyS8GMsXYl2XfXnaQAJQgx",
    "object": "chat.completion",
    "created": 1707831023,
    "model": "gpt-4",
    "choices": [
        {
            "index": 0,
            "finish_reason": "stop",
            "message": {
                "role": "assistant",
                "content": "Hello! How can I assist you today? If you have any questions or need information on a topic, feel free to ask."
            }
        }
    ],
    "usage": {
        "prompt_tokens": 10,
        "completion_tokens": 26,
        "total_tokens": 36
    },
    "system_fingerprint": "fp_68a7d165bf"
}
2024-02-13 13:30:27,518 - __main__ - INFO - ---------
Sent message: Hello\! How can I assist you today? If you have any questions or need information on a topic, feel free to ask\.
2024-02-13 13:30:27,518 - aiogram.event - INFO - Update id=345672885 is handled. Duration 4083 ms by bot id=6522975675
FreePhoenix888 commented 9 months ago

I do not find /start in https://github.com/search?q=repo%3Adeep-foundation%2Frussian-laws%20%2Fstart&type=code and https://github.com/search?q=repo%3Adeep-foundation%2Frussian-laws-bot+start&type=code. Where is it taken from?

Konard commented 9 months ago

@FreePhoenix888 it is default command that used to activate any bot in Telegram. And now the effect is that it is sent as a message directly to GPT-4. That wastes money.