Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] TaskWeaver Integration #541

Merged
merged 34 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
674d2dc
taskweaver basic tracking
the-praxs Dec 2, 2024
6fe9d31
Merge branch 'main' into feat/taskweaver
the-praxs Dec 3, 2024
c1e99c1
linting
the-praxs Dec 3, 2024
0b7d3a8
Merge branch 'main' into feat/taskweaver
the-praxs Dec 4, 2024
51ae25f
Merge branch 'main' into feat/taskweaver
the-praxs Dec 9, 2024
bdf64aa
Merge branch 'main' into feat/taskweaver
teocns Dec 11, 2024
23eb629
Merge branch 'main' into feat/taskweaver
the-praxs Dec 12, 2024
774eedd
Merge branch 'main' into feat/taskweaver
the-praxs Dec 13, 2024
16c7e9f
Merge branch 'main' into feat/taskweaver
the-praxs Dec 16, 2024
e06e88c
Merge branch 'main' into feat/taskweaver
the-praxs Dec 16, 2024
7e83a07
Merge branch 'main' into feat/taskweaver
the-praxs Dec 17, 2024
1dfeb99
some logging occurs
the-praxs Dec 17, 2024
66c848d
more debug info to understand llm info flow
the-praxs Dec 18, 2024
edea673
saving model info now in `LLMEvent`
the-praxs Dec 18, 2024
caae7f5
get service mappings from taskweaver
the-praxs Dec 18, 2024
aa877fb
remove taskweaver code from agentops init
the-praxs Dec 19, 2024
d794b9f
fix incorrect use of agent_id in events
the-praxs Dec 19, 2024
5523131
clean and refactor code for taskweaver LLM tracking
the-praxs Dec 19, 2024
7f5c2c2
convert `LLMEvent` to `ActionEvent`
the-praxs Dec 19, 2024
e615560
improved event handling
the-praxs Dec 19, 2024
3f5adb8
add `ActionEvent` for recording `json_schema`
the-praxs Dec 19, 2024
1a5a084
linting
the-praxs Dec 19, 2024
b250430
add microsoft and taskweaver logos
the-praxs Dec 20, 2024
1ae51bf
add default tags `taskweaver`
the-praxs Dec 20, 2024
b502582
cast message as string
the-praxs Dec 20, 2024
e278b5c
add session image
the-praxs Dec 20, 2024
c3b0215
add documentation for taskweaver
the-praxs Dec 20, 2024
676e6ca
linting
the-praxs Dec 20, 2024
306a3b5
overhauled handler code
the-praxs Dec 22, 2024
9867928
Merge branch 'main' into feat/taskweaver
the-praxs Dec 22, 2024
f5faec2
linting
the-praxs Dec 22, 2024
d355ce9
use correct logger import
the-praxs Dec 22, 2024
2696ae7
stutter fix
the-praxs Dec 22, 2024
d2724f3
add warning for stutter
the-praxs Dec 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions agentops/llms/providers/taskweaver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import pprint
from typing import Optional
import json

from agentops.event import ErrorEvent, LLMEvent, ActionEvent
from agentops.session import Session
from agentops.log_config import logger
from agentops.helpers import get_ISO_time, check_call_stack_for_agent_id
from agentops.llms.providers.instrumented_provider import InstrumentedProvider
from agentops.singleton import singleton


@singleton
class TaskWeaverProvider(InstrumentedProvider):
original_chat_completion = None

def __init__(self, client):
super().__init__(client)
self._provider_name = "TaskWeaver"
self.client.add_default_tags(["taskweaver"])

Check warning on line 20 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L18-L20

Added lines #L18 - L20 were not covered by tests

def handle_response(self, response, kwargs, init_timestamp, session: Optional[Session] = None) -> dict:
"""Handle responses for TaskWeaver"""
llm_event = LLMEvent(init_timestamp=init_timestamp, params=kwargs)
action_event = ActionEvent(init_timestamp=init_timestamp)

Check warning on line 25 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L24-L25

Added lines #L24 - L25 were not covered by tests

try:
response_dict = response.get("response", {})

Check warning on line 28 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L27-L28

Added lines #L27 - L28 were not covered by tests

action_event.params = kwargs.get("json_schema", None)
action_event.returns = response_dict
action_event.end_timestamp = get_ISO_time()
self._safe_record(session, action_event)
except Exception as e:
error_event = ErrorEvent(

Check warning on line 35 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L30-L35

Added lines #L30 - L35 were not covered by tests
trigger_event=action_event, exception=e, details={"response": str(response), "kwargs": str(kwargs)}
)
self._safe_record(session, error_event)
kwargs_str = pprint.pformat(kwargs)
response_str = pprint.pformat(response)
logger.error(

Check warning on line 41 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L38-L41

Added lines #L38 - L41 were not covered by tests
f"Unable to parse response for Action call. Skipping upload to AgentOps\n"
f"response:\n {response_str}\n"
f"kwargs:\n {kwargs_str}\n"
)

