Skip to content

Commit

Permalink
fix reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
WHALEEYE committed Aug 23, 2024
1 parent cbf88d2 commit 6fec1a3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Transforms and data augmentation for both image + bbox.
"""

import os
import random

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
Various positional encodings for the transformer.
"""

import math

import torch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* extra LN at the end of encoder is removed
* decoder returns a stack of activations from all decoding layers
"""

from typing import Optional

import torch
Expand Down
1 change: 1 addition & 0 deletions crab-benchmark-v0/thirdparty/groundingdino/util/box_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Utilities for bounding box manipulation and GIoU.
"""

import torch
from torchvision.ops.boxes import box_area

Expand Down
1 change: 1 addition & 0 deletions crab-benchmark-v0/thirdparty/groundingdino/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Mostly copy-paste from torchvision references.
"""

import colorsys
import datetime
import functools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
@File : visualizer.py
@Time : 2022/04/05 11:39:33
@Author : Shilong Liu
@Author : Shilong Liu
@Contact : [email protected]
"""

Expand Down
15 changes: 10 additions & 5 deletions crab/agents/backend_models/camel_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from PIL import Image

from crab import Action, ActionOutput, BackendModel, BackendOutput, MessageType
from crab.utils.common import base64_to_image

try:
from camel.agents import ExternalToolAgent
Expand Down Expand Up @@ -83,13 +84,18 @@ def get_token_usage(self):

def reset(self, system_message: str, action_space: Optional[List[Action]]) -> None:
action_schema = self._convert_action_to_schema(action_space)
config = ChatGPTConfig(
tool_choice="required", tools=action_schema, **self.parameters
config = self.parameters.copy()
if action_schema is not None:
config["tool_choice"] = "required"
config["tools"] = action_schema

chatgpt_config = ChatGPTConfig(
**config,
)
backend_model = ModelFactory.create(
self.model_platform_type,
self.model_type,
model_config_dict=config.as_dict(),
model_config_dict=chatgpt_config.as_dict(),
)
sysmsg = BaseMessage.make_assistant_message(
role_name="Assistant",
Expand All @@ -103,7 +109,6 @@ def reset(self, system_message: str, action_space: Optional[List[Action]]) -> No
)
self.token_usage = 0

# TODO: convert Action into OpenAIFunction
@staticmethod
def _convert_action_to_schema(
action_space: Optional[List[Action]],
Expand Down Expand Up @@ -131,7 +136,7 @@ def chat(self, messages: List[Tuple[str, MessageType]]):
content = ""
for message in messages:
if message[1] == MessageType.IMAGE_JPG_BASE64:
image = decode_image(message[0])
image = base64_to_image(message[0])
image_list.append(image)
else:
content = message[0]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ google-generativeai = { version = "^0.6.0", optional = true }
anthropic = { version = "^0.29.0", optional = true }
groq = { version = "^0.5.0", optional = true }
ollama = { version = "^0.2.0", optional = true }
camel-ai = { git = "https://github.com/camel-ai/camel.git", branch = "feature/adapt-crab", extras=["all"] }
camel-ai = { git = "https://github.com/camel-ai/camel.git", branch = "feature/adapt-crab", extras=["all"], optional = true }

# text ocr
easyocr = { version = "^1.7.1", optional = true }
Expand Down Expand Up @@ -90,7 +90,6 @@ client = [
"anthropic",
"groq",
"ollama",
"camel-ai",
"easyocr",
"plotly",
"torch",
Expand All @@ -104,6 +103,7 @@ client = [
"pycocotools",
"timm",
]
camel = ["camel-ai"]

[tool.poetry.group.dev.dependencies]
mypy = "^1.8.0"
Expand Down
2 changes: 1 addition & 1 deletion test/agents/backend_models/test_camel_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def add(a: int, b: int):
return a + b


@pytest.mark.skip(reason="Mock data to be added")
# @pytest.mark.skip(reason="Mock data to be added")
def test_action_chat(camel_model_text):
camel_model_text.reset("You are a helpful assistant.", [add])
message = (
Expand Down

0 comments on commit 6fec1a3

Please sign in to comment.