Skip to content

Commit

Permalink
Llmtracker fix (#554)
Browse files Browse the repository at this point in the history
* move files around

* rename files to prevent bad imports

* rename files back

* version upgrade

* fix tach

* rc relase

* change to relative paths

* new rc

* removed circular imports

* new rc

* upgrade rc

* added new build stuff

* update version

* made wildcare finder

* check providers

* remove partners

* rc7

* added new tool

* revert providers

* resetore dependency groups

* fixed autogen logging

* bump rc

* version bump for rc

* fix import

* new release

* add providers

* bump to version 21

* fix imports: use absolute paths

Signed-off-by: Teo <[email protected]>

* git checkout main -- pyproject.toml

Signed-off-by: Teo <[email protected]>

---------

Signed-off-by: Teo <[email protected]>
Co-authored-by: teocns <[email protected]>
Co-authored-by: Teo <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 1451de7 commit 5524c46
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 56 deletions.
1 change: 1 addition & 0 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import threading
from importlib.metadata import version as get_version
from packaging import version
from .llms import tracker

try:
from .partners.langchain_callback_handler import (
Expand Down
2 changes: 1 addition & 1 deletion agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .config import Configuration
from .event import ErrorEvent, Event
from .host_env import get_host_env
from .llms import LlmTracker
from .llms.tracker import LlmTracker
from .log_config import logger
from .meta_client import MetaClient
from .session import Session, active_sessions
Expand Down
2 changes: 1 addition & 1 deletion agentops/llms/llama_stack_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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.instrumented_provider import InstrumentedProvider
from agentops.llms.providers.instrumented_provider import InstrumentedProvider


class LlamaStackClientProvider(InstrumentedProvider):
Expand Down
12 changes: 6 additions & 6 deletions agentops/llms/ai21.py → agentops/llms/providers/ai21.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import pprint
from typing import Optional

from agentops.llms.instrumented_provider import InstrumentedProvider
from agentops.llms.providers.instrumented_provider import InstrumentedProvider
from agentops.time_travel import fetch_completion_override_from_time_travel_cache

from ..event import ErrorEvent, LLMEvent, ActionEvent, ToolEvent
from ..session import Session
from ..log_config import logger
from ..helpers import check_call_stack_for_agent_id, get_ISO_time
from ..singleton import singleton
from agentops.event import ErrorEvent, LLMEvent, ActionEvent, ToolEvent
from agentops.session import Session
from agentops.log_config import logger
from agentops.helpers import check_call_stack_for_agent_id, get_ISO_time
from agentops.singleton import singleton


@singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import pprint
from typing import Optional

from agentops.llms.instrumented_provider import InstrumentedProvider
from agentops.llms.providers.instrumented_provider import InstrumentedProvider
from agentops.time_travel import fetch_completion_override_from_time_travel_cache

from ..event import ErrorEvent, LLMEvent, ToolEvent
from ..helpers import check_call_stack_for_agent_id, get_ISO_time
from ..log_config import logger
from ..session import Session
from ..singleton import singleton
from agentops.event import ErrorEvent, LLMEvent, ToolEvent
from agentops.helpers import check_call_stack_for_agent_id, get_ISO_time
from agentops.log_config import logger
from agentops.session import Session
from agentops.singleton import singleton


@singleton
Expand Down
8 changes: 4 additions & 4 deletions agentops/llms/cohere.py → agentops/llms/providers/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from typing import Optional

from .instrumented_provider import InstrumentedProvider
from ..event import ActionEvent, ErrorEvent, LLMEvent
from ..session import Session
from ..log_config import logger
from agentops.event import ActionEvent, ErrorEvent, LLMEvent
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 ..singleton import singleton
from agentops.singleton import singleton


@singleton
Expand Down
8 changes: 4 additions & 4 deletions agentops/llms/groq.py → agentops/llms/providers/groq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from typing import Optional

from .instrumented_provider import InstrumentedProvider
from ..event import ErrorEvent, LLMEvent
from ..session import Session
from ..log_config import logger
from agentops.event import ErrorEvent, LLMEvent
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 ..singleton import singleton
from agentops.singleton import singleton


@singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from abc import ABC, abstractmethod
from typing import Optional

from ..session import Session
from ..event import LLMEvent
from agentops.session import Session
from agentops.event import LLMEvent


class InstrumentedProvider(ABC):
Expand Down
10 changes: 5 additions & 5 deletions agentops/llms/litellm.py → agentops/llms/providers/litellm.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pprint
from typing import Optional

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


@singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys
from typing import Optional

from ..event import LLMEvent, ErrorEvent
from ..session import Session
from ..log_config import logger
from agentops.event import LLMEvent, ErrorEvent
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 .instrumented_provider import InstrumentedProvider

Expand Down
6 changes: 3 additions & 3 deletions agentops/llms/ollama.py → agentops/llms/providers/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import sys
from typing import Optional

from ..event import LLMEvent
from ..session import Session
from agentops.event import LLMEvent
from agentops.session import Session
from agentops.helpers import get_ISO_time, check_call_stack_for_agent_id
from .instrumented_provider import InstrumentedProvider
from ..singleton import singleton
from agentops.singleton import singleton

original_func = {}

Expand Down
12 changes: 6 additions & 6 deletions agentops/llms/openai.py → agentops/llms/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import pprint
from typing import Optional

from agentops.llms.instrumented_provider import InstrumentedProvider
from agentops.llms.providers.instrumented_provider import InstrumentedProvider
from agentops.time_travel import fetch_completion_override_from_time_travel_cache

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


@singleton
Expand Down
17 changes: 8 additions & 9 deletions agentops/llms/__init__.py → agentops/llms/tracker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import functools
import sys
from importlib import import_module
from importlib.metadata import version
Expand All @@ -9,14 +8,14 @@

from ..log_config import logger

from .cohere import CohereProvider
from .groq import GroqProvider
from .litellm import LiteLLMProvider
from .ollama import OllamaProvider
from .openai import OpenAiProvider
from .anthropic import AnthropicProvider
from .mistral import MistralProvider
from .ai21 import AI21Provider
from .providers.cohere import CohereProvider
from .providers.groq import GroqProvider
from .providers.litellm import LiteLLMProvider
from .providers.ollama import OllamaProvider
from .providers.openai import OpenAiProvider
from .providers.anthropic import AnthropicProvider
from .providers.mistral import MistralProvider
from .providers.ai21 import AI21Provider

original_func = {}
original_create = None
Expand Down
2 changes: 1 addition & 1 deletion agentops/partners/autogen_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def log_chat_completion(
# Note: Autogen tokens are not included in the request and function call tokens are not counted in the completion
llm_event = LLMEvent(
prompt=request["messages"],
completion=completion.message,
completion=completion.message.to_dict(),
model=response.model,
cost=cost,
returns=completion.message.to_json(),
Expand Down
10 changes: 5 additions & 5 deletions agentops/partners/langchain_callback_handler.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Dict, Any, List, Optional, Sequence, Union
from collections import defaultdict
from uuid import UUID
import logging
import os

from tenacity import RetryCallState

from langchain_core.agents import AgentFinish, AgentAction
from langchain_core.documents import Document
from langchain_core.outputs import ChatGenerationChunk, GenerationChunk, LLMResult
from langchain.callbacks.base import BaseCallbackHandler, AsyncCallbackHandler
from langchain_core.messages import BaseMessage

from tenacity import RetryCallState

from agentops import Client as AOClient
from agentops import ActionEvent, LLMEvent, ToolEvent, ErrorEvent
from agentops.helpers import get_ISO_time
from agentops.helpers import get_ISO_time, debug_print_function_params

from ..helpers import debug_print_function_params
import os
from ..log_config import logger
import logging


def get_model_from_kwargs(kwargs: any) -> str:
Expand Down

0 comments on commit 5524c46

Please sign in to comment.