try:
llm_event.init_timestamp = init_timestamp
llm_event.params = kwargs
llm_event.returns = response_dict
llm_event.agent_id = check_call_stack_for_agent_id()
llm_event.model = kwargs.get("model", "unknown")
llm_event.prompt = kwargs.get("messages")
llm_event.completion = response_dict.get("message", "")
llm_event.end_timestamp = get_ISO_time()
self._safe_record(session, llm_event)

Check warning on line 56 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L47-L56

Added lines #L47 - L56 were not covered by tests

except Exception as e:
error_event = ErrorEvent(

Check warning on line 59 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L58-L59

Added lines #L58 - L59 were not covered by tests
trigger_event=llm_event, exception=e, details={"response": str(response), "kwargs": str(kwargs)}
)
self._safe_record(session, error_event)
kwargs_str = pprint.pformat(kwargs)
response_str = pprint.pformat(response)
logger.error(

Check warning on line 65 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L62-L65

Added lines #L62 - L65 were not covered by tests
f"Unable to parse response for LLM call. Skipping upload to AgentOps\n"
f"response:\n {response_str}\n"
f"kwargs:\n {kwargs_str}\n"
)

return response

Check warning on line 71 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L71

Added line #L71 was not covered by tests

def override(self):
"""Override TaskWeaver's chat completion methods"""
try:
from taskweaver.llm import llm_completion_config_map

Check warning on line 76 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L75-L76

Added lines #L75 - L76 were not covered by tests

def create_patched_chat_completion(original_method):

Check warning on line 78 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L78

Added line #L78 was not covered by tests
"""Create a new patched chat_completion function with bound original method"""

def patched_chat_completion(service, *args, **kwargs):
init_timestamp = get_ISO_time()
session = kwargs.get("session", None)

Check warning on line 83 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L81-L83

Added lines #L81 - L83 were not covered by tests
if "session" in kwargs.keys():
del kwargs["session"]

Check warning on line 85 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L85

Added line #L85 was not covered by tests

result = original_method(service, *args, **kwargs)
kwargs.update(

Check warning on line 88 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L87-L88

Added lines #L87 - L88 were not covered by tests
{
"model": self._get_model_name(service),
"messages": args[0],
"stream": args[1],
"temperature": args[2],
"max_tokens": args[3],
"top_p": args[4],
"stop": args[5],
}
)

if kwargs["stream"]:
accumulated_content = ""

Check warning on line 101 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L101

Added line #L101 was not covered by tests
for chunk in result:
if isinstance(chunk, dict) and "content" in chunk:
accumulated_content += chunk["content"]

Check warning on line 104 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L104

Added line #L104 was not covered by tests
else:
accumulated_content += chunk
yield chunk
accumulated_content = json.loads(accumulated_content)
return self.handle_response(accumulated_content, kwargs, init_timestamp, session=session)

Check warning on line 109 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L106-L109

Added lines #L106 - L109 were not covered by tests
else:
return self.handle_response(result, kwargs, init_timestamp, session=session)

Check warning on line 111 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L111

Added line #L111 was not covered by tests

return patched_chat_completion

Check warning on line 113 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L113

Added line #L113 was not covered by tests

for service_name, service_class in llm_completion_config_map.items():
if not hasattr(service_class, "_original_chat_completion"):
service_class._original_chat_completion = service_class.chat_completion
service_class.chat_completion = create_patched_chat_completion(

Check warning on line 118 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L117-L118

Added lines #L117 - L118 were not covered by tests
service_class._original_chat_completion
)

except Exception as e:
logger.error(f"Failed to patch method: {str(e)}", exc_info=True)

Check warning on line 123 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L122-L123

Added lines #L122 - L123 were not covered by tests

def undo_override(self):
"""Restore original TaskWeaver chat completion methods"""
try:
from taskweaver.llm import llm_completion_config_map

Check warning on line 128 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L127-L128

Added lines #L127 - L128 were not covered by tests

for service_name, service_class in llm_completion_config_map.items():
service_class.chat_completion = service_class._original_chat_completion
delattr(service_class, "_original_chat_completion")

Check warning on line 132 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L131-L132

Added lines #L131 - L132 were not covered by tests

except Exception as e:
logger.error(f"Failed to restore original method: {str(e)}", exc_info=True)

Check warning on line 135 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L134-L135

Added lines #L134 - L135 were not covered by tests

def _get_model_name(self, service) -> str:
"""Extract model name from service instance"""
model_name = "unknown"

Check warning on line 139 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L139

Added line #L139 was not covered by tests
if hasattr(service, "config"):
config = service.config

