mirror of
				https://github.com/cdryzun/tg_bot_collections.git
				synced 2025-11-04 08:46:44 +08:00 
			
		
		
		
	fix: gpt token
This commit is contained in:
		@ -117,14 +117,15 @@ def chatgpt_pro_handler(message: Message, bot: TeleBot) -> None:
 | 
			
		||||
    reply_id = bot_reply_first(message, who, bot)
 | 
			
		||||
 | 
			
		||||
    player_message.append({"role": "user", "content": m})
 | 
			
		||||
    # keep the last 5, every has two ask and answer.
 | 
			
		||||
    if len(player_message) > 10:
 | 
			
		||||
    # keep the last 3, every has two ask and answer.
 | 
			
		||||
    # save me some money
 | 
			
		||||
    if len(player_message) > 6:
 | 
			
		||||
        player_message = player_message[2:]
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        r = client.chat.completions.create(
 | 
			
		||||
            messages=player_message,
 | 
			
		||||
            max_tokens=2048,
 | 
			
		||||
            max_tokens=8192,
 | 
			
		||||
            model=CHATGPT_PRO_MODEL,
 | 
			
		||||
            stream=True,
 | 
			
		||||
        )
 | 
			
		||||
@ -134,7 +135,7 @@ def chatgpt_pro_handler(message: Message, bot: TeleBot) -> None:
 | 
			
		||||
            if chunk.choices[0].delta.content is None:
 | 
			
		||||
                break
 | 
			
		||||
            s += chunk.choices[0].delta.content
 | 
			
		||||
            if time.time() - start > 2.0:
 | 
			
		||||
            if time.time() - start > 1.7:
 | 
			
		||||
                start = time.time()
 | 
			
		||||
                bot_reply_markdown(reply_id, who, s, bot, split_text=False)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,7 @@ gemini_file_player_dict = {}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def make_new_gemini_convo(is_pro=False) -> ChatSession:
 | 
			
		||||
    model_name = "models/gemini-1.0-pro-latest"
 | 
			
		||||
    model_name = "gemini-1.5-flash-latest"
 | 
			
		||||
    if is_pro:
 | 
			
		||||
        model_name = "models/gemini-1.5-pro-latest"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										30
									
								
								pdm.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										30
									
								
								pdm.lock
									
									
									
										generated
									
									
									
								
							@ -97,7 +97,7 @@ files = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "anthropic"
 | 
			
		||||
version = "0.25.8"
 | 
			
		||||
version = "0.25.9"
 | 
			
		||||
requires_python = ">=3.7"
 | 
			
		||||
summary = "The official Python library for the anthropic API"
 | 
			
		||||
groups = ["default"]
 | 
			
		||||
@ -111,8 +111,8 @@ dependencies = [
 | 
			
		||||
    "typing-extensions<5,>=4.7",
 | 
			
		||||
]
 | 
			
		||||
