Compare commits
3 Commits
a99a80f6c9
...
cfa592e85b
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa592e85b | |||
| d8a5fde5f1 | |||
| eb476ba2d0 |
@@ -28,6 +28,7 @@ from bot.modules.ai import (
|
|||||||
get_follow_ups,
|
get_follow_ups,
|
||||||
stream_response,
|
stream_response,
|
||||||
)
|
)
|
||||||
|
from bot.user_lock import get_user_lock
|
||||||
from utils import env
|
from utils import env
|
||||||
from utils.convex import ConvexClient
|
from utils.convex import ConvexClient
|
||||||
|
|
||||||
@@ -256,15 +257,34 @@ async def process_message_from_web( # noqa: C901, PLR0912, PLR0913, PLR0915
|
|||||||
convex_chat_id: str,
|
convex_chat_id: str,
|
||||||
images_base64: list[str] | None = None,
|
images_base64: list[str] | None = None,
|
||||||
images_media_types: list[str] | None = None,
|
images_media_types: list[str] | None = None,
|
||||||
|
pending_generation_id: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
user = await convex.query("users:getById", {"userId": convex_user_id})
|
user = await convex.query("users:getById", {"userId": convex_user_id})
|
||||||
|
|
||||||
if not user or not user.get("geminiApiKey"):
|
if not user or not user.get("geminiApiKey"):
|
||||||
return
|
return
|
||||||
|
|
||||||
tg_chat_id = user["telegramChatId"].value if user.get("telegramChatId") else None
|
|
||||||
is_summarize = text == "/summarize"
|
is_summarize = text == "/summarize"
|
||||||
|
|
||||||
|
if not is_summarize:
|
||||||
|
user_message_args: dict = {
|
||||||
|
"chatId": convex_chat_id,
|
||||||
|
"role": "user",
|
||||||
|
"content": text,
|
||||||
|
"source": "web",
|
||||||
|
}
|
||||||
|
if images_base64 and images_media_types:
|
||||||
|
user_message_args["imagesBase64"] = images_base64
|
||||||
|
user_message_args["imagesMediaTypes"] = images_media_types
|
||||||
|
await convex.mutation("messages:createFromBackend", user_message_args)
|
||||||
|
|
||||||
|
if pending_generation_id:
|
||||||
|
await convex.mutation(
|
||||||
|
"pendingGenerations:remove", {"id": pending_generation_id}
|
||||||
|
)
|
||||||
|
|
||||||
|
tg_chat_id = user["telegramChatId"].value if user.get("telegramChatId") else None
|
||||||
|
|
||||||
if tg_chat_id and not is_summarize:
|
if tg_chat_id and not is_summarize:
|
||||||
if images_base64 and images_media_types:
|
if images_base64 and images_media_types:
|
||||||
if len(images_base64) == 1:
|
if len(images_base64) == 1:
|
||||||
@@ -387,7 +407,7 @@ async def process_message_from_web( # noqa: C901, PLR0912, PLR0913, PLR0915
|
|||||||
await state.flush()
|
await state.flush()
|
||||||
|
|
||||||
full_history = [*history, {"role": "assistant", "content": final_answer}]
|
full_history = [*history, {"role": "assistant", "content": final_answer}]
|
||||||
follow_up_model = user.get("followUpModel", "gemini-2.5-flash-lite")
|
follow_up_model = user.get("followUpModel", "gemini-3.1-flash-lite-preview")
|
||||||
follow_up_prompt = user.get("followUpPrompt")
|
follow_up_prompt = user.get("followUpPrompt")
|
||||||
follow_up_agent = create_follow_up_agent(
|
follow_up_agent = create_follow_up_agent(
|
||||||
api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt
|
api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt
|
||||||
@@ -485,174 +505,189 @@ async def process_message( # noqa: C901, PLR0912, PLR0913, PLR0915
|
|||||||
model_name = user.get("model", "gemini-3-pro-preview")
|
model_name = user.get("model", "gemini-3-pro-preview")
|
||||||
convex_user_id = user["_id"]
|
convex_user_id = user["_id"]
|
||||||
|
|
||||||
proxy_config = get_proxy_config(chat_id)
|
async with get_user_lock(convex_user_id):
|
||||||
proxy_state: ProxyStreamingState | None = None
|
proxy_config = get_proxy_config(chat_id)
|
||||||
|
proxy_state: ProxyStreamingState | None = None
|
||||||
|
|
||||||
if proxy_config and not skip_proxy_user_message:
|
if proxy_config and not skip_proxy_user_message:
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
await proxy_config.proxy_bot.send_message(
|
await proxy_config.proxy_bot.send_message(
|
||||||
proxy_config.target_chat_id, f"👤 {text}"
|
proxy_config.target_chat_id, f"👤 {text}"
|
||||||
|
)
|
||||||
|
await increment_proxy_count(chat_id)
|
||||||
|
proxy_config = get_proxy_config(chat_id)
|
||||||
|
|
||||||
|
rag_connections = await convex.query(
|
||||||
|
"ragConnections:getActiveForUser", {"userId": convex_user_id}
|
||||||
|
)
|
||||||
|
rag_db_names: list[str] = []
|
||||||
|
if rag_connections:
|
||||||
|
for conn in rag_connections:
|
||||||
|
db = await convex.query(
|
||||||
|
"rag:getDatabaseById", {"ragDatabaseId": conn["ragDatabaseId"]}
|
||||||
|
)
|
||||||
|
if db:
|
||||||
|
rag_db_names.append(db["name"])
|
||||||
|
|
||||||
|
inject_connections = await convex.query(
|
||||||
|
"injectConnections:getActiveForUser", {"userId": convex_user_id}
|
||||||
|
)
|
||||||
|
inject_content = ""
|
||||||
|
if inject_connections:
|
||||||
|
for conn in inject_connections:
|
||||||
|
db = await convex.query(
|
||||||
|
"inject:getDatabaseById",
|
||||||
|
{"injectDatabaseId": conn["injectDatabaseId"]},
|
||||||
|
)
|
||||||
|
if db and db.get("content"):
|
||||||
|
inject_content += db["content"] + "\n\n"
|
||||||
|
inject_content = inject_content.strip()
|
||||||
|
|
||||||
|
if not skip_user_message:
|
||||||
|
await convex.mutation(
|
||||||
|
"messages:create",
|
||||||
|
{
|
||||||
|
"chatId": active_chat_id,
|
||||||
|
"role": "user",
|
||||||
|
"content": text,
|
||||||
|
"source": "telegram",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
await increment_proxy_count(chat_id)
|
|
||||||
proxy_config = get_proxy_config(chat_id)
|
|
||||||
|
|
||||||
rag_connections = await convex.query(
|
assistant_message_id = await convex.mutation(
|
||||||
"ragConnections:getActiveForUser", {"userId": convex_user_id}
|
|
||||||
)
|
|
||||||
rag_db_names: list[str] = []
|
|
||||||
if rag_connections:
|
|
||||||
for conn in rag_connections:
|
|
||||||
db = await convex.query(
|
|
||||||
"rag:getDatabaseById", {"ragDatabaseId": conn["ragDatabaseId"]}
|
|
||||||
)
|
|
||||||
if db:
|
|
||||||
rag_db_names.append(db["name"])
|
|
||||||
|
|
||||||
inject_connections = await convex.query(
|
|
||||||
"injectConnections:getActiveForUser", {"userId": convex_user_id}
|
|
||||||
)
|
|
||||||
inject_content = ""
|
|
||||||
if inject_connections:
|
|
||||||
for conn in inject_connections:
|
|
||||||
db = await convex.query(
|
|
||||||
"inject:getDatabaseById", {"injectDatabaseId": conn["injectDatabaseId"]}
|
|
||||||
)
|
|
||||||
if db and db.get("content"):
|
|
||||||
inject_content += db["content"] + "\n\n"
|
|
||||||
inject_content = inject_content.strip()
|
|
||||||
|
|
||||||
if not skip_user_message:
|
|
||||||
await convex.mutation(
|
|
||||||
"messages:create",
|
"messages:create",
|
||||||
{
|
{
|
||||||
"chatId": active_chat_id,
|
"chatId": active_chat_id,
|
||||||
"role": "user",
|
"role": "assistant",
|
||||||
"content": text,
|
"content": "",
|
||||||
"source": "telegram",
|
"source": "telegram",
|
||||||
|
"isStreaming": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assistant_message_id = await convex.mutation(
|
history = await convex.query(
|
||||||
"messages:create",
|
"messages:getHistoryForAI", {"chatId": active_chat_id, "limit": 50}
|
||||||
{
|
|
||||||
"chatId": active_chat_id,
|
|
||||||
"role": "assistant",
|
|
||||||
"content": "",
|
|
||||||
"source": "telegram",
|
|
||||||
"isStreaming": True,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
history = await convex.query(
|
|
||||||
"messages:getHistoryForAI", {"chatId": active_chat_id, "limit": 50}
|
|
||||||
)
|
|
||||||
|
|
||||||
system_prompt = user.get("systemPrompt")
|
|
||||||
if system_prompt and inject_content:
|
|
||||||
system_prompt = system_prompt.replace("{theory_database}", inject_content)
|
|
||||||
text_agent = create_text_agent(
|
|
||||||
api_key=api_key,
|
|
||||||
model_name=model_name,
|
|
||||||
system_prompt=system_prompt,
|
|
||||||
rag_db_names=rag_db_names or None,
|
|
||||||
)
|
|
||||||
|
|
||||||
agent_deps = (
|
|
||||||
AgentDeps(user_id=convex_user_id, api_key=api_key, rag_db_names=rag_db_names)
|
|
||||||
if rag_db_names
|
|
||||||
else None
|
|
||||||
)
|
|
||||||
|
|
||||||
processing_msg = await bot.send_message(chat_id, "...")
|
|
||||||
state = StreamingState(bot, chat_id, processing_msg)
|
|
||||||
|
|
||||||
if proxy_config:
|
|
||||||
proxy_processing_msg = await proxy_config.proxy_bot.send_message(
|
|
||||||
proxy_config.target_chat_id, "..."
|
|
||||||
)
|
|
||||||
proxy_state = ProxyStreamingState(
|
|
||||||
proxy_config.proxy_bot, proxy_config.target_chat_id, proxy_processing_msg
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
system_prompt = user.get("systemPrompt")
|
||||||
await state.start_typing()
|
if system_prompt and inject_content:
|
||||||
|
system_prompt = system_prompt.replace("{theory_database}", inject_content)
|
||||||
|
text_agent = create_text_agent(
|
||||||
|
api_key=api_key,
|
||||||
|
model_name=model_name,
|
||||||
|
system_prompt=system_prompt,
|
||||||
|
rag_db_names=rag_db_names or None,
|
||||||
|
)
|
||||||
|
|
||||||
async def on_chunk(content: str) -> None:
|
agent_deps = (
|
||||||
await state.update_message(content)
|
AgentDeps(
|
||||||
if proxy_state:
|
user_id=convex_user_id, api_key=api_key, rag_db_names=rag_db_names
|
||||||
await proxy_state.update_message(content)
|
)
|
||||||
await convex.mutation(
|
if rag_db_names
|
||||||
"messages:update",
|
else None
|
||||||
{"messageId": assistant_message_id, "content": content},
|
)
|
||||||
|
|
||||||
|
processing_msg = await bot.send_message(chat_id, "...")
|
||||||
|
state = StreamingState(bot, chat_id, processing_msg)
|
||||||
|
|
||||||
|
if proxy_config:
|
||||||
|
proxy_processing_msg = await proxy_config.proxy_bot.send_message(
|
||||||
|
proxy_config.target_chat_id, "..."
|
||||||
|
)
|
||||||
|
proxy_state = ProxyStreamingState(
|
||||||
|
proxy_config.proxy_bot,
|
||||||
|
proxy_config.target_chat_id,
|
||||||
|
proxy_processing_msg,
|
||||||
)
|
)
|
||||||
|
|
||||||
chat_images = await fetch_chat_images(active_chat_id)
|
try:
|
||||||
|
await state.start_typing()
|
||||||
|
|
||||||
final_answer = await stream_response(
|
async def on_chunk(content: str) -> None:
|
||||||
text_agent,
|
await state.update_message(content)
|
||||||
text,
|
if proxy_state:
|
||||||
history[:-2],
|
await proxy_state.update_message(content)
|
||||||
on_chunk,
|
await convex.mutation(
|
||||||
images=chat_images,
|
"messages:update",
|
||||||
deps=agent_deps,
|
{"messageId": assistant_message_id, "content": content},
|
||||||
)
|
|
||||||
|
|
||||||
await state.flush()
|
|
||||||
if proxy_state:
|
|
||||||
await proxy_state.flush()
|
|
||||||
|
|
||||||
full_history = [*history[:-1], {"role": "assistant", "content": final_answer}]
|
|
||||||
follow_up_model = user.get("followUpModel", "gemini-2.5-flash-lite")
|
|
||||||
follow_up_prompt = user.get("followUpPrompt")
|
|
||||||
follow_up_agent = create_follow_up_agent(
|
|
||||||
api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt
|
|
||||||
)
|
|
||||||
follow_ups = await get_follow_ups(follow_up_agent, full_history, chat_images)
|
|
||||||
|
|
||||||
await state.stop_typing()
|
|
||||||
|
|
||||||
await convex.mutation(
|
|
||||||
"messages:update",
|
|
||||||
{
|
|
||||||
"messageId": assistant_message_id,
|
|
||||||
"content": final_answer,
|
|
||||||
"followUpOptions": follow_ups,
|
|
||||||
"isStreaming": False,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
with contextlib.suppress(Exception):
|
|
||||||
await processing_msg.delete()
|
|
||||||
|
|
||||||
keyboard = make_follow_up_keyboard(follow_ups)
|
|
||||||
await send_long_message(bot, chat_id, final_answer, keyboard)
|
|
||||||
|
|
||||||
if proxy_state and proxy_config:
|
|
||||||
with contextlib.suppress(Exception):
|
|
||||||
await proxy_state.message.delete()
|
|
||||||
parts = split_message(final_answer)
|
|
||||||
for part in parts:
|
|
||||||
await proxy_config.proxy_bot.send_message(
|
|
||||||
proxy_config.target_chat_id, part
|
|
||||||
)
|
)
|
||||||
await increment_proxy_count(chat_id)
|
|
||||||
|
|
||||||
except Exception as e: # noqa: BLE001
|
chat_images = await fetch_chat_images(active_chat_id)
|
||||||
await state.stop_typing()
|
|
||||||
error_msg = f"Error: {e}"
|
final_answer = await stream_response(
|
||||||
await convex.mutation(
|
text_agent,
|
||||||
"messages:update",
|
text,
|
||||||
{
|
history[:-2],
|
||||||
"messageId": assistant_message_id,
|
on_chunk,
|
||||||
"content": error_msg,
|
images=chat_images,
|
||||||
"isStreaming": False,
|
deps=agent_deps,
|
||||||
},
|
)
|
||||||
)
|
|
||||||
with contextlib.suppress(Exception):
|
await state.flush()
|
||||||
await processing_msg.edit_text(html.quote(error_msg[:TELEGRAM_MAX_LENGTH]))
|
if proxy_state:
|
||||||
if proxy_state:
|
await proxy_state.flush()
|
||||||
|
|
||||||
|
full_history = [
|
||||||
|
*history[:-1],
|
||||||
|
{"role": "assistant", "content": final_answer},
|
||||||
|
]
|
||||||
|
follow_up_model = user.get("followUpModel", "gemini-3.1-flash-lite-preview")
|
||||||
|
follow_up_prompt = user.get("followUpPrompt")
|
||||||
|
follow_up_agent = create_follow_up_agent(
|
||||||
|
api_key=api_key,
|
||||||
|
model_name=follow_up_model,
|
||||||
|
system_prompt=follow_up_prompt,
|
||||||
|
)
|
||||||
|
follow_ups = await get_follow_ups(
|
||||||
|
follow_up_agent, full_history, chat_images
|
||||||
|
)
|
||||||
|
|
||||||
|
await state.stop_typing()
|
||||||
|
|
||||||
|
await convex.mutation(
|
||||||
|
"messages:update",
|
||||||
|
{
|
||||||
|
"messageId": assistant_message_id,
|
||||||
|
"content": final_answer,
|
||||||
|
"followUpOptions": follow_ups,
|
||||||
|
"isStreaming": False,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
await proxy_state.message.edit_text(error_msg[:TELEGRAM_MAX_LENGTH])
|
await processing_msg.delete()
|
||||||
|
|
||||||
|
keyboard = make_follow_up_keyboard(follow_ups)
|
||||||
|
await send_long_message(bot, chat_id, final_answer, keyboard)
|
||||||
|
|
||||||
|
if proxy_state and proxy_config:
|
||||||
|
with contextlib.suppress(Exception):
|
||||||
|
await proxy_state.message.delete()
|
||||||
|
parts = split_message(final_answer)
|
||||||
|
for part in parts:
|
||||||
|
await proxy_config.proxy_bot.send_message(
|
||||||
|
proxy_config.target_chat_id, part
|
||||||
|
)
|
||||||
|
await increment_proxy_count(chat_id)
|
||||||
|
|
||||||
|
except Exception as e: # noqa: BLE001
|
||||||
|
await state.stop_typing()
|
||||||
|
error_msg = f"Error: {e}"
|
||||||
|
await convex.mutation(
|
||||||
|
"messages:update",
|
||||||
|
{
|
||||||
|
"messageId": assistant_message_id,
|
||||||
|
"content": error_msg,
|
||||||
|
"isStreaming": False,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
with contextlib.suppress(Exception):
|
||||||
|
await processing_msg.edit_text(
|
||||||
|
html.quote(error_msg[:TELEGRAM_MAX_LENGTH])
|
||||||
|
)
|
||||||
|
if proxy_state:
|
||||||
|
with contextlib.suppress(Exception):
|
||||||
|
await proxy_state.message.edit_text(error_msg[:TELEGRAM_MAX_LENGTH])
|
||||||
|
|
||||||
|
|
||||||
async def send_to_telegram(user_id: int, text: str, bot: Bot) -> None:
|
async def send_to_telegram(user_id: int, text: str, bot: Bot) -> None:
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def create_text_agent(
|
|||||||
|
|
||||||
if rag_db_names:
|
if rag_db_names:
|
||||||
full_prompt = f"{base_prompt}{RAG_SYSTEM_ADDITION} {LATEX_INSTRUCTION}"
|
full_prompt = f"{base_prompt}{RAG_SYSTEM_ADDITION} {LATEX_INSTRUCTION}"
|
||||||
agent: Agent[None, str] = Agent(
|
agent: Agent[AgentDeps, str] = Agent(
|
||||||
model, instructions=full_prompt, deps_type=AgentDeps
|
model, instructions=full_prompt, deps_type=AgentDeps
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -101,13 +101,16 @@ def create_text_agent(
|
|||||||
|
|
||||||
def create_follow_up_agent(
|
def create_follow_up_agent(
|
||||||
api_key: str,
|
api_key: str,
|
||||||
model_name: str = "gemini-2.5-flash-lite",
|
model_name: str = "gemini-3.1-flash-lite-preview",
|
||||||
system_prompt: str | None = None,
|
system_prompt: str | None = None,
|
||||||
) -> Agent[None, FollowUpOptions]:
|
) -> Agent[None, FollowUpOptions]:
|
||||||
provider = GoogleProvider(api_key=api_key)
|
provider = GoogleProvider(api_key=api_key)
|
||||||
model = GoogleModel(model_name, provider=provider)
|
model = GoogleModel(model_name, provider=provider)
|
||||||
prompt = system_prompt or DEFAULT_FOLLOW_UP
|
prompt = system_prompt or DEFAULT_FOLLOW_UP
|
||||||
return Agent(model, output_type=FollowUpOptions, instructions=prompt)
|
agent: Agent[None, FollowUpOptions] = Agent( # ty: ignore[invalid-assignment]
|
||||||
|
model, output_type=FollowUpOptions, instructions=prompt
|
||||||
|
)
|
||||||
|
return agent
|
||||||
|
|
||||||
|
|
||||||
def build_message_history(history: list[dict[str, str]]) -> list[ModelMessage]:
|
def build_message_history(history: list[dict[str, str]]) -> list[ModelMessage]:
|
||||||
|
|||||||
@@ -104,6 +104,44 @@ Example output:
|
|||||||
"3. Usually implemented as swapping randomly selected subtrees of parent trees"
|
"3. Usually implemented as swapping randomly selected subtrees of parent trees"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
REFERENCE_SYSTEM = """
|
||||||
|
You are an Examination Engine for solving problem sets, designed for Apple Watch output.
|
||||||
|
|
||||||
|
You operate against context bank:
|
||||||
|
|
||||||
|
<EXAM_MATERIALS>
|
||||||
|
{theory_database}
|
||||||
|
</EXAM_MATERIALS>
|
||||||
|
|
||||||
|
*** PROTOCOL: BATCH PROCESSING ***
|
||||||
|
|
||||||
|
1. **DETECT ALL** problems in input.
|
||||||
|
2. **SOLVE ALL** sequentially in one response.
|
||||||
|
3. **ORDER:** follow source numbering. Subparts (a, b, c) stay grouped under parent.
|
||||||
|
4. **SEPARATOR:** "---" between problems.
|
||||||
|
5. **CONTINUATION:** new page after partial solve → don't repeat solved tasks.
|
||||||
|
6. **NO PREAMBLE.** Start directly with **Ex. 1**. No "I see the following problems".
|
||||||
|
|
||||||
|
*** SOLVING LOGIC ***
|
||||||
|
|
||||||
|
This is a PROBLEM-SOLVING engine, not a theory recall engine.
|
||||||
|
Every problem gets a full derivation.
|
||||||
|
|
||||||
|
- **Honor EXAM_MATERIALS first.** If they specify a formula source, notation,
|
||||||
|
forbidden method, required step or example - comply.
|
||||||
|
- Mirror approach exactly: same notation, structure, justification depth, voice.
|
||||||
|
- If no match in materials → infer canonical structure from examples and apply.
|
||||||
|
- **Show all reasoning** that examples show.
|
||||||
|
Don't skip steps "because obvious" if examples don't skip them.
|
||||||
|
- **Brief justifications welcome** when examples use them
|
||||||
|
("by symmetry", "since disjoint", "WLOG"). Match voice.
|
||||||
|
|
||||||
|
*** APPLE WATCH FORMATTING (strict) ***
|
||||||
|
- Line width: MAX 25-30 chars. Force breaks often.
|
||||||
|
- Math: `$$...$$` display, `$...$` inline, standard LaTeX.
|
||||||
|
"""
|
||||||
|
|
||||||
DEFAULT_FOLLOW_UP = (
|
DEFAULT_FOLLOW_UP = (
|
||||||
"Based on the conversation, suggest 3 short follow-up questions "
|
"Based on the conversation, suggest 3 short follow-up questions "
|
||||||
"the user might want to ask. Each option should be under 50 characters."
|
"the user might want to ask. Each option should be under 50 characters."
|
||||||
@@ -124,4 +162,5 @@ PRESETS: dict[str, tuple[str, str]] = {
|
|||||||
"exam": (EXAM_SYSTEM, EXAM_FOLLOW_UP),
|
"exam": (EXAM_SYSTEM, EXAM_FOLLOW_UP),
|
||||||
"ragtheory": (RAGTHEORY_SYSTEM, EXAM_FOLLOW_UP),
|
"ragtheory": (RAGTHEORY_SYSTEM, EXAM_FOLLOW_UP),
|
||||||
"proofs": (PROOFS_SYSTEM, EXAM_FOLLOW_UP),
|
"proofs": (PROOFS_SYSTEM, EXAM_FOLLOW_UP),
|
||||||
|
"reference": (REFERENCE_SYSTEM, EXAM_FOLLOW_UP),
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-8
@@ -5,6 +5,7 @@ import time
|
|||||||
from aiogram import Bot
|
from aiogram import Bot
|
||||||
|
|
||||||
from bot.handlers.message.handler import process_message_from_web
|
from bot.handlers.message.handler import process_message_from_web
|
||||||
|
from bot.user_lock import get_user_lock
|
||||||
from utils import env
|
from utils import env
|
||||||
from utils.collaborative import (
|
from utils.collaborative import (
|
||||||
CollaborativeClient,
|
CollaborativeClient,
|
||||||
@@ -53,14 +54,16 @@ async def start_sync_listener(bot: Bot) -> None:
|
|||||||
|
|
||||||
async def handle_pending_generation(bot: Bot, item: dict, item_id: str) -> None:
|
async def handle_pending_generation(bot: Bot, item: dict, item_id: str) -> None:
|
||||||
try:
|
try:
|
||||||
await process_message_from_web(
|
async with get_user_lock(item["userId"]):
|
||||||
convex_user_id=item["userId"],
|
await process_message_from_web(
|
||||||
text=item["userMessage"],
|
convex_user_id=item["userId"],
|
||||||
bot=bot,
|
text=item["userMessage"],
|
||||||
convex_chat_id=item["chatId"],
|
bot=bot,
|
||||||
images_base64=item.get("imagesBase64"),
|
convex_chat_id=item["chatId"],
|
||||||
images_media_types=item.get("imagesMediaTypes"),
|
images_base64=item.get("imagesBase64"),
|
||||||
)
|
images_media_types=item.get("imagesMediaTypes"),
|
||||||
|
pending_generation_id=item_id,
|
||||||
|
)
|
||||||
except Exception as e: # noqa: BLE001
|
except Exception as e: # noqa: BLE001
|
||||||
logger.error(f"Error processing {item_id}: {e}")
|
logger.error(f"Error processing {item_id}: {e}")
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
_locks: dict[str, asyncio.Lock] = {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_user_lock(convex_user_id: str) -> asyncio.Lock:
|
||||||
|
lock = _locks.get(convex_user_id)
|
||||||
|
if lock is None:
|
||||||
|
lock = asyncio.Lock()
|
||||||
|
_locks[convex_user_id] = lock
|
||||||
|
return lock
|
||||||
Generated
+127
-42
@@ -154,6 +154,7 @@ source = { editable = "." }
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "aiogram" },
|
{ name = "aiogram" },
|
||||||
{ name = "convex" },
|
{ name = "convex" },
|
||||||
|
{ name = "httpx" },
|
||||||
{ name = "pydantic-ai-slim", extra = ["google"] },
|
{ name = "pydantic-ai-slim", extra = ["google"] },
|
||||||
{ name = "pydantic-settings" },
|
{ name = "pydantic-settings" },
|
||||||
{ name = "rich" },
|
{ name = "rich" },
|
||||||
@@ -164,6 +165,7 @@ dependencies = [
|
|||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "aiogram", specifier = ">=3.24.0" },
|
{ name = "aiogram", specifier = ">=3.24.0" },
|
||||||
{ name = "convex", specifier = ">=0.7.0" },
|
{ name = "convex", specifier = ">=0.7.0" },
|
||||||
|
{ name = "httpx", specifier = ">=0.27" },
|
||||||
{ name = "pydantic-ai-slim", extras = ["google"], specifier = ">=1.44.0" },
|
{ name = "pydantic-ai-slim", extras = ["google"], specifier = ">=1.44.0" },
|
||||||
{ name = "pydantic-settings", specifier = ">=2.12.0" },
|
{ name = "pydantic-settings", specifier = ">=2.12.0" },
|
||||||
{ name = "rich", specifier = ">=14.2.0" },
|
{ name = "rich", specifier = ">=14.2.0" },
|
||||||
@@ -179,6 +181,51 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" },
|
{ url = "https://files.pythonhosted.org/packages/e6/ad/3cc14f097111b4de0040c83a525973216457bbeeb63739ef1ed275c1c021/certifi-2026.1.4-py3-none-any.whl", hash = "sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c", size = 152900, upload-time = "2026-01-04T02:42:40.15Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cffi"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "pycparser", marker = "implementation_name != 'PyPy'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/eb/56/b1ba7935a17738ae8453301356628e8147c79dbb825bcbc73dc7401f9846/cffi-2.0.0.tar.gz", hash = "sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529", size = 523588, upload-time = "2025-09-08T23:24:04.541Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4b/8d/a0a47a0c9e413a658623d014e91e74a50cdd2c423f7ccfd44086ef767f90/cffi-2.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:00bdf7acc5f795150faa6957054fbbca2439db2f775ce831222b66f192f03beb", size = 185230, upload-time = "2025-09-08T23:23:00.879Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4a/d2/a6c0296814556c68ee32009d9c2ad4f85f2707cdecfd7727951ec228005d/cffi-2.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:45d5e886156860dc35862657e1494b9bae8dfa63bf56796f2fb56e1679fc0bca", size = 181043, upload-time = "2025-09-08T23:23:02.231Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b0/1e/d22cc63332bd59b06481ceaac49d6c507598642e2230f201649058a7e704/cffi-2.0.0-cp313-cp313-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:07b271772c100085dd28b74fa0cd81c8fb1a3ba18b21e03d7c27f3436a10606b", size = 212446, upload-time = "2025-09-08T23:23:03.472Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a9/f5/a2c23eb03b61a0b8747f211eb716446c826ad66818ddc7810cc2cc19b3f2/cffi-2.0.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d48a880098c96020b02d5a1f7d9251308510ce8858940e6fa99ece33f610838b", size = 220101, upload-time = "2025-09-08T23:23:04.792Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f2/7f/e6647792fc5850d634695bc0e6ab4111ae88e89981d35ac269956605feba/cffi-2.0.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f93fd8e5c8c0a4aa1f424d6173f14a892044054871c771f8566e4008eaa359d2", size = 207948, upload-time = "2025-09-08T23:23:06.127Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cb/1e/a5a1bd6f1fb30f22573f76533de12a00bf274abcdc55c8edab639078abb6/cffi-2.0.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:dd4f05f54a52fb558f1ba9f528228066954fee3ebe629fc1660d874d040ae5a3", size = 206422, upload-time = "2025-09-08T23:23:07.753Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/98/df/0a1755e750013a2081e863e7cd37e0cdd02664372c754e5560099eb7aa44/cffi-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c8d3b5532fc71b7a77c09192b4a5a200ea992702734a2e9279a37f2478236f26", size = 219499, upload-time = "2025-09-08T23:23:09.648Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/50/e1/a969e687fcf9ea58e6e2a928ad5e2dd88cc12f6f0ab477e9971f2309b57c/cffi-2.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d9b29c1f0ae438d5ee9acb31cadee00a58c46cc9c0b2f9038c6b0b3470877a8c", size = 222928, upload-time = "2025-09-08T23:23:10.928Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/36/54/0362578dd2c9e557a28ac77698ed67323ed5b9775ca9d3fe73fe191bb5d8/cffi-2.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6d50360be4546678fc1b79ffe7a66265e28667840010348dd69a314145807a1b", size = 221302, upload-time = "2025-09-08T23:23:12.42Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/eb/6d/bf9bda840d5f1dfdbf0feca87fbdb64a918a69bca42cfa0ba7b137c48cb8/cffi-2.0.0-cp313-cp313-win32.whl", hash = "sha256:74a03b9698e198d47562765773b4a8309919089150a0bb17d829ad7b44b60d27", size = 172909, upload-time = "2025-09-08T23:23:14.32Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/37/18/6519e1ee6f5a1e579e04b9ddb6f1676c17368a7aba48299c3759bbc3c8b3/cffi-2.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:19f705ada2530c1167abacb171925dd886168931e0a7b78f5bffcae5c6b5be75", size = 183402, upload-time = "2025-09-08T23:23:15.535Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/cb/0e/02ceeec9a7d6ee63bb596121c2c8e9b3a9e150936f4fbef6ca1943e6137c/cffi-2.0.0-cp313-cp313-win_arm64.whl", hash = "sha256:256f80b80ca3853f90c21b23ee78cd008713787b1b1e93eae9f3d6a7134abd91", size = 177780, upload-time = "2025-09-08T23:23:16.761Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/92/c4/3ce07396253a83250ee98564f8d7e9789fab8e58858f35d07a9a2c78de9f/cffi-2.0.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:fc33c5141b55ed366cfaad382df24fe7dcbc686de5be719b207bb248e3053dc5", size = 185320, upload-time = "2025-09-08T23:23:18.087Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/59/dd/27e9fa567a23931c838c6b02d0764611c62290062a6d4e8ff7863daf9730/cffi-2.0.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c654de545946e0db659b3400168c9ad31b5d29593291482c43e3564effbcee13", size = 181487, upload-time = "2025-09-08T23:23:19.622Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d6/43/0e822876f87ea8a4ef95442c3d766a06a51fc5298823f884ef87aaad168c/cffi-2.0.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:24b6f81f1983e6df8db3adc38562c83f7d4a0c36162885ec7f7b77c7dcbec97b", size = 220049, upload-time = "2025-09-08T23:23:20.853Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b4/89/76799151d9c2d2d1ead63c2429da9ea9d7aac304603de0c6e8764e6e8e70/cffi-2.0.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:12873ca6cb9b0f0d3a0da705d6086fe911591737a59f28b7936bdfed27c0d47c", size = 207793, upload-time = "2025-09-08T23:23:22.08Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bb/dd/3465b14bb9e24ee24cb88c9e3730f6de63111fffe513492bf8c808a3547e/cffi-2.0.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:d9b97165e8aed9272a6bb17c01e3cc5871a594a446ebedc996e2397a1c1ea8ef", size = 206300, upload-time = "2025-09-08T23:23:23.314Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/47/d9/d83e293854571c877a92da46fdec39158f8d7e68da75bf73581225d28e90/cffi-2.0.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:afb8db5439b81cf9c9d0c80404b60c3cc9c3add93e114dcae767f1477cb53775", size = 219244, upload-time = "2025-09-08T23:23:24.541Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2b/0f/1f177e3683aead2bb00f7679a16451d302c436b5cbf2505f0ea8146ef59e/cffi-2.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:737fe7d37e1a1bffe70bd5754ea763a62a066dc5913ca57e957824b72a85e205", size = 222828, upload-time = "2025-09-08T23:23:26.143Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/c6/0f/cafacebd4b040e3119dcb32fed8bdef8dfe94da653155f9d0b9dc660166e/cffi-2.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:38100abb9d1b1435bc4cc340bb4489635dc2f0da7456590877030c9b3d40b0c1", size = 220926, upload-time = "2025-09-08T23:23:27.873Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3e/aa/df335faa45b395396fcbc03de2dfcab242cd61a9900e914fe682a59170b1/cffi-2.0.0-cp314-cp314-win32.whl", hash = "sha256:087067fa8953339c723661eda6b54bc98c5625757ea62e95eb4898ad5e776e9f", size = 175328, upload-time = "2025-09-08T23:23:44.61Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bb/92/882c2d30831744296ce713f0feb4c1cd30f346ef747b530b5318715cc367/cffi-2.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:203a48d1fb583fc7d78a4c6655692963b860a417c0528492a6bc21f1aaefab25", size = 185650, upload-time = "2025-09-08T23:23:45.848Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/9f/2c/98ece204b9d35a7366b5b2c6539c350313ca13932143e79dc133ba757104/cffi-2.0.0-cp314-cp314-win_arm64.whl", hash = "sha256:dbd5c7a25a7cb98f5ca55d258b103a2054f859a46ae11aaf23134f9cc0d356ad", size = 180687, upload-time = "2025-09-08T23:23:47.105Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/3e/61/c768e4d548bfa607abcda77423448df8c471f25dbe64fb2ef6d555eae006/cffi-2.0.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:9a67fc9e8eb39039280526379fb3a70023d77caec1852002b4da7e8b270c4dd9", size = 188773, upload-time = "2025-09-08T23:23:29.347Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2c/ea/5f76bce7cf6fcd0ab1a1058b5af899bfbef198bea4d5686da88471ea0336/cffi-2.0.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7a66c7204d8869299919db4d5069a82f1561581af12b11b3c9f48c584eb8743d", size = 185013, upload-time = "2025-09-08T23:23:30.63Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/be/b4/c56878d0d1755cf9caa54ba71e5d049479c52f9e4afc230f06822162ab2f/cffi-2.0.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7cc09976e8b56f8cebd752f7113ad07752461f48a58cbba644139015ac24954c", size = 221593, upload-time = "2025-09-08T23:23:31.91Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e0/0d/eb704606dfe8033e7128df5e90fee946bbcb64a04fcdaa97321309004000/cffi-2.0.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:92b68146a71df78564e4ef48af17551a5ddd142e5190cdf2c5624d0c3ff5b2e8", size = 209354, upload-time = "2025-09-08T23:23:33.214Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d8/19/3c435d727b368ca475fb8742ab97c9cb13a0de600ce86f62eab7fa3eea60/cffi-2.0.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b1e74d11748e7e98e2f426ab176d4ed720a64412b6a15054378afdb71e0f37dc", size = 208480, upload-time = "2025-09-08T23:23:34.495Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/d0/44/681604464ed9541673e486521497406fadcc15b5217c3e326b061696899a/cffi-2.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:28a3a209b96630bca57cce802da70c266eb08c6e97e5afd61a75611ee6c64592", size = 221584, upload-time = "2025-09-08T23:23:36.096Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/25/8e/342a504ff018a2825d395d44d63a767dd8ebc927ebda557fecdaca3ac33a/cffi-2.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:7553fb2090d71822f02c629afe6042c299edf91ba1bf94951165613553984512", size = 224443, upload-time = "2025-09-08T23:23:37.328Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e1/5e/b666bacbbc60fbf415ba9988324a132c9a7a0448a9a8f125074671c0f2c3/cffi-2.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6c6c373cfc5c83a975506110d17457138c8c63016b563cc9ed6e056a82f13ce4", size = 223437, upload-time = "2025-09-08T23:23:38.945Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a0/1d/ec1a60bd1a10daa292d3cd6bb0b359a81607154fb8165f3ec95fe003b85c/cffi-2.0.0-cp314-cp314t-win32.whl", hash = "sha256:1fc9ea04857caf665289b7a75923f2c6ed559b8298a1b8c49e59f7dd95c8481e", size = 180487, upload-time = "2025-09-08T23:23:40.423Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/41/4c1168c74fac325c0c8156f04b6749c8b6a8f405bbf91413ba088359f60d/cffi-2.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:d68b6cef7827e8641e8ef16f4494edda8b36104d79773a334beaa1e3521430f6", size = 191726, upload-time = "2025-09-08T23:23:41.742Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ae/3a/dbeec9d1ee0844c679f6bb5d6ad4e9f198b1224f4e7a32825f47f6192b0c/cffi-2.0.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0a1527a803f0a659de1af2e1fd700213caba79377e27e4693648c2923da066f9", size = 184195, upload-time = "2025-09-08T23:23:43.004Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "charset-normalizer"
|
name = "charset-normalizer"
|
||||||
version = "3.4.4"
|
version = "3.4.4"
|
||||||
@@ -220,15 +267,6 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" },
|
{ url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colorama"
|
|
||||||
version = "0.4.6"
|
|
||||||
source = { registry = "https://pypi.org/simple" }
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
|
|
||||||
wheels = [
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "convex"
|
name = "convex"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -263,6 +301,59 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/5d/a6/b01145a2a25c00024809dedf5fce0dc5e7cb3fbde477112e5569f35ff7d1/convex-0.7.0-cp39-abi3-win_amd64.whl", hash = "sha256:ee71e10a883fed22d2d2d43e828162eb0afe2071699fd36d6b0ba63a9639fee1", size = 1150704, upload-time = "2024-12-17T01:03:22.904Z" },
|
{ url = "https://files.pythonhosted.org/packages/5d/a6/b01145a2a25c00024809dedf5fce0dc5e7cb3fbde477112e5569f35ff7d1/convex-0.7.0-cp39-abi3-win_amd64.whl", hash = "sha256:ee71e10a883fed22d2d2d43e828162eb0afe2071699fd36d6b0ba63a9639fee1", size = 1150704, upload-time = "2024-12-17T01:03:22.904Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cryptography"
|
||||||
|
version = "47.0.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "cffi", marker = "platform_python_implementation != 'PyPy'" },
|
||||||
|
]
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/ef/b2/7ffa7fe8207a8c42147ffe70c3e360b228160c1d85dc3faff16aaa3244c0/cryptography-47.0.0.tar.gz", hash = "sha256:9f8e55fe4e63613a5e1cc5819030f27b97742d720203a087802ce4ce9ceb52bb", size = 830863, upload-time = "2026-04-24T19:54:57.056Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a4/98/40dfe932134bdcae4f6ab5927c87488754bf9eb79297d7e0070b78dd58e9/cryptography-47.0.0-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:160ad728f128972d362e714054f6ba0067cab7fb350c5202a9ae8ae4ce3ef1a0", size = 7912214, upload-time = "2026-04-24T19:53:03.864Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/34/c6/2733531243fba725f58611b918056b277692f1033373dcc8bd01af1c05d4/cryptography-47.0.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:b9a8943e359b7615db1a3ba587994618e094ff3d6fa5a390c73d079ce18b3973", size = 4644617, upload-time = "2026-04-24T19:53:06.909Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/00/e3/b27be1a670a9b87f855d211cf0e1174a5d721216b7616bd52d8581d912ed/cryptography-47.0.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f5c15764f261394b22aef6b00252f5195f46f2ca300bec57149474e2538b31f8", size = 4668186, upload-time = "2026-04-24T19:53:09.053Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/81/b9/8443cfe5d17d482d348cee7048acf502bb89a51b6382f06240fd290d4ca3/cryptography-47.0.0-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:9c59ab0e0fa3a180a5a9c59f3a5abe3ef90d474bc56d7fadfbe80359491b615b", size = 4651244, upload-time = "2026-04-24T19:53:11.217Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/5d/5e/13ed0cdd0eb88ba159d6dd5ebfece8cb901dbcf1ae5ac4072e28b55d3153/cryptography-47.0.0-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:34b4358b925a5ea3e14384ca781a2c0ef7ac219b57bb9eacc4457078e2b19f92", size = 5252906, upload-time = "2026-04-24T19:53:13.532Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/64/16/ed058e1df0f33d440217cd120d41d5dda9dd215a80b8187f68483185af82/cryptography-47.0.0-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:0024b87d47ae2399165a6bfb20d24888881eeab83ae2566d62467c5ff0030ce7", size = 4701842, upload-time = "2026-04-24T19:53:15.618Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/02/e0/3d30986b30fdbd9e969abbdf8ba00ed0618615144341faeb57f395a084fe/cryptography-47.0.0-cp311-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:1e47422b5557bb82d3fff997e8d92cff4e28b9789576984f08c248d2b3535d93", size = 4289313, upload-time = "2026-04-24T19:53:17.755Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/df/fd/32db38e3ad0cb331f0691cb4c7a8a6f176f679124dee746b3af6633db4d9/cryptography-47.0.0-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:6f29f36582e6151d9686235e586dd35bb67491f024767d10b842e520dc6a07ac", size = 4650964, upload-time = "2026-04-24T19:53:20.062Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/86/53/5395d944dfd48cb1f67917f533c609c34347185ef15eb4308024c876f274/cryptography-47.0.0-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:a9b761f012a943b7de0e828843c5688d0de94a0578d44d6c85a1bae32f87791f", size = 5207817, upload-time = "2026-04-24T19:53:22.498Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/34/4f/e5711b28e1901f7d480a2b1b688b645aa4c77c73f10731ed17e7f7db3f0d/cryptography-47.0.0-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:4e1de79e047e25d6e9f8cea71c86b4a53aced64134f0f003bbcbf3655fd172c8", size = 4701544, upload-time = "2026-04-24T19:53:24.356Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/22/22/c8ddc25de3010fc8da447648f5a092c40e7a8fadf01dd6d255d9c0b9373d/cryptography-47.0.0-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:ef6b3634087f18d2155b1e8ce264e5345a753da2c5fa9815e7d41315c90f8318", size = 4783536, upload-time = "2026-04-24T19:53:26.665Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/66/b6/d4a68f4ea999c6d89e8498579cba1c5fcba4276284de7773b17e4fa69293/cryptography-47.0.0-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:11dbb9f50a0f1bb9757b3d8c27c1101780efb8f0bdecfb12439c22a74d64c001", size = 4926106, upload-time = "2026-04-24T19:53:28.686Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/54/ed/5f524db1fade9c013aa618e1c99c6ed05e8ffc9ceee6cda22fed22dda3f4/cryptography-47.0.0-cp311-abi3-win32.whl", hash = "sha256:7fda2f02c9015db3f42bb8a22324a454516ed10a8c29ca6ece6cdbb5efe2a203", size = 3258581, upload-time = "2026-04-24T19:53:31.058Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b2/dc/1b901990b174786569029f67542b3edf72ac068b6c3c8683c17e6a2f5363/cryptography-47.0.0-cp311-abi3-win_amd64.whl", hash = "sha256:f5c3296dab66202f1b18a91fa266be93d6aa0c2806ea3d67762c69f60adc71aa", size = 3775309, upload-time = "2026-04-24T19:53:33.054Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/14/88/7aa18ad9c11bc87689affa5ce4368d884b517502d75739d475fc6f4a03c7/cryptography-47.0.0-cp314-cp314t-macosx_10_9_universal2.whl", hash = "sha256:be12cb6a204f77ed968bcefe68086eb061695b540a3dd05edac507a3111b25f0", size = 7904299, upload-time = "2026-04-24T19:53:35.003Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/07/55/c18f75724544872f234678fdedc871391722cb34a2aee19faa9f63100bb2/cryptography-47.0.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:2ebd84adf0728c039a3be2700289378e1c164afc6748df1a5ed456767bef9ba7", size = 4631180, upload-time = "2026-04-24T19:53:37.517Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/ee/65/31a5cc0eaca99cec5bafffe155d407115d96136bb161e8b49e0ef73f09a7/cryptography-47.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:7f68d6fbc7fbbcfb0939fea72c3b96a9f9a6edfc0e1b1d29778a2066030418b1", size = 4653529, upload-time = "2026-04-24T19:53:39.775Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e5/bc/641c0519a495f3bfd0421b48d7cd325c4336578523ccd76ea322b6c29c7a/cryptography-47.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:6651d32eff255423503aa276739da98c30f26c40cbeffcc6048e0d54ef704c0c", size = 4638570, upload-time = "2026-04-24T19:53:42.129Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/2b/f2/300327b0a47f6dc94dd8b71b57052aefe178bb51745073d73d80604f11ab/cryptography-47.0.0-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:3fb8fa48075fad7193f2e5496135c6a76ac4b2aa5a38433df0a539296b377829", size = 5238019, upload-time = "2026-04-24T19:53:44.577Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e9/5a/5b5cf994391d4bf9d9c7efd4c66aabe4d95227256627f8fea6cff7dfadbd/cryptography-47.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:11438c7518132d95f354fa01a4aa2f806d172a061a7bed18cf18cbdacdb204d7", size = 4686832, upload-time = "2026-04-24T19:53:47.015Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/dc/2c/ae950e28fd6475c852fc21a44db3e6b5bcc1261d1e370f2b6e42fa800fef/cryptography-47.0.0-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:8c1a736bbb3288005796c3f7ccb9453360d7fed483b13b9f468aea5171432923", size = 4269301, upload-time = "2026-04-24T19:53:48.97Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/67/fb/6a39782e150ffe5cc1b0018cb6ddc48bf7ca62b498d7539ffc8a758e977d/cryptography-47.0.0-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:f1557695e5c2b86e204f6ce9470497848634100787935ab7adc5397c54abd7ab", size = 4638110, upload-time = "2026-04-24T19:53:51.011Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8e/d7/0b3c71090a76e5c203164a47688b697635ece006dcd2499ab3a4dbd3f0bd/cryptography-47.0.0-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:f9a034b642b960767fb343766ae5ba6ad653f2e890ddd82955aef288ffea8736", size = 5194988, upload-time = "2026-04-24T19:53:52.962Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/63/33/63a961498a9df51721ab578c5a2622661411fc520e00bd83b0cc64eb20c4/cryptography-47.0.0-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:b1c76fca783aa7698eb21eb14f9c4aa09452248ee54a627d125025a43f83e7a7", size = 4686563, upload-time = "2026-04-24T19:53:55.274Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/b7/bf/5ee5b145248f92250de86145d1c1d6edebbd57a7fe7caa4dedb5d4cf06a1/cryptography-47.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:4f7722c97826770bab8ae92959a2e7b20a5e9e9bf4deae68fd86c3ca457bab52", size = 4770094, upload-time = "2026-04-24T19:53:57.753Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/92/43/21d220b2da5d517773894dacdcdb5c682c28d3fffce65548cb06e87d5501/cryptography-47.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:09f6d7bf6724f8db8b32f11eccf23efc8e759924bc5603800335cf8859a3ddbd", size = 4913811, upload-time = "2026-04-24T19:54:00.236Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/31/98/dc4ad376ac5f1a1a7d4a83f7b0c6f2bcad36b5d2d8f30aeb482d3a7d9582/cryptography-47.0.0-cp314-cp314t-win32.whl", hash = "sha256:6eebcaf0df1d21ce1f90605c9b432dd2c4f4ab665ac29a40d5e3fc68f51b5e63", size = 3237158, upload-time = "2026-04-24T19:54:02.606Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bc/da/97f62d18306b5133468bc3f8cc73a3111e8cdc8cf8d3e69474d6e5fd2d1b/cryptography-47.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:51c9313e90bd1690ec5a75ed047c27c0b8e6c570029712943d6116ef9a90620b", size = 3758706, upload-time = "2026-04-24T19:54:04.433Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/e0/34/a4fae8ae7c3bc227460c9ae43f56abf1b911da0ec29e0ebac53bb0a4b6b7/cryptography-47.0.0-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:14432c8a9bcb37009784f9594a62fae211a2ae9543e96c92b2a8e4c3cd5cd0c4", size = 7904072, upload-time = "2026-04-24T19:54:06.411Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/01/64/d7b1e54fdb69f22d24a64bb3e88dc718b31c7fb10ef0b9691a3cf7eeea6e/cryptography-47.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:07efe86201817e7d3c18781ca9770bc0db04e1e48c994be384e4602bc38f8f27", size = 4635767, upload-time = "2026-04-24T19:54:08.519Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/8b/7b/cca826391fb2a94efdcdfe4631eb69306ee1cff0b22f664a412c90713877/cryptography-47.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:2b45761c6ec22b7c726d6a829558777e32d0f1c8be7c3f3480f9c912d5ee8a10", size = 4654350, upload-time = "2026-04-24T19:54:10.795Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/4c/65/4b57bcc823f42a991627c51c2f68c9fd6eb1393c1756aac876cba2accae2/cryptography-47.0.0-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:edd4da498015da5b9f26d38d3bfc2e90257bfa9cbed1f6767c282a0025ae649b", size = 4643394, upload-time = "2026-04-24T19:54:13.275Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/f4/c4/2c5fbeea70adbbca2bbae865e1d605d6a4a7f8dbd9d33eaf69645087f06c/cryptography-47.0.0-cp38-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:9af828c0d5a65c70ec729cd7495a4bf1a67ecb66417b8f02ff125ab8a6326a74", size = 5225777, upload-time = "2026-04-24T19:54:15.18Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/7e/b8/ac57107ef32749d2b244e36069bb688792a363aaaa3acc9e3cf84c130315/cryptography-47.0.0-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:256d07c78a04d6b276f5df935a9923275f53bd1522f214447fdf365494e2d515", size = 4688771, upload-time = "2026-04-24T19:54:17.835Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/56/fc/9f1de22ff8be99d991f240a46863c52d475404c408886c5a38d2b5c3bb26/cryptography-47.0.0-cp38-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:5d0e362ff51041b0c0d219cc7d6924d7b8996f57ce5712bdcef71eb3c65a59cc", size = 4270753, upload-time = "2026-04-24T19:54:19.963Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/00/68/d70c852797aa68e8e48d12e5a87170c43f67bb4a59403627259dd57d15de/cryptography-47.0.0-cp38-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:1581aef4219f7ca2849d0250edaa3866212fb74bf5667284f46aa92f9e65c1ca", size = 4642911, upload-time = "2026-04-24T19:54:21.818Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/a5/51/661cbee74f594c5d97ff82d34f10d5551c085ca4668645f4606ebd22bd5d/cryptography-47.0.0-cp38-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:a49a3eb5341b9503fa3000a9a0db033161db90d47285291f53c2a9d2cd1b7f76", size = 5181411, upload-time = "2026-04-24T19:54:24.376Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/94/87/f2b6c374a82cf076cfa1416992ac8e8ec94d79facc37aec87c1a5cb72352/cryptography-47.0.0-cp38-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:2207a498b03275d0051589e326b79d4cf59985c99031b05bb292ac52631c37fe", size = 4688262, upload-time = "2026-04-24T19:54:26.946Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/14/e2/8b7462f4acf21ec509616f0245018bb197194ab0b65c2ea21a0bdd53c0eb/cryptography-47.0.0-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:7a02675e2fabd0c0fc04c868b8781863cbf1967691543c22f5470500ff840b31", size = 4775506, upload-time = "2026-04-24T19:54:28.926Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/70/75/158e494e4c08dc05e039da5bb48553826bd26c23930cf8d3cd5f21fa8921/cryptography-47.0.0-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:80887c5cbd1774683cb126f0ab4184567f080071d5acf62205acb354b4b753b7", size = 4912060, upload-time = "2026-04-24T19:54:30.869Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/06/bd/0a9d3edbf5eadbac926d7b9b3cd0c4be584eeeae4a003d24d9eda4affbbd/cryptography-47.0.0-cp38-abi3-win32.whl", hash = "sha256:ed67ea4e0cfb5faa5bc7ecb6e2b8838f3807a03758eec239d6c21c8769355310", size = 3248487, upload-time = "2026-04-24T19:54:33.494Z" },
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/60/80/5681af756d0da3a599b7bdb586fac5a1540f1bcefd2717a20e611ddade45/cryptography-47.0.0-cp38-abi3-win_amd64.whl", hash = "sha256:835d2d7f47cdc53b3224e90810fb1d36ca94ea29cc1801fb4c1bc43876735769", size = 3755737, upload-time = "2026-04-24T19:54:35.408Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "distro"
|
name = "distro"
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
@@ -360,15 +451,15 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "google-auth"
|
name = "google-auth"
|
||||||
version = "2.47.0"
|
version = "2.50.0"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
{ name = "cryptography" },
|
||||||
{ name = "pyasn1-modules" },
|
{ name = "pyasn1-modules" },
|
||||||
{ name = "rsa" },
|
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/60/3c/ec64b9a275ca22fa1cd3b6e77fefcf837b0732c890aa32d2bd21313d9b33/google_auth-2.47.0.tar.gz", hash = "sha256:833229070a9dfee1a353ae9877dcd2dec069a8281a4e72e72f77d4a70ff945da", size = 323719, upload-time = "2026-01-06T21:55:31.045Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/5f/18/238d7021d151bdab868f23433817b027dd759135202f4dfce0670d1230ca/google_auth-2.50.0.tar.gz", hash = "sha256:f35eafb191195328e8ce10a7883970877e7aeb49c2bfaa54aa0e394316d353d0", size = 336523, upload-time = "2026-04-30T21:19:29.659Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/db/18/79e9008530b79527e0d5f79e7eef08d3b179b7f851cfd3a2f27822fbdfa9/google_auth-2.47.0-py3-none-any.whl", hash = "sha256:c516d68336bfde7cf0da26aab674a36fedcf04b37ac4edd59c597178760c3498", size = 234867, upload-time = "2026-01-06T21:55:28.6Z" },
|
{ url = "https://files.pythonhosted.org/packages/37/cf/4880c2137c14280b2f59975cdf12cc442bc0ae1f9ea473a26eaa0c146786/google_auth-2.50.0-py3-none-any.whl", hash = "sha256:04382175e28b94f49694977f0a792688b59a668def1499e9d8de996dc9ce5b15", size = 246495, upload-time = "2026-04-30T21:19:27.664Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.optional-dependencies]
|
[package.optional-dependencies]
|
||||||
@@ -378,7 +469,7 @@ requests = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "google-genai"
|
name = "google-genai"
|
||||||
version = "1.59.0"
|
version = "1.74.0"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "anyio" },
|
{ name = "anyio" },
|
||||||
@@ -392,21 +483,18 @@ dependencies = [
|
|||||||
{ name = "typing-extensions" },
|
{ name = "typing-extensions" },
|
||||||
{ name = "websockets" },
|
{ name = "websockets" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/40/34/c03bcbc759d67ac3d96077838cdc1eac85417de6ea3b65b313fe53043eee/google_genai-1.59.0.tar.gz", hash = "sha256:0b7a2dc24582850ae57294209d8dfc2c4f5fcfde0a3f11d81dc5aca75fb619e2", size = 487374, upload-time = "2026-01-15T20:29:46.619Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/33/c8/4a8f1de0a3268d526a345b8c74456b3e1e6ffd200982626326cf7ca83e5b/google_genai-1.74.0.tar.gz", hash = "sha256:c4c473cebdeb6e5adbb0639326de66a3a85a2209e0d32de7d66bf05c698abae8", size = 536772, upload-time = "2026-04-29T22:16:35.881Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/aa/53/6d00692fe50d73409b3406ae90c71bc4499c8ae7fac377ba16e283da917c/google_genai-1.59.0-py3-none-any.whl", hash = "sha256:59fc01a225d074fe9d1e626c3433da292f33249dadce4deb34edea698305a6df", size = 719099, upload-time = "2026-01-15T20:29:44.604Z" },
|
{ url = "https://files.pythonhosted.org/packages/ca/2b/539c328b66f7bfef2df869371a1789361228e5a7694ba02a642608367b46/google_genai-1.74.0-py3-none-any.whl", hash = "sha256:87d0b311c67d4b2a0ca741e9fc6891330c29defae81d46d8db41079aa1a3d80a", size = 790433, upload-time = "2026-04-29T22:16:33.979Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "griffe"
|
name = "griffelib"
|
||||||
version = "1.15.0"
|
version = "2.0.2"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
sdist = { url = "https://files.pythonhosted.org/packages/9d/82/74f4a3310cdabfbb10da554c3a672847f1ed33c6f61dd472681ce7f1fe67/griffelib-2.0.2.tar.gz", hash = "sha256:3cf20b3bc470e83763ffbf236e0076b1211bac1bc67de13daf494640f2de707e", size = 166461, upload-time = "2026-03-27T11:34:51.091Z" }
|
||||||
{ name = "colorama" },
|
|
||||||
]
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/0d/0c/3a471b6e31951dce2360477420d0a8d1e00dea6cf33b70f3e8c3ab6e28e1/griffe-1.15.0.tar.gz", hash = "sha256:7726e3afd6f298fbc3696e67958803e7ac843c1cfe59734b6251a40cdbfb5eea", size = 424112, upload-time = "2025-11-10T15:03:15.52Z" }
|
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/9c/83/3b1d03d36f224edded98e9affd0467630fc09d766c0e56fb1498cbb04a9b/griffe-1.15.0-py3-none-any.whl", hash = "sha256:6f6762661949411031f5fcda9593f586e6ce8340f0ba88921a0f2ef7a81eb9a3", size = 150705, upload-time = "2025-11-10T15:03:13.549Z" },
|
{ url = "https://files.pythonhosted.org/packages/11/8c/c9138d881c79aa0ea9ed83cbd58d5ca75624378b38cee225dcf5c42cc91f/griffelib-2.0.2-py3-none-any.whl", hash = "sha256:925c857658fb1ba40c0772c37acbc2ab650bd794d9c1b9726922e36ea4117ea1", size = 142357, upload-time = "2026-03-27T11:34:46.275Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -690,6 +778,15 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/47/8d/d529b5d697919ba8c11ad626e835d4039be708a35b0d22de83a269a6682c/pyasn1_modules-0.4.2-py3-none-any.whl", hash = "sha256:29253a9207ce32b64c3ac6600edc75368f98473906e8fd1043bd6b5b1de2c14a", size = 181259, upload-time = "2025-03-28T02:41:19.028Z" },
|
{ url = "https://files.pythonhosted.org/packages/47/8d/d529b5d697919ba8c11ad626e835d4039be708a35b0d22de83a269a6682c/pyasn1_modules-0.4.2-py3-none-any.whl", hash = "sha256:29253a9207ce32b64c3ac6600edc75368f98473906e8fd1043bd6b5b1de2c14a", size = 181259, upload-time = "2025-03-28T02:41:19.028Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pycparser"
|
||||||
|
version = "3.0"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/1b/7d/92392ff7815c21062bea51aa7b87d45576f649f16458d78b7cf94b9ab2e6/pycparser-3.0.tar.gz", hash = "sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29", size = 103492, upload-time = "2026-01-21T14:26:51.89Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/0c/c3/44f3fbbfa403ea2a7c779186dc20772604442dde72947e7d01069cbe98e3/pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992", size = 48172, upload-time = "2026-01-21T14:26:50.693Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pydantic"
|
name = "pydantic"
|
||||||
version = "2.12.5"
|
version = "2.12.5"
|
||||||
@@ -707,20 +804,20 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pydantic-ai-slim"
|
name = "pydantic-ai-slim"
|
||||||
version = "1.44.0"
|
version = "1.89.1"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "genai-prices" },
|
{ name = "genai-prices" },
|
||||||
{ name = "griffe" },
|
{ name = "griffelib" },
|
||||||
{ name = "httpx" },
|
{ name = "httpx" },
|
||||||
{ name = "opentelemetry-api" },
|
{ name = "opentelemetry-api" },
|
||||||
{ name = "pydantic" },
|
{ name = "pydantic" },
|
||||||
{ name = "pydantic-graph" },
|
{ name = "pydantic-graph" },
|
||||||
{ name = "typing-inspection" },
|
{ name = "typing-inspection" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/24/73/122aafb9bcad78042e2799649db745c357fc594e112c0ad0d8d183fdc447/pydantic_ai_slim-1.44.0.tar.gz", hash = "sha256:1bda6dbec4b94d8e52e32eb1e4c1da14f4f0202414306c65e2c3b43bebd82407", size = 378362, upload-time = "2026-01-17T01:26:09.64Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/23/91/b2134056eb5debb7cb28e4efe7ca19fc5c7b2935e55b299a30ddad0d7746/pydantic_ai_slim-1.89.1.tar.gz", hash = "sha256:3ed967bff8dec992a907c1d1dabab2034a5f4aee75289de22e88b2ef9def8da6", size = 614728, upload-time = "2026-05-01T19:09:38.551Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/1a/18/2f68a9718843a95c0b4724ab3821ef8f60f7b8ef50e70b3769db3259da81/pydantic_ai_slim-1.44.0-py3-none-any.whl", hash = "sha256:3bf412f43d3ae787350d671f873706ad74603777e04f42411c8fbdf7dced8031", size = 496441, upload-time = "2026-01-17T01:26:00.184Z" },
|
{ url = "https://files.pythonhosted.org/packages/95/14/d0f7c8f828c460a517531e0df7cfe9e20f4315da8357a9068caaf0193bbb/pydantic_ai_slim-1.89.1-py3-none-any.whl", hash = "sha256:9e7d615a0a3e48993d067901e596e85708e9c8d1f6bef96c20c340385028d465", size = 780314, upload-time = "2026-05-01T19:09:28.843Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.optional-dependencies]
|
[package.optional-dependencies]
|
||||||
@@ -783,7 +880,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pydantic-graph"
|
name = "pydantic-graph"
|
||||||
version = "1.44.0"
|
version = "1.89.1"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "httpx" },
|
{ name = "httpx" },
|
||||||
@@ -791,9 +888,9 @@ dependencies = [
|
|||||||
{ name = "pydantic" },
|
{ name = "pydantic" },
|
||||||
{ name = "typing-inspection" },
|
{ name = "typing-inspection" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/aa/d9/83f1921633634cb1fd5947ebdc48a992cd1e660d9d0ba10f23450af654b8/pydantic_graph-1.44.0.tar.gz", hash = "sha256:81bb14bb47d3313fd7114f3ae9650dab77729451659e0247d298e1800f997c23", size = 58454, upload-time = "2026-01-17T01:26:12.113Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/ea/64/f26c4d17568ab06ae576af0771ad83753cc2661bf9ca5a5698d01404ee20/pydantic_graph-1.89.1.tar.gz", hash = "sha256:99b8ae10fd10400208ee469355969e2dc253a600c3f667a5e790874064846e85", size = 59257, upload-time = "2026-05-01T19:09:40.998Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/6f/e6/f9ed700171435309e214cf19012cf3b391d10ec28786d4a567ee315b1acd/pydantic_graph-1.44.0-py3-none-any.whl", hash = "sha256:5affbfe5779f79946de2c6a6524b98e2344982a129b2a1e19d031e76a5bc1e51", size = 72324, upload-time = "2026-01-17T01:26:04.119Z" },
|
{ url = "https://files.pythonhosted.org/packages/7e/52/9070e11f52424fe34e2ca96ae122902cab7c4325e2a90b33d44a410843b1/pydantic_graph-1.89.1-py3-none-any.whl", hash = "sha256:2ebce28573e81de9924c2ff68f90f949ccd96bbc2e8dc6cf4bb96208b34fbec0", size = 73065, upload-time = "2026-05-01T19:09:32.912Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -856,18 +953,6 @@ wheels = [
|
|||||||
{ url = "https://files.pythonhosted.org/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd", size = 243393, upload-time = "2025-10-09T14:16:51.245Z" },
|
{ url = "https://files.pythonhosted.org/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd", size = 243393, upload-time = "2025-10-09T14:16:51.245Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rsa"
|
|
||||||
version = "4.9.1"
|
|
||||||
source = { registry = "https://pypi.org/simple" }
|
|
||||||
dependencies = [
|
|
||||||
{ name = "pyasn1" },
|
|
||||||
]
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/da/8a/22b7beea3ee0d44b1916c0c1cb0ee3af23b700b6da9f04991899d0c555d4/rsa-4.9.1.tar.gz", hash = "sha256:e7bdbfdb5497da4c07dfd35530e1a902659db6ff241e39d9953cad06ebd0ae75", size = 29034, upload-time = "2025-04-16T09:51:18.218Z" }
|
|
||||||
wheels = [
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/64/8d/0133e4eb4beed9e425d9a98ed6e081a55d195481b7632472be1af08d2f6b/rsa-4.9.1-py3-none-any.whl", hash = "sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea243539fe239762", size = 34696, upload-time = "2025-04-16T09:51:17.142Z" },
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sniffio"
|
name = "sniffio"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { processContent } from '$lib/utils/markdown';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
content: string;
|
||||||
|
images?: string[];
|
||||||
|
mediaTypes?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
let { content, images = [], mediaTypes = [] }: Props = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="prose-mini w-full rounded-lg bg-blue-600 px-2.5 py-1.5 text-[11px] leading-relaxed text-white opacity-60"
|
||||||
|
>
|
||||||
|
{#if images.length > 0}
|
||||||
|
<div class="mb-1 flex flex-wrap gap-1">
|
||||||
|
{#each images as img, i (i)}
|
||||||
|
<img
|
||||||
|
src={`data:${mediaTypes[i] ?? 'image/jpeg'};base64,${img}`}
|
||||||
|
alt=""
|
||||||
|
class="max-h-16 rounded"
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if content}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
<div>{@html processContent(content)}</div>
|
||||||
|
{/if}
|
||||||
|
<div class="mt-1 flex items-center gap-1 text-[8px] text-blue-100/80">
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
class="h-2.5 w-2.5 animate-spin"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="3" opacity="0.3" />
|
||||||
|
<path
|
||||||
|
d="M12 2a10 10 0 0 1 10 10"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width="3"
|
||||||
|
stroke-linecap="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span>в очереди</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -52,8 +52,48 @@ export const create = mutation({
|
|||||||
followUpOptions: v.optional(v.array(v.string())),
|
followUpOptions: v.optional(v.array(v.string())),
|
||||||
isStreaming: v.optional(v.boolean())
|
isStreaming: v.optional(v.boolean())
|
||||||
},
|
},
|
||||||
returns: v.id('messages'),
|
returns: v.union(v.id('messages'), v.null()),
|
||||||
handler: async (ctx, args) => {
|
handler: async (ctx, args) => {
|
||||||
|
const drafts: Array<{ base64: string; mediaType: string; id: Id<'photoDrafts'> }> = [];
|
||||||
|
if (args.photoDraftIds && args.photoDraftIds.length > 0) {
|
||||||
|
for (const draftId of args.photoDraftIds) {
|
||||||
|
const draft = await ctx.db.get(draftId);
|
||||||
|
if (draft) {
|
||||||
|
drafts.push({ base64: draft.base64, mediaType: draft.mediaType, id: draft._id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.source === 'web' && args.role === 'user') {
|
||||||
|
const chat = await ctx.db.get(args.chatId);
|
||||||
|
if (chat) {
|
||||||
|
const pendingGenId = await ctx.db.insert('pendingGenerations', {
|
||||||
|
userId: chat.userId,
|
||||||
|
chatId: args.chatId,
|
||||||
|
userMessage: args.content,
|
||||||
|
imagesBase64: drafts.length > 0 ? drafts.map((d) => d.base64) : args.imagesBase64,
|
||||||
|
imagesMediaTypes:
|
||||||
|
drafts.length > 0 ? drafts.map((d) => d.mediaType) : args.imagesMediaTypes,
|
||||||
|
createdAt: Date.now()
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < drafts.length; i++) {
|
||||||
|
await ctx.db.insert('pendingGenerationImages', {
|
||||||
|
pendingGenerationId: pendingGenId,
|
||||||
|
base64: drafts[i].base64,
|
||||||
|
mediaType: drafts[i].mediaType,
|
||||||
|
order: i
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const draft of drafts) {
|
||||||
|
await ctx.db.delete(draft.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const messageId = await ctx.db.insert('messages', {
|
const messageId = await ctx.db.insert('messages', {
|
||||||
chatId: args.chatId,
|
chatId: args.chatId,
|
||||||
role: args.role,
|
role: args.role,
|
||||||
@@ -68,16 +108,6 @@ export const create = mutation({
|
|||||||
isStreaming: args.isStreaming
|
isStreaming: args.isStreaming
|
||||||
});
|
});
|
||||||
|
|
||||||
const drafts: Array<{ base64: string; mediaType: string; id: Id<'photoDrafts'> }> = [];
|
|
||||||
if (args.photoDraftIds && args.photoDraftIds.length > 0) {
|
|
||||||
for (const draftId of args.photoDraftIds) {
|
|
||||||
const draft = await ctx.db.get(draftId);
|
|
||||||
if (draft) {
|
|
||||||
drafts.push({ base64: draft.base64, mediaType: draft.mediaType, id: draft._id });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < drafts.length; i++) {
|
for (let i = 0; i < drafts.length; i++) {
|
||||||
await ctx.db.insert('messageImages', {
|
await ctx.db.insert('messageImages', {
|
||||||
messageId,
|
messageId,
|
||||||
@@ -87,27 +117,6 @@ export const create = mutation({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.source === 'web' && args.role === 'user') {
|
|
||||||
const chat = await ctx.db.get(args.chatId);
|
|
||||||
if (chat) {
|
|
||||||
const pendingGenId = await ctx.db.insert('pendingGenerations', {
|
|
||||||
userId: chat.userId,
|
|
||||||
chatId: args.chatId,
|
|
||||||
userMessage: args.content,
|
|
||||||
createdAt: Date.now()
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < drafts.length; i++) {
|
|
||||||
await ctx.db.insert('pendingGenerationImages', {
|
|
||||||
pendingGenerationId: pendingGenId,
|
|
||||||
base64: drafts[i].base64,
|
|
||||||
mediaType: drafts[i].mediaType,
|
|
||||||
order: i
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const draft of drafts) {
|
for (const draft of drafts) {
|
||||||
await ctx.db.delete(draft.id);
|
await ctx.db.delete(draft.id);
|
||||||
}
|
}
|
||||||
@@ -116,6 +125,31 @@ export const create = mutation({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const createFromBackend = mutation({
|
||||||
|
args: {
|
||||||
|
chatId: v.id('chats'),
|
||||||
|
role: v.union(v.literal('user'), v.literal('assistant')),
|
||||||
|
content: v.string(),
|
||||||
|
source: v.union(v.literal('telegram'), v.literal('web')),
|
||||||
|
imagesBase64: v.optional(v.array(v.string())),
|
||||||
|
imagesMediaTypes: v.optional(v.array(v.string())),
|
||||||
|
isStreaming: v.optional(v.boolean())
|
||||||
|
},
|
||||||
|
returns: v.id('messages'),
|
||||||
|
handler: async (ctx, args) => {
|
||||||
|
return await ctx.db.insert('messages', {
|
||||||
|
chatId: args.chatId,
|
||||||
|
role: args.role,
|
||||||
|
content: args.content,
|
||||||
|
source: args.source,
|
||||||
|
imagesBase64: args.imagesBase64,
|
||||||
|
imagesMediaTypes: args.imagesMediaTypes,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
isStreaming: args.isStreaming
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const update = mutation({
|
export const update = mutation({
|
||||||
args: {
|
args: {
|
||||||
messageId: v.id('messages'),
|
messageId: v.id('messages'),
|
||||||
|
|||||||
@@ -40,6 +40,50 @@ export const list = query({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const listByChat = query({
|
||||||
|
args: { chatId: v.id('chats') },
|
||||||
|
returns: v.array(
|
||||||
|
v.object({
|
||||||
|
_id: v.id('pendingGenerations'),
|
||||||
|
_creationTime: v.number(),
|
||||||
|
userMessage: v.string(),
|
||||||
|
imagesBase64: v.optional(v.array(v.string())),
|
||||||
|
imagesMediaTypes: v.optional(v.array(v.string())),
|
||||||
|
createdAt: v.number()
|
||||||
|
})
|
||||||
|
),
|
||||||
|
handler: async (ctx, args) => {
|
||||||
|
const pending = await ctx.db
|
||||||
|
.query('pendingGenerations')
|
||||||
|
.withIndex('by_chat_id', (q) => q.eq('chatId', args.chatId))
|
||||||
|
.order('asc')
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
const result = [];
|
||||||
|
for (const p of pending) {
|
||||||
|
const images = await ctx.db
|
||||||
|
.query('pendingGenerationImages')
|
||||||
|
.withIndex('by_pending_generation_id', (q) => q.eq('pendingGenerationId', p._id))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
const sortedImages = images.sort((a, b) => a.order - b.order);
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
_id: p._id,
|
||||||
|
_creationTime: p._creationTime,
|
||||||
|
userMessage: p.userMessage,
|
||||||
|
imagesBase64:
|
||||||
|
sortedImages.length > 0 ? sortedImages.map((img) => img.base64) : p.imagesBase64,
|
||||||
|
imagesMediaTypes:
|
||||||
|
sortedImages.length > 0 ? sortedImages.map((img) => img.mediaType) : p.imagesMediaTypes,
|
||||||
|
createdAt: p.createdAt
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const create = mutation({
|
export const create = mutation({
|
||||||
args: {
|
args: {
|
||||||
userId: v.id('users'),
|
userId: v.id('users'),
|
||||||
@@ -61,6 +105,10 @@ export const remove = mutation({
|
|||||||
args: { id: v.id('pendingGenerations') },
|
args: { id: v.id('pendingGenerations') },
|
||||||
returns: v.null(),
|
returns: v.null(),
|
||||||
handler: async (ctx, args) => {
|
handler: async (ctx, args) => {
|
||||||
|
const existing = await ctx.db.get(args.id);
|
||||||
|
if (!existing) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const images = await ctx.db
|
const images = await ctx.db
|
||||||
.query('pendingGenerationImages')
|
.query('pendingGenerationImages')
|
||||||
.withIndex('by_pending_generation_id', (q) => q.eq('pendingGenerationId', args.id))
|
.withIndex('by_pending_generation_id', (q) => q.eq('pendingGenerationId', args.id))
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default defineSchema({
|
|||||||
imagesBase64: v.optional(v.array(v.string())),
|
imagesBase64: v.optional(v.array(v.string())),
|
||||||
imagesMediaTypes: v.optional(v.array(v.string())),
|
imagesMediaTypes: v.optional(v.array(v.string())),
|
||||||
createdAt: v.number()
|
createdAt: v.number()
|
||||||
}),
|
}).index('by_chat_id', ['chatId']),
|
||||||
|
|
||||||
pendingGenerationImages: defineTable({
|
pendingGenerationImages: defineTable({
|
||||||
pendingGenerationId: v.id('pendingGenerations'),
|
pendingGenerationId: v.id('pendingGenerations'),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
import { api } from '$lib/convex/_generated/api';
|
import { api } from '$lib/convex/_generated/api';
|
||||||
import type { Id } from '$lib/convex/_generated/dataModel';
|
import type { Id } from '$lib/convex/_generated/dataModel';
|
||||||
import ChatMessage from '$lib/components/ChatMessage.svelte';
|
import ChatMessage from '$lib/components/ChatMessage.svelte';
|
||||||
|
import PendingMessageBubble from '$lib/components/PendingMessageBubble.svelte';
|
||||||
import ChatInput from '$lib/components/ChatInput.svelte';
|
import ChatInput from '$lib/components/ChatInput.svelte';
|
||||||
import FollowUpButtons from '$lib/components/FollowUpButtons.svelte';
|
import FollowUpButtons from '$lib/components/FollowUpButtons.svelte';
|
||||||
import StealthOverlay from '$lib/components/StealthOverlay.svelte';
|
import StealthOverlay from '$lib/components/StealthOverlay.svelte';
|
||||||
@@ -117,7 +118,16 @@
|
|||||||
: null;
|
: null;
|
||||||
const messagesQuery = $derived(usePolling ? messagesQueryPoll! : messagesQueryWs!);
|
const messagesQuery = $derived(usePolling ? messagesQueryPoll! : messagesQueryWs!);
|
||||||
|
|
||||||
|
const pendingQueryWs = usePolling
|
||||||
|
? null
|
||||||
|
: useQuery(api.pendingGenerations.listByChat, () => (chatId ? { chatId } : 'skip'));
|
||||||
|
const pendingQueryPoll = usePolling
|
||||||
|
? usePollingQuery(api.pendingGenerations.listByChat, () => (chatId ? { chatId } : 'skip'))
|
||||||
|
: null;
|
||||||
|
const pendingQuery = $derived(usePolling ? pendingQueryPoll! : pendingQueryWs!);
|
||||||
|
|
||||||
let messages = $derived(messagesQuery.data ?? []);
|
let messages = $derived(messagesQuery.data ?? []);
|
||||||
|
let pendingMessages = $derived(pendingQuery.data ?? []);
|
||||||
let lastMessage = $derived(messages[messages.length - 1]);
|
let lastMessage = $derived(messages[messages.length - 1]);
|
||||||
let followUpOptions = $derived(
|
let followUpOptions = $derived(
|
||||||
lastMessage?.role === 'assistant' && lastMessage.followUpOptions
|
lastMessage?.role === 'assistant' && lastMessage.followUpOptions
|
||||||
@@ -263,12 +273,19 @@
|
|||||||
|
|
||||||
let prevMessageCount = 0;
|
let prevMessageCount = 0;
|
||||||
let prevLastMessageId: string | undefined;
|
let prevLastMessageId: string | undefined;
|
||||||
|
let prevPendingCount = 0;
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const count = messages.length;
|
const count = messages.length;
|
||||||
const lastId = lastMessage?._id;
|
const lastId = lastMessage?._id;
|
||||||
if (count > prevMessageCount || (lastId && lastId !== prevLastMessageId)) {
|
const pendingCount = pendingMessages.length;
|
||||||
|
if (
|
||||||
|
count > prevMessageCount ||
|
||||||
|
pendingCount > prevPendingCount ||
|
||||||
|
(lastId && lastId !== prevLastMessageId)
|
||||||
|
) {
|
||||||
prevMessageCount = count;
|
prevMessageCount = count;
|
||||||
|
prevPendingCount = pendingCount;
|
||||||
prevLastMessageId = lastId;
|
prevLastMessageId = lastId;
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
@@ -577,7 +594,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
{#each messages as message, i (message._id)}
|
{#each messages as message, i (message._id)}
|
||||||
{#if i === messages.length - 1}
|
{#if i === messages.length - 1 && pendingMessages.length === 0}
|
||||||
<div bind:this={lastMessageElement}>
|
<div bind:this={lastMessageElement}>
|
||||||
<ChatMessage
|
<ChatMessage
|
||||||
role={message.role}
|
role={message.role}
|
||||||
@@ -593,6 +610,23 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
{#each pendingMessages as p, i (p._id)}
|
||||||
|
{#if i === pendingMessages.length - 1}
|
||||||
|
<div bind:this={lastMessageElement}>
|
||||||
|
<PendingMessageBubble
|
||||||
|
content={p.userMessage}
|
||||||
|
images={p.imagesBase64 ?? []}
|
||||||
|
mediaTypes={p.imagesMediaTypes ?? []}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<PendingMessageBubble
|
||||||
|
content={p.userMessage}
|
||||||
|
images={p.imagesBase64 ?? []}
|
||||||
|
mediaTypes={p.imagesMediaTypes ?? []}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if followUpOptions.length > 0}
|
{#if followUpOptions.length > 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user