Check warning on line 141 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L141

Added line #L141 was not covered by tests
if hasattr(config, "model"):
model_name = config.model or "unknown"

Check warning on line 143 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L143

Added line #L143 was not covered by tests
elif hasattr(config, "llm_module_config") and hasattr(config.llm_module_config, "model"):
model_name = config.llm_module_config.model or "unknown"
return model_name

Check warning on line 146 in agentops/llms/providers/taskweaver.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/providers/taskweaver.py#L145-L146

Added lines #L145 - L146 were not covered by tests
14 changes: 14 additions & 0 deletions agentops/llms/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .providers.anthropic import AnthropicProvider
from .providers.mistral import MistralProvider
from .providers.ai21 import AI21Provider
from .providers.taskweaver import TaskWeaverProvider

original_func = {}
original_create = None
Expand Down Expand Up @@ -54,6 +55,9 @@
"client.answer.create",
),
},
"taskweaver": {
"0.0.1": ("chat_completion", "chat_completion_stream"),
},
}

def __init__(self, client):
Expand Down Expand Up @@ -164,6 +168,15 @@
else:
logger.warning(f"Only LlamaStackClient>=0.0.53 supported. v{module_version} found.")

if api == "taskweaver":
module_version = version(api)

Check warning on line 172 in agentops/llms/tracker.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/tracker.py#L172

Added line #L172 was not covered by tests

if Version(module_version) >= parse("0.0.1"):
provider = TaskWeaverProvider(self.client)
provider.override()

Check warning on line 176 in agentops/llms/tracker.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/tracker.py#L175-L176

Added lines #L175 - L176 were not covered by tests
else:
logger.warning(f"Only TaskWeaver>=0.0.1 supported. v{module_version} found.")

Check warning on line 178 in agentops/llms/tracker.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/tracker.py#L178

Added line #L178 was not covered by tests

def stop_instrumenting(self):
OpenAiProvider(self.client).undo_override()
GroqProvider(self.client).undo_override()
Expand All @@ -174,3 +187,4 @@
MistralProvider(self.client).undo_override()
AI21Provider(self.client).undo_override()
LlamaStackClientProvider(self.client).undo_override()
TaskWeaverProvider(self.client).undo_override()

Check warning on line 190 in agentops/llms/tracker.py

View check run for this annotation

Codecov / codecov/patch

agentops/llms/tracker.py#L190

Added line #L190 was not covered by tests
156 changes: 156 additions & 0 deletions agentops/partners/taskweaver_event_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
from taskweaver.module.event_emitter import (

Check warning on line 1 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L1

Added line #L1 was not covered by tests
SessionEventHandlerBase,
TaskWeaverEvent,
EventScope,
SessionEventType,
RoundEventType,
PostEventType,
)
import agentops
from typing import Dict, Optional, Any
from uuid import UUID

Check warning on line 11 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L9-L11

Added lines #L9 - L11 were not covered by tests


class TaskWeaverEventHandler(SessionEventHandlerBase):
def __init__(self):
super().__init__()
self.current_round_id: Optional[str] = None
self.agent_sessions: Dict[str, Any] = {}
self._message_buffer: Dict[str, str] = {}
self._attachment_buffer: Dict[str, Dict[str, Any]] = {}
self._active_agents: Dict[str, str] = {} # Maps role_round_id to agent_id

Check warning on line 21 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L14-L21

Added lines #L14 - L21 were not covered by tests

def _get_or_create_agent(self, role: str) -> str:

Check warning on line 23 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L23

Added line #L23 was not covered by tests
"""Get existing agent ID or create new agent for role+round combination"""
agent_key = f"{role}"

Check warning on line 25 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L25

Added line #L25 was not covered by tests
if agent_key not in self._active_agents:
agent_id = agentops.create_agent(name=role)

Check warning on line 27 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L27

Added line #L27 was not covered by tests
if agent_id: # Only store if agent creation was successful
self._active_agents[agent_key] = agent_id
return self._active_agents.get(agent_key)

Check warning on line 30 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L29-L30

Added lines #L29 - L30 were not covered by tests

def handle_session(self, type: SessionEventType, msg: str, extra: Any, **kwargs: Any):
agentops.record(

Check warning on line 33 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L32-L33

Added lines #L32 - L33 were not covered by tests
agentops.ActionEvent(action_type=type.value, params={"message": msg}, returns=str(extra) if extra else None)
)

def handle_round(self, type: RoundEventType, msg: str, extra: Any, round_id: str, **kwargs: Any):

Check warning on line 37 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L37

Added line #L37 was not covered by tests
if type == RoundEventType.round_start:
self.current_round_id = round_id
agentops.record(agentops.ActionEvent(action_type="round_start", params={"round_id": round_id}, returns=msg))

Check warning on line 40 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L39-L40

