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

Rework AgentOps implementation for new agent executor #1334

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/crewai/llm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Dict, List
from litellm import completion
import litellm


Expand All @@ -10,7 +9,7 @@ def __init__(self, model: str, stop: List[str] = [], callbacks: List[Any] = []):
litellm.callbacks = callbacks

def call(self, messages: List[Dict[str, str]]) -> Dict[str, Any]:
response = completion(
response = litellm.completion(
stop=self.stop, model=self.model, messages=messages, num_retries=5
)
return response["choices"][0]["message"]["content"]
Expand Down
9 changes: 4 additions & 5 deletions src/crewai/tools/tool_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
from crewai.utilities import I18N, Converter, ConverterError, Printer

agentops = None
if os.environ.get("AGENTOPS_API_KEY"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we keep this? given that if the person haven't set up a key we probably don't was to try import the library anyway?

try:
import agentops # type: ignore
except ImportError:
pass
try:
import agentops # type: ignore
except ImportError:
pass

OPENAI_BIGGER_MODELS = ["gpt-4", "gpt-4o"]

Expand Down
4 changes: 2 additions & 2 deletions src/crewai/utilities/internal_instructor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Optional, Type

import instructor
from litellm import completion
import litellm


class InternalInstructor:
Expand Down Expand Up @@ -29,7 +29,7 @@ def set_instructor(self):
self.llm = self.agent.function_calling_llm or self.agent.llm

self._client = instructor.from_litellm(
completion,
litellm.completion,
mode=instructor.Mode.TOOLS,
)

Expand Down
Loading