meshagent-agents 0.5.3__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of meshagent-agents might be problematic. Click here for more details.
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/CHANGELOG.md +3 -0
- {meshagent_agents-0.5.3/meshagent_agents.egg-info → meshagent_agents-0.5.4}/PKG-INFO +6 -6
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/chat.py +200 -161
- meshagent_agents-0.5.4/meshagent/agents/version.py +1 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4/meshagent_agents.egg-info}/PKG-INFO +6 -6
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent_agents.egg-info/requires.txt +5 -5
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/pyproject.toml +5 -5
- meshagent_agents-0.5.3/meshagent/agents/version.py +0 -1
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/LICENSE +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/MANIFEST.in +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/README.md +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/__init__.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/adapter.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/agent.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/context.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/development.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/hosting.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/indexer.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/listener.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/mail.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/planning.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/prompt.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/pydantic.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/__init__.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/document.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/gallery.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/presentation.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/schema.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/super_editor_document.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/single_shot_writer.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/thread_schema.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/utils.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/worker.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/writer.py +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent_agents.egg-info/SOURCES.txt +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent_agents.egg-info/dependency_links.txt +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent_agents.egg-info/top_level.txt +0 -0
- {meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-agents
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: Agent Building Blocks for Meshagent
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Documentation, https://docs.meshagent.com
|
|
@@ -12,19 +12,19 @@ License-File: LICENSE
|
|
|
12
12
|
Requires-Dist: pyjwt~=2.10
|
|
13
13
|
Requires-Dist: pytest~=8.4
|
|
14
14
|
Requires-Dist: pytest-asyncio~=0.26
|
|
15
|
-
Requires-Dist: meshagent-api~=0.5.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.5.
|
|
17
|
-
Requires-Dist: meshagent-openai~=0.5.
|
|
15
|
+
Requires-Dist: meshagent-api~=0.5.4
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.5.4
|
|
17
|
+
Requires-Dist: meshagent-openai~=0.5.4
|
|
18
18
|
Requires-Dist: pydantic~=2.11
|
|
19
19
|
Requires-Dist: opentelemetry-distro~=0.54b1
|
|
20
20
|
Provides-Extra: all
|
|
21
|
-
Requires-Dist: meshagent-api[all]~=0.5.
|
|
21
|
+
Requires-Dist: meshagent-api[all]~=0.5.4; extra == "all"
|
|
22
22
|
Requires-Dist: chonkie~=0.5.1; extra == "all"
|
|
23
23
|
Requires-Dist: chonkie[semantic]~=0.5.1; extra == "all"
|
|
24
24
|
Requires-Dist: chonkie[openai]~=0.5.1; extra == "all"
|
|
25
25
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "all"
|
|
26
26
|
Provides-Extra: sync
|
|
27
|
-
Requires-Dist: meshagent-api[sync]~=0.5.
|
|
27
|
+
Requires-Dist: meshagent-api[sync]~=0.5.4; extra == "sync"
|
|
28
28
|
Provides-Extra: mail
|
|
29
29
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
|
|
30
30
|
Provides-Extra: rag
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from .agent import SingleRoomAgent, AgentChatContext
|
|
1
|
+
from meshagent.agents.agent import SingleRoomAgent, AgentChatContext
|
|
2
2
|
from meshagent.api.chan import Chan
|
|
3
3
|
from meshagent.api import (
|
|
4
4
|
RoomMessage,
|
|
@@ -10,7 +10,7 @@ from meshagent.api import (
|
|
|
10
10
|
MeshDocument,
|
|
11
11
|
)
|
|
12
12
|
from meshagent.tools import Toolkit, ToolContext
|
|
13
|
-
from .adapter import LLMAdapter, ToolResponseAdapter
|
|
13
|
+
from meshagent.agents.adapter import LLMAdapter, ToolResponseAdapter
|
|
14
14
|
from meshagent.openai.tools.responses_adapter import ImageGenerationTool, LocalShellTool
|
|
15
15
|
import asyncio
|
|
16
16
|
from typing import Optional
|
|
@@ -22,6 +22,7 @@ from typing import Literal
|
|
|
22
22
|
import base64
|
|
23
23
|
from openai.types.responses import ResponseStreamEvent
|
|
24
24
|
from asyncio import CancelledError
|
|
25
|
+
from meshagent.api import RoomException
|
|
25
26
|
|
|
26
27
|
from opentelemetry import trace
|
|
27
28
|
import shlex
|
|
@@ -307,13 +308,22 @@ class ChatBot(SingleRoomAgent):
|
|
|
307
308
|
|
|
308
309
|
async def _send_and_save_chat(
|
|
309
310
|
self,
|
|
310
|
-
|
|
311
|
+
thread: MeshDocument,
|
|
311
312
|
path: str,
|
|
312
313
|
to: RemoteParticipant,
|
|
313
314
|
id: str,
|
|
314
315
|
text: str,
|
|
315
316
|
thread_attributes: dict,
|
|
316
317
|
):
|
|
318
|
+
messages = None
|
|
319
|
+
|
|
320
|
+
for prop in thread.root.get_children():
|
|
321
|
+
if prop.tag_name == "messages":
|
|
322
|
+
messages = prop
|
|
323
|
+
|
|
324
|
+
if messages is None:
|
|
325
|
+
raise RoomException("messages element was not found in thread document")
|
|
326
|
+
|
|
317
327
|
with tracer.start_as_current_span("chatbot.thread.message") as span:
|
|
318
328
|
span.set_attributes(thread_attributes)
|
|
319
329
|
span.set_attribute("role", "assistant")
|
|
@@ -339,10 +349,10 @@ class ChatBot(SingleRoomAgent):
|
|
|
339
349
|
},
|
|
340
350
|
)
|
|
341
351
|
|
|
342
|
-
async def
|
|
352
|
+
async def _greet(
|
|
343
353
|
self,
|
|
344
354
|
*,
|
|
345
|
-
|
|
355
|
+
thread: MeshDocument,
|
|
346
356
|
path: str,
|
|
347
357
|
chat_context: AgentChatContext,
|
|
348
358
|
participant: RemoteParticipant,
|
|
@@ -353,7 +363,7 @@ class ChatBot(SingleRoomAgent):
|
|
|
353
363
|
await self._send_and_save_chat(
|
|
354
364
|
id=str(uuid.uuid4()),
|
|
355
365
|
to=RemoteParticipant(id=participant.id),
|
|
356
|
-
|
|
366
|
+
thread=thread,
|
|
357
367
|
path=path,
|
|
358
368
|
text=self._auto_greet_message,
|
|
359
369
|
thread_attributes=thread_attributes,
|
|
@@ -403,107 +413,149 @@ class ChatBot(SingleRoomAgent):
|
|
|
403
413
|
async def close_thread(self, *, path: str):
|
|
404
414
|
return await self.room.sync.close(path=path)
|
|
405
415
|
|
|
406
|
-
async def
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
416
|
+
async def load_thread_context(self, *, thread_context: ChatThreadContext):
|
|
417
|
+
"""
|
|
418
|
+
load the thread from the thread document by inserting the current messages in the thread into the chat context
|
|
419
|
+
"""
|
|
420
|
+
thread = thread_context.thread
|
|
421
|
+
chat_context = thread_context.chat
|
|
422
|
+
for prop in thread.root.get_children():
|
|
423
|
+
if prop.tag_name == "messages":
|
|
424
|
+
doc_messages = prop
|
|
425
|
+
|
|
426
|
+
for element in doc_messages.get_children():
|
|
427
|
+
if isinstance(element, Element) and element.tag_name == "message":
|
|
428
|
+
msg = element["text"]
|
|
429
|
+
if element[
|
|
430
|
+
"author_name"
|
|
431
|
+
] == self.room.local_participant.get_attribute("name"):
|
|
432
|
+
chat_context.append_assistant_message(msg)
|
|
433
|
+
else:
|
|
434
|
+
chat_context.append_user_message(msg)
|
|
435
|
+
|
|
436
|
+
for child in element.get_children():
|
|
437
|
+
if child.tag_name == "file":
|
|
438
|
+
chat_context.append_assistant_message(
|
|
439
|
+
f"the user attached a file with the path '{child.get_attribute('path')}'"
|
|
440
|
+
)
|
|
412
441
|
|
|
442
|
+
if doc_messages is None:
|
|
443
|
+
raise Exception("thread was not properly initialized")
|
|
444
|
+
|
|
445
|
+
async def prepare_llm_context(self, *, context: ChatThreadContext):
|
|
446
|
+
"""
|
|
447
|
+
called prior to sending the request to the LLM in case the agent needs to modify the context prior to sending
|
|
448
|
+
"""
|
|
449
|
+
pass
|
|
450
|
+
|
|
451
|
+
async def _process_llm_events(
|
|
452
|
+
self,
|
|
453
|
+
*,
|
|
454
|
+
thread_context: ChatThreadContext,
|
|
455
|
+
llm_messages: asyncio.Queue,
|
|
456
|
+
thread_attributes: dict,
|
|
457
|
+
):
|
|
458
|
+
thread = thread_context.thread
|
|
413
459
|
doc_messages = None
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
460
|
+
for prop in thread.root.get_children():
|
|
461
|
+
if prop.tag_name == "messages":
|
|
462
|
+
doc_messages = prop
|
|
417
463
|
|
|
418
|
-
|
|
464
|
+
if doc_messages is None:
|
|
465
|
+
raise RoomException("messages element is missing from thread document")
|
|
466
|
+
|
|
467
|
+
context_message = None
|
|
468
|
+
updates = asyncio.Queue()
|
|
419
469
|
|
|
420
|
-
|
|
470
|
+
# throttle updates so we don't send too many syncs over the wire at once
|
|
471
|
+
async def update_thread():
|
|
421
472
|
try:
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
context_message = None
|
|
428
|
-
updates = asyncio.Queue()
|
|
429
|
-
|
|
430
|
-
# throttle updates so we don't send too many syncs over the wire at once
|
|
431
|
-
async def update_thread():
|
|
432
|
-
try:
|
|
433
|
-
changes = {}
|
|
434
|
-
while True:
|
|
435
|
-
try:
|
|
436
|
-
element, partial = updates.get_nowait()
|
|
437
|
-
changes[element] = partial
|
|
473
|
+
changes = {}
|
|
474
|
+
while True:
|
|
475
|
+
try:
|
|
476
|
+
element, partial = updates.get_nowait()
|
|
477
|
+
changes[element] = partial
|
|
438
478
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
479
|
+
except asyncio.QueueEmpty:
|
|
480
|
+
for e, p in changes.items():
|
|
481
|
+
e["text"] = p
|
|
442
482
|
|
|
443
|
-
|
|
483
|
+
changes.clear()
|
|
444
484
|
|
|
445
|
-
|
|
446
|
-
|
|
485
|
+
e, p = await updates.get()
|
|
486
|
+
changes[e] = p
|
|
447
487
|
|
|
448
|
-
|
|
488
|
+
await asyncio.sleep(0.1)
|
|
449
489
|
|
|
450
|
-
|
|
451
|
-
|
|
490
|
+
except asyncio.QueueShutDown:
|
|
491
|
+
# flush any pending changes
|
|
492
|
+
for e, p in changes.items():
|
|
493
|
+
e["text"] = p
|
|
452
494
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
async for evt in llm_messages:
|
|
456
|
-
for participant in self._room.messaging.get_participants():
|
|
457
|
-
logger.debug(
|
|
458
|
-
f"sending event {evt.type} to {participant.get_attribute('name')}"
|
|
459
|
-
)
|
|
495
|
+
changes.clear()
|
|
496
|
+
pass
|
|
460
497
|
|
|
461
|
-
|
|
498
|
+
update_thread_task = asyncio.create_task(update_thread())
|
|
499
|
+
try:
|
|
500
|
+
while True:
|
|
501
|
+
evt = await llm_messages.get()
|
|
502
|
+
for participant in self._room.messaging.get_participants():
|
|
503
|
+
logger.debug(
|
|
504
|
+
f"sending event {evt.type} to {participant.get_attribute('name')}"
|
|
505
|
+
)
|
|
462
506
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
507
|
+
# self.room.messaging.send_message_nowait(to=participant, type="llm.event", message=json.loads(evt.to_json()))
|
|
508
|
+
|
|
509
|
+
if evt.type == "response.content_part.added":
|
|
510
|
+
partial = ""
|
|
511
|
+
|
|
512
|
+
content_element = doc_messages.append_child(
|
|
513
|
+
tag_name="message",
|
|
514
|
+
attributes={
|
|
515
|
+
"text": "",
|
|
516
|
+
"created_at": datetime.datetime.now(datetime.timezone.utc)
|
|
517
|
+
.isoformat()
|
|
518
|
+
.replace("+00:00", "Z"),
|
|
519
|
+
"author_name": self.room.local_participant.get_attribute(
|
|
520
|
+
"name"
|
|
521
|
+
),
|
|
522
|
+
},
|
|
523
|
+
)
|
|
479
524
|
|
|
480
|
-
|
|
481
|
-
|
|
525
|
+
context_message = {"role": "assistant", "content": ""}
|
|
526
|
+
thread_context.chat.messages.append(context_message)
|
|
482
527
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
528
|
+
elif evt.type == "response.output_text.delta":
|
|
529
|
+
partial += evt.delta
|
|
530
|
+
updates.put_nowait((content_element, partial))
|
|
531
|
+
context_message["content"] = partial
|
|
487
532
|
|
|
488
|
-
|
|
489
|
-
|
|
533
|
+
elif evt.type == "response.output_text.done":
|
|
534
|
+
content_element = None
|
|
490
535
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
536
|
+
with tracer.start_as_current_span("chatbot.thread.message") as span:
|
|
537
|
+
span.set_attribute(
|
|
538
|
+
"from_participant_name",
|
|
539
|
+
self.room.local_participant.get_attribute("name"),
|
|
540
|
+
)
|
|
541
|
+
span.set_attribute("role", "assistant")
|
|
542
|
+
span.set_attributes(thread_attributes)
|
|
543
|
+
span.set_attributes({"text": evt.text})
|
|
544
|
+
except asyncio.QueueShutDown:
|
|
545
|
+
pass
|
|
546
|
+
finally:
|
|
547
|
+
updates.shutdown()
|
|
548
|
+
await update_thread_task
|
|
504
549
|
|
|
505
|
-
|
|
506
|
-
|
|
550
|
+
async def _spawn_thread(self, path: str, messages: Chan[RoomMessage]):
|
|
551
|
+
logger.debug("chatbot is starting a thread", extra={"path": path})
|
|
552
|
+
chat_context = await self.init_chat_context()
|
|
553
|
+
opened = False
|
|
554
|
+
|
|
555
|
+
current_file = None
|
|
556
|
+
thread_context = None
|
|
557
|
+
|
|
558
|
+
thread_attributes = None
|
|
507
559
|
|
|
508
560
|
thread = None
|
|
509
561
|
|
|
@@ -512,9 +564,9 @@ class ChatBot(SingleRoomAgent):
|
|
|
512
564
|
|
|
513
565
|
while True:
|
|
514
566
|
while True:
|
|
515
|
-
logger.
|
|
567
|
+
logger.debug(f"waiting for message on thread {path}")
|
|
516
568
|
received = await messages.recv()
|
|
517
|
-
logger.
|
|
569
|
+
logger.debug(f"received message on thread {path}: {received.type}")
|
|
518
570
|
|
|
519
571
|
chat_with_participant = None
|
|
520
572
|
for participant in self._room.messaging.get_participants():
|
|
@@ -569,83 +621,57 @@ class ChatBot(SingleRoomAgent):
|
|
|
569
621
|
|
|
570
622
|
thread = await self.open_thread(path=path)
|
|
571
623
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
== self.room.local_participant.get_attribute(
|
|
585
|
-
"name"
|
|
586
|
-
)
|
|
587
|
-
):
|
|
588
|
-
chat_context.append_assistant_message(
|
|
589
|
-
msg
|
|
590
|
-
)
|
|
591
|
-
else:
|
|
592
|
-
chat_context.append_user_message(msg)
|
|
593
|
-
|
|
594
|
-
for child in element.get_children():
|
|
595
|
-
if child.tag_name == "file":
|
|
596
|
-
chat_context.append_assistant_message(
|
|
597
|
-
f"the user attached a file with the path '{child.get_attribute('path')}'"
|
|
598
|
-
)
|
|
599
|
-
|
|
600
|
-
if doc_messages is None:
|
|
601
|
-
raise Exception("thread was not properly initialized")
|
|
624
|
+
thread_context = ChatThreadContext(
|
|
625
|
+
path=path,
|
|
626
|
+
chat=chat_context,
|
|
627
|
+
thread=thread,
|
|
628
|
+
participants=get_thread_participants(
|
|
629
|
+
room=self.room, thread=thread
|
|
630
|
+
),
|
|
631
|
+
)
|
|
632
|
+
|
|
633
|
+
await self.load_thread_context(
|
|
634
|
+
thread_context=thread_context
|
|
635
|
+
)
|
|
602
636
|
|
|
603
637
|
if received.type == "opened":
|
|
604
638
|
if not opened:
|
|
605
639
|
opened = True
|
|
606
640
|
|
|
607
|
-
await self.
|
|
641
|
+
await self._greet(
|
|
608
642
|
path=path,
|
|
609
643
|
chat_context=chat_context,
|
|
610
644
|
participant=chat_with_participant,
|
|
611
|
-
|
|
645
|
+
thread=thread,
|
|
612
646
|
thread_attributes=thread_attributes,
|
|
613
647
|
)
|
|
614
648
|
|
|
615
649
|
if received.type == "chat":
|
|
616
650
|
if thread is None:
|
|
617
|
-
|
|
618
|
-
type="thread is not open", data={}
|
|
619
|
-
)
|
|
651
|
+
logger.info("thread is not open", extra={"path": path})
|
|
620
652
|
break
|
|
621
653
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
"
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
"role": "user",
|
|
634
|
-
"text": received.message["text"],
|
|
635
|
-
}
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
)
|
|
654
|
+
logger.debug(
|
|
655
|
+
"chatbot received a chat",
|
|
656
|
+
extra={
|
|
657
|
+
"context": chat_context.id,
|
|
658
|
+
"participant_id": self.room.local_participant.id,
|
|
659
|
+
"participant_name": self.room.local_participant.get_attribute(
|
|
660
|
+
"name"
|
|
661
|
+
),
|
|
662
|
+
"text": received.message["text"],
|
|
663
|
+
},
|
|
664
|
+
)
|
|
639
665
|
|
|
640
|
-
|
|
641
|
-
|
|
666
|
+
attachments = received.message.get("attachments", [])
|
|
667
|
+
text = received.message["text"]
|
|
642
668
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
669
|
+
for attachment in attachments:
|
|
670
|
+
chat_context.append_assistant_message(
|
|
671
|
+
message=f"the user attached a file at the path '{attachment['path']}'"
|
|
672
|
+
)
|
|
647
673
|
|
|
648
|
-
|
|
674
|
+
chat_context.append_user_message(message=text)
|
|
649
675
|
|
|
650
676
|
if messages.empty():
|
|
651
677
|
break
|
|
@@ -690,9 +716,6 @@ class ChatBot(SingleRoomAgent):
|
|
|
690
716
|
room=self.room, thread=thread
|
|
691
717
|
)
|
|
692
718
|
|
|
693
|
-
def handle_event(evt):
|
|
694
|
-
llm_messages.send_nowait(evt)
|
|
695
|
-
|
|
696
719
|
with tracer.start_as_current_span("chatbot.llm") as span:
|
|
697
720
|
try:
|
|
698
721
|
with tracer.start_as_current_span(
|
|
@@ -705,6 +728,23 @@ class ChatBot(SingleRoomAgent):
|
|
|
705
728
|
)
|
|
706
729
|
)
|
|
707
730
|
|
|
731
|
+
await self.prepare_llm_context(
|
|
732
|
+
context=thread_context
|
|
733
|
+
)
|
|
734
|
+
|
|
735
|
+
llm_messages = asyncio.Queue[ResponseStreamEvent]()
|
|
736
|
+
|
|
737
|
+
def handle_event(evt):
|
|
738
|
+
llm_messages.put_nowait(evt)
|
|
739
|
+
|
|
740
|
+
llm_task = asyncio.create_task(
|
|
741
|
+
self._process_llm_events(
|
|
742
|
+
thread_context=thread_context,
|
|
743
|
+
llm_messages=llm_messages,
|
|
744
|
+
thread_attributes=thread_attributes,
|
|
745
|
+
)
|
|
746
|
+
)
|
|
747
|
+
|
|
708
748
|
await self._llm_adapter.next(
|
|
709
749
|
context=chat_context,
|
|
710
750
|
room=self._room,
|
|
@@ -713,10 +753,13 @@ class ChatBot(SingleRoomAgent):
|
|
|
713
753
|
event_handler=handle_event,
|
|
714
754
|
)
|
|
715
755
|
|
|
756
|
+
llm_messages.shutdown()
|
|
757
|
+
await llm_task
|
|
758
|
+
|
|
716
759
|
except Exception as e:
|
|
717
760
|
logger.error("An error was encountered", exc_info=e)
|
|
718
761
|
await self._send_and_save_chat(
|
|
719
|
-
|
|
762
|
+
thread=thread,
|
|
720
763
|
to=chat_with_participant,
|
|
721
764
|
path=path,
|
|
722
765
|
id=str(uuid.uuid4()),
|
|
@@ -741,13 +784,9 @@ class ChatBot(SingleRoomAgent):
|
|
|
741
784
|
finally:
|
|
742
785
|
|
|
743
786
|
async def cleanup():
|
|
744
|
-
llm_messages.close()
|
|
745
|
-
|
|
746
787
|
if self.room is not None:
|
|
747
788
|
logger.info(f"thread was ended {path}")
|
|
748
|
-
|
|
749
|
-
type="chatbot.thread.ended", data={"path": path}
|
|
750
|
-
)
|
|
789
|
+
logger.info("chatbot thread ended", extra={"path": path})
|
|
751
790
|
|
|
752
791
|
if thread is not None:
|
|
753
792
|
await self.close_thread(path=path)
|
|
@@ -786,7 +825,7 @@ class ChatBot(SingleRoomAgent):
|
|
|
786
825
|
|
|
787
826
|
messages = self._get_message_channel(path)
|
|
788
827
|
|
|
789
|
-
logger.
|
|
828
|
+
logger.debug(
|
|
790
829
|
f"queued incoming message for thread {path}: {message.type}"
|
|
791
830
|
)
|
|
792
831
|
|
|
@@ -806,7 +845,7 @@ class ChatBot(SingleRoomAgent):
|
|
|
806
845
|
f"The chat thread ended with an error {e}", exc_info=e
|
|
807
846
|
)
|
|
808
847
|
|
|
809
|
-
logger.
|
|
848
|
+
logger.debug(f"spawning chat thread for {path}")
|
|
810
849
|
task = asyncio.create_task(
|
|
811
850
|
self._spawn_thread(messages=messages, path=path)
|
|
812
851
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.4"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-agents
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: Agent Building Blocks for Meshagent
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Documentation, https://docs.meshagent.com
|
|
@@ -12,19 +12,19 @@ License-File: LICENSE
|
|
|
12
12
|
Requires-Dist: pyjwt~=2.10
|
|
13
13
|
Requires-Dist: pytest~=8.4
|
|
14
14
|
Requires-Dist: pytest-asyncio~=0.26
|
|
15
|
-
Requires-Dist: meshagent-api~=0.5.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.5.
|
|
17
|
-
Requires-Dist: meshagent-openai~=0.5.
|
|
15
|
+
Requires-Dist: meshagent-api~=0.5.4
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.5.4
|
|
17
|
+
Requires-Dist: meshagent-openai~=0.5.4
|
|
18
18
|
Requires-Dist: pydantic~=2.11
|
|
19
19
|
Requires-Dist: opentelemetry-distro~=0.54b1
|
|
20
20
|
Provides-Extra: all
|
|
21
|
-
Requires-Dist: meshagent-api[all]~=0.5.
|
|
21
|
+
Requires-Dist: meshagent-api[all]~=0.5.4; extra == "all"
|
|
22
22
|
Requires-Dist: chonkie~=0.5.1; extra == "all"
|
|
23
23
|
Requires-Dist: chonkie[semantic]~=0.5.1; extra == "all"
|
|
24
24
|
Requires-Dist: chonkie[openai]~=0.5.1; extra == "all"
|
|
25
25
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "all"
|
|
26
26
|
Provides-Extra: sync
|
|
27
|
-
Requires-Dist: meshagent-api[sync]~=0.5.
|
|
27
|
+
Requires-Dist: meshagent-api[sync]~=0.5.4; extra == "sync"
|
|
28
28
|
Provides-Extra: mail
|
|
29
29
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
|
|
30
30
|
Provides-Extra: rag
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
pyjwt~=2.10
|
|
2
2
|
pytest~=8.4
|
|
3
3
|
pytest-asyncio~=0.26
|
|
4
|
-
meshagent-api~=0.5.
|
|
5
|
-
meshagent-tools~=0.5.
|
|
6
|
-
meshagent-openai~=0.5.
|
|
4
|
+
meshagent-api~=0.5.4
|
|
5
|
+
meshagent-tools~=0.5.4
|
|
6
|
+
meshagent-openai~=0.5.4
|
|
7
7
|
pydantic~=2.11
|
|
8
8
|
opentelemetry-distro~=0.54b1
|
|
9
9
|
|
|
10
10
|
[all]
|
|
11
|
-
meshagent-api[all]~=0.5.
|
|
11
|
+
meshagent-api[all]~=0.5.4
|
|
12
12
|
chonkie~=0.5.1
|
|
13
13
|
chonkie[semantic]~=0.5.1
|
|
14
14
|
chonkie[openai]~=0.5.1
|
|
@@ -23,4 +23,4 @@ chonkie[semantic]~=0.5.1
|
|
|
23
23
|
chonkie[openai]~=0.5.1
|
|
24
24
|
|
|
25
25
|
[sync]
|
|
26
|
-
meshagent-api[sync]~=0.5.
|
|
26
|
+
meshagent-api[sync]~=0.5.4
|
|
@@ -17,16 +17,16 @@ dependencies = [
|
|
|
17
17
|
"pyjwt~=2.10",
|
|
18
18
|
"pytest~=8.4",
|
|
19
19
|
"pytest-asyncio~=0.26",
|
|
20
|
-
"meshagent-api~=0.5.
|
|
21
|
-
"meshagent-tools~=0.5.
|
|
22
|
-
"meshagent-openai~=0.5.
|
|
20
|
+
"meshagent-api~=0.5.4",
|
|
21
|
+
"meshagent-tools~=0.5.4",
|
|
22
|
+
"meshagent-openai~=0.5.4",
|
|
23
23
|
"pydantic~=2.11",
|
|
24
24
|
"opentelemetry-distro~=0.54b1"
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
all = [
|
|
29
|
-
"meshagent-api[all]~=0.5.
|
|
29
|
+
"meshagent-api[all]~=0.5.4",
|
|
30
30
|
"chonkie~=0.5.1",
|
|
31
31
|
"chonkie[semantic]~=0.5.1",
|
|
32
32
|
"chonkie[openai]~=0.5.1",
|
|
@@ -34,7 +34,7 @@ all = [
|
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
sync = [
|
|
37
|
-
"meshagent-api[sync]~=0.5.
|
|
37
|
+
"meshagent-api[sync]~=0.5.4",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
mail = [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent/agents/schemas/super_editor_document.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meshagent_agents-0.5.3 → meshagent_agents-0.5.4}/meshagent_agents.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|