files = [
 | 
			
		||||
    {file = "anthropic-0.25.8-py3-none-any.whl", hash = "sha256:c7a0091916eb22a5e0012b725f5492779eedfcad2da8dc906082e1db7596a65c"},
 | 
			
		||||
    {file = "anthropic-0.25.8.tar.gz", hash = "sha256:93f6063e96d5dbeaa172edc177762f630e55b2f81595cedb760278b95a2dd03e"},
 | 
			
		||||
    {file = "anthropic-0.25.9-py3-none-any.whl", hash = "sha256:d0b17d442160356a531593b237de55d3125cc6fa708f1268c214107e61c81c57"},
 | 
			
		||||
    {file = "anthropic-0.25.9.tar.gz", hash = "sha256:a4ec810b1cfbf3340af99b6f5bf599a83d66986e0f572a5f3bc4ebcab284f629"},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -681,7 +681,7 @@ files = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "google-ai-generativelanguage"
 | 
			
		||||
version = "0.6.2"
 | 
			
		||||
version = "0.6.3"
 | 
			
		||||
requires_python = ">=3.7"
 | 
			
		||||
summary = "Google Ai Generativelanguage API client library"
 | 
			
		||||
groups = ["default"]
 | 
			
		||||
@ -692,8 +692,8 @@ dependencies = [
 | 
			
		||||
    "protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5",
 | 
			
		||||
]
 | 
			
		||||
files = [
 | 
			
		||||
    {file = "google-ai-generativelanguage-0.6.2.tar.gz", hash = "sha256:308791ac3b9dad015b359172970739aa3753dd542142a416d07f9fa047e22386"},
 | 
			
		||||
    {file = "google_ai_generativelanguage-0.6.2-py3-none-any.whl", hash = "sha256:bf84c34c641570d7e8a1f2e6901e6771af1438f2ee8307d1801fd43585f9b1c6"},
 | 
			
		||||
    {file = "google-ai-generativelanguage-0.6.3.tar.gz", hash = "sha256:10a11f1e1bb8470ff50030c1acd729b3aba7a29ade2c30cf1d1c917291366c67"},
 | 
			
		||||
    {file = "google_ai_generativelanguage-0.6.3-py3-none-any.whl", hash = "sha256:55a6698f6c9cbbfde5f9cd288073b6941dd9e3e6dc2176dfa3197f9a4c489895"},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -783,12 +783,12 @@ files = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "google-generativeai"
 | 
			
		||||
version = "0.5.2"
 | 
			
		||||
version = "0.5.3"
 | 
			
		||||
requires_python = ">=3.9"
 | 
			
		||||
summary = "Google Generative AI High level API client library and tools."
 | 
			
		||||
groups = ["default"]
 | 
			
		||||
dependencies = [
 | 
			
		||||
    "google-ai-generativelanguage==0.6.2",
 | 
			
		||||
    "google-ai-generativelanguage==0.6.3",
 | 
			
		||||
    "google-api-core",
 | 
			
		||||
    "google-api-python-client",
 | 
			
		||||
    "google-auth>=2.15.0",
 | 
			
		||||
@ -798,7 +798,7 @@ dependencies = [
 | 
			
		||||
    "typing-extensions",
 | 
			
		||||
]
 | 
			
		||||
files = [
 | 
			
		||||
    {file = "google_generativeai-0.5.2-py3-none-any.whl", hash = "sha256:56f39485a0a673c93c21ec31c17809cc6a964193fb77b7ce809ad15d0dd72d7b"},
 | 
			
		||||
    {file = "google_generativeai-0.5.3-py3-none-any.whl", hash = "sha256:a74509ee219601c74c0561eb4e1c9af6a88594c7dd098d30a18c6592afe62bd9"},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -1230,7 +1230,7 @@ files = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "openai"
 | 
			
		||||
version = "1.26.0"
 | 
			
		||||
version = "1.30.1"
 | 
			
		||||
requires_python = ">=3.7.1"
 | 
			
		||||
summary = "The official Python library for the openai API"
 | 
			
		||||
groups = ["default"]
 | 
			
		||||
@ -1244,8 +1244,8 @@ dependencies = [
 | 
			
		||||
    "typing-extensions<5,>=4.7",
 | 
			
		||||
]
 | 
			
		||||
files = [
 | 
			
		||||
    {file = "openai-1.26.0-py3-none-any.whl", hash = "sha256:884ced523fb0225780f8b0e0ed6f7e014049c32d049a41ad0ac962869f1055d1"},
 | 
			
		||||
    {file = "openai-1.26.0.tar.gz", hash = "sha256:642e857b60855702ee6ff665e8fa80946164f77b92e58fd24e01b545685b8405"},
 | 
			
		||||
    {file = "openai-1.30.1-py3-none-any.whl", hash = "sha256:c9fb3c3545c118bbce8deb824397b9433a66d0d0ede6a96f7009c95b76de4a46"},
 | 
			
		||||
    {file = "openai-1.30.1.tar.gz", hash = "sha256:4f85190e577cba0b066e1950b8eb9b11d25bc7ebcc43a86b326ce1bfa564ec74"},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
@ -1741,7 +1741,7 @@ files = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "pytelegrambotapi"
 | 
			
		||||
version = "4.17.0"
 | 
			
		||||
version = "4.18.0"
 | 
			
		||||
requires_python = ">=3.8"
 | 
			
		||||
summary = "Python Telegram bot api."
 | 
			
		||||
groups = ["default"]
 | 
			
		||||
@ -1749,8 +1749,8 @@ dependencies = [
 | 
			
		||||
    "requests",
 | 
			
		||||
]
 | 
			
		||||
files = [
 | 
			
		||||
    {file = "pytelegrambotapi-4.17.0-py3-none-any.whl", hash = "sha256:326b51fdaa4f5dcb1e12d326beb9d9aa1289ffb578110b17d5ea269971a39160"},
 | 
			
		||||
    {file = "pytelegrambotapi-4.17.0.tar.gz", hash = "sha256:8cfda15e64a12fe73b78545ccc7b59e035d7fb3e54da5722ddf756296f3b8159"},
 | 
			
		||||
    {file = "pytelegrambotapi-4.18.0-py3-none-any.whl", hash = "sha256:88a980ed75f3ea611c97fcb375fc787fc6ef4f1e2f61ae59a14d7377058376a1"},
 | 
			
		||||
    {file = "pytelegrambotapi-4.18.0.tar.gz", hash = "sha256:a8a18c1fe847d1dc2622279d21ec591e47e0c067278eeb2275c759dfbc9522d5"},
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
aiohttp==3.9.5
 | 
			
		||||
aiosignal==1.3.1
 | 
			
		||||
annotated-types==0.6.0
 | 
			
		||||
anthropic==0.25.8
 | 
			
		||||
anthropic==0.25.9
 | 
			
		||||
anyio==4.3.0
 | 
			
		||||
async-timeout==4.0.3; python_version < "3.11"
 | 
			
		||||
attrs==23.2.0
 | 
			
		||||
@ -34,12 +34,12 @@ frozenlist==1.4.1
 | 
			
		||||
fsspec==2024.3.1
 | 
			
		||||
geopandas==0.14.4
 | 
			
		||||
github-poster==2.7.4
 | 
			
		||||
google-ai-generativelanguage==0.6.2
 | 
			
		||||
google-ai-generativelanguage==0.6.3
 | 
			
		||||
google-api-core==2.19.0
 | 
			
		||||
google-api-python-client==2.128.0
 | 
			
		||||
google-auth==2.29.0
 | 
			
		||||
google-auth-httplib2==0.2.0
 | 
			
		||||
google-generativeai==0.5.2
 | 
			
		||||
google-generativeai==0.5.3
 | 
			
		||||
googleapis-common-protos==1.63.0
 | 
			
		||||
groq==0.5.0
 | 
			
		||||
grpcio==1.63.0
 | 
			
		||||
@ -58,7 +58,7 @@ mistletoe==1.3.0
 | 
			
		||||
multidict==6.0.5
 | 
			
		||||
networkx==3.3
 | 
			
		||||
numpy==1.26.4
 | 
			
		||||
openai==1.26.0
 | 
			
		||||
openai==1.30.1
 | 
			
		||||
osmnx==1.9.2
 | 
			
		||||
packaging==24.0
 | 
			
		||||
pandas==2.2.2
 | 
			
		||||
@ -78,7 +78,7 @@ pygments==2.18.0
 | 
			
		||||
pyogrio==0.7.2
 | 
			
		||||
pyparsing==3.1.2
 | 
			
		||||
pyproj==3.6.1
 | 
			
		||||
pytelegrambotapi==4.17.0
 | 
			
		||||
pytelegrambotapi==4.18.0
 | 
			
		||||
python-dateutil==2.9.0.post0
 | 
			
		||||
pytz==2024.1
 | 
			
		||||
pyyaml==6.0.1
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								tg.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tg.py
									
									
									
									
									
								
							@ -3,16 +3,6 @@ from telebot import TeleBot
 | 
			
		||||
 | 
			
		||||
from handlers import list_available_commands, load_handlers
 | 
			
		||||
 | 
			
		||||
import socket
 | 
			
		||||
from urllib3.connection import HTTPConnection
 | 
			
		||||
 | 
			
		||||
HTTPConnection.default_socket_options = HTTPConnection.default_socket_options + [
 | 
			
		||||
    (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
 | 
			
		||||
    (socket.SOL_TCP, socket.TCP_KEEPIDLE, 200),
 | 
			
		||||
    (socket.SOL_TCP, socket.TCP_KEEPINTVL, 45),
 | 
			
		||||
    (socket.SOL_TCP, socket.TCP_KEEPCNT, 20),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    # Init args
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user