mirror of
https://github.com/cdryzun/tg_bot_collections.git
synced 2025-04-29 08:37:09 +08:00
fix: update image_to_data_uri to use dynamic content type
This commit is contained in:
parent
474e80db53
commit
b66c9ac136
@ -220,9 +220,10 @@ def enrich_text_with_urls(text: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def image_to_data_uri(file_path):
|
def image_to_data_uri(file_path):
|
||||||
|
content_type = guess_type(file_path)[0]
|
||||||
with open(file_path, "rb") as image_file:
|
with open(file_path, "rb") as image_file:
|
||||||
encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
|
encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
|
||||||
return f"data:image/png;base64,{encoded_image}"
|
return f"data:{content_type};base64,{encoded_image}"
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -389,7 +389,7 @@ def answer_it_handler(message: Message, bot: TeleBot) -> None:
|
|||||||
#### Complete Messages ####
|
#### Complete Messages ####
|
||||||
if CHATGPT_COMPLETE and CHATGPT_API_KEY:
|
if CHATGPT_COMPLETE and CHATGPT_API_KEY:
|
||||||
full_answer += complete_chatgpt_future.result()
|
full_answer += complete_chatgpt_future.result()
|
||||||
if CLADUE_COMPLETE and ANTHROPIC_API_KEY and not local_image_path:
|
if CLADUE_COMPLETE and ANTHROPIC_API_KEY:
|
||||||
full_answer += complete_claude_future.result()
|
full_answer += complete_claude_future.result()
|
||||||
if COHERE_COMPLETE and COHERE_API_KEY and not local_image_path:
|
if COHERE_COMPLETE and COHERE_API_KEY and not local_image_path:
|
||||||
full_answer += complete_cohere_future.result()
|
full_answer += complete_cohere_future.result()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user