Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

feat: support mistral pixtral model (#1016)

Wendong-Fan45d919f521c3
diff --git a/camel/types/enums.py b/camel/types/enums.py
index f9d8eff8e..ef7eae820 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -82,6 +82,7 @@ class ModelType(Enum):
MISTRAL_MIXTRAL_8x7B = "open-mixtral-8x7b"
MISTRAL_MIXTRAL_8x22B = "open-mixtral-8x22b"
MISTRAL_CODESTRAL_MAMBA = "open-codestral-mamba"
+ MISTRAL_PIXTRAL_12B = "pixtral-12b-2409"
# Reka models
REKA_CORE = "reka-core"
@@ -186,6 +187,7 @@ class ModelType(Enum):
ModelType.MISTRAL_MIXTRAL_8x7B,
ModelType.MISTRAL_MIXTRAL_8x22B,
ModelType.MISTRAL_CODESTRAL_MAMBA,
+ ModelType.MISTRAL_PIXTRAL_12B,
}
@property
@@ -278,6 +280,7 @@ class ModelType(Enum):
ModelType.O1_MINI,
ModelType.MISTRAL_LARGE,
ModelType.MISTRAL_NEMO,
+ ModelType.MISTRAL_PIXTRAL_12B,
ModelType.QWEN_2,
}:
return 128_000
diff --git a/examples/models/mistral_model_example.py b/examples/models/mistral_model_example.py
index f1a437052..1c275d604 100644
--- a/examples/models/mistral_model_example.py
+++ b/examples/models/mistral_model_example.py
@@ -11,6 +11,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
+from io import BytesIO
+
+import requests
+from PIL import Image
+
from camel.agents import ChatAgent
from camel.configs import MistralConfig
from camel.messages import BaseMessage
@@ -47,3 +52,32 @@ Hello CAMEL AI! It's great to connect with a community dedicated to the study
of autonomous and communicative agents. How can I assist you today?
===============================================================================
'''
+
+model = ModelFactory.create(
+ model_platform=ModelPlatformType.MISTRAL,
+ model_type=ModelType.MISTRAL_PIXTRAL_12B,
+ model_config_dict=MistralConfig(temperature=0.0).as_dict(),
+)
+
+# Set agent
+camel_agent = ChatAgent(system_message=sys_msg, model=model)
+
+# URL of the image
+url = "https://raw.githubusercontent.com/camel-ai/camel/master/misc/primary_logo.png"
+response = requests.get(url)
+img = Image.open(BytesIO(response.content))
+
+user_msg = BaseMessage.make_user_message(
+ role_name="User", content="""what's in the image?""", image_list=[img]
+)
+
+# Get response information
+response = camel_agent.step(user_msg)
+print(response.msgs[0].content)
+'''
+===============================================================================
+The image features a logo with a purple camel illustration on the left side
+and the word "CAMEL" written in purple capital letters to the right of the
+camel.
+===============================================================================
+'''
diff --git a/test/models/test_mistral_model.py b/test/models/test_mistral_model.py
index baef69bd4..685b50e3d 100644
--- a/test/models/test_mistral_model.py
+++ b/test/models/test_mistral_model.py
@@ -32,6 +32,7 @@ from camel.utils import OpenAITokenCounter
ModelType.MISTRAL_MIXTRAL_8x22B,
ModelType.MISTRAL_CODESTRAL,
ModelType.MISTRAL_CODESTRAL_MAMBA,
+ ModelType.MISTRAL_PIXTRAL_12B,
],
)
def test_mistral_model(model_type):