Added lines #L39 - L40 were not covered by tests

elif type == RoundEventType.round_error:
agentops.record(

Check warning on line 43 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L43

Added line #L43 was not covered by tests
agentops.ErrorEvent(error_type="round_error", details={"message": msg, "round_id": round_id})
)

elif type == RoundEventType.round_end:
agentops.record(agentops.ActionEvent(action_type="round_end", params={"round_id": round_id}, returns=msg))
self.current_round_id = None

Check warning on line 49 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L48-L49

Added lines #L48 - L49 were not covered by tests

def handle_post(self, type: PostEventType, msg: str, extra: Any, post_id: str, round_id: str, **kwargs: Any):
role = extra.get("role", "Planner")
agent_id = self._get_or_create_agent(role=role)

Check warning on line 53 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L51-L53

Added lines #L51 - L53 were not covered by tests

if type == PostEventType.post_start:
agentops.record(

Check warning on line 56 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L56

Added line #L56 was not covered by tests
agentops.ActionEvent(
action_type="post_start",
params={
"post_id": post_id,
"round_id": round_id,
"agent_id": agent_id,
},
returns=msg,
)
)

elif type == PostEventType.post_message_update:
is_end = extra.get("is_end", False)

Check warning on line 69 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L69

Added line #L69 was not covered by tests
if not is_end:
self._message_buffer[post_id] = self._message_buffer.get(post_id, "") + msg

Check warning on line 71 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L71

Added line #L71 was not covered by tests
else:
agentops.record(

Check warning on line 73 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L73

Added line #L73 was not covered by tests
agentops.ActionEvent(
action_type="post_message_update",
params={
"post_id": post_id,
"round_id": round_id,
"agent_id": agent_id,
"is_end": is_end,
"model": extra.get("model", None),
},
returns=self._message_buffer.get(post_id, ""),
)
)

if is_end:
self._message_buffer.pop(post_id, None)

Check warning on line 88 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L88

Added line #L88 was not covered by tests

elif type == PostEventType.post_attachment_update:
attachment_id = extra.get("id", "")
attachment_type = extra.get("type", "")
is_end = extra.get("is_end", False)

Check warning on line 93 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L91-L93

Added lines #L91 - L93 were not covered by tests

if attachment_id not in self._attachment_buffer:
self._attachment_buffer[attachment_id] = {

Check warning on line 96 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L96

Added line #L96 was not covered by tests
"type": attachment_type,
"content": "",
"post_id": post_id,
"round_id": round_id,
"agent_id": agent_id,
}

agentops.record(

Check warning on line 104 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L104

Added line #L104 was not covered by tests
agentops.ActionEvent(
action_type="attachment_stream_start",
params={
"attachment_id": attachment_id,
"attachment_type": str(attachment_type),
"post_id": post_id,
"round_id": round_id,
"agent_id": agent_id,
},
)
)

self._attachment_buffer[attachment_id]["content"] += str(msg)

Check warning on line 117 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L117

Added line #L117 was not covered by tests

if is_end:
buffer = self._attachment_buffer[attachment_id]
agentops.record(

Check warning on line 121 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L120-L121

Added lines #L120 - L121 were not covered by tests
agentops.ToolEvent(
name=str(buffer["type"]),
params={
"post_id": buffer["post_id"],
"round_id": buffer["round_id"],
"attachment_id": attachment_id,
},
returns=buffer["content"],
agent_id=buffer["agent_id"],
)
)
self._attachment_buffer.pop(attachment_id)

Check warning on line 133 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L133

Added line #L133 was not covered by tests

elif type == PostEventType.post_error:
agentops.record(

Check warning on line 136 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L136

Added line #L136 was not covered by tests
agentops.ErrorEvent(
error_type="post_error",
details={"message": msg, "post_id": post_id, "round_id": round_id},
)
)

elif type == PostEventType.post_end:
agentops.record(

Check warning on line 144 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L144

Added line #L144 was not covered by tests
agentops.ActionEvent(
action_type="post_end",
params={"post_id": post_id, "round_id": round_id, "agent_id": agent_id},
returns=msg,
)
)

def cleanup_round(self, round_id: str):

Check warning on line 152 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L152

Added line #L152 was not covered by tests
"""Cleanup agents and buffers for a completed round"""
self._active_agents = {k: v for k, v in self._active_agents.items() if not k.endswith(round_id)}
self._message_buffer.clear()
self._attachment_buffer.clear()

Check warning on line 156 in agentops/partners/taskweaver_event_handler.py

View check run for this annotation

Codecov / codecov/patch

agentops/partners/taskweaver_event_handler.py#L154-L156

Added lines #L154 - L156 were not covered by tests
1 change: 1 addition & 0 deletions docs/images/external/microsoft/microsoft_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading