Skip to content

Commit 45d919f

Browse files
authored
feat: support mistral pixtral model (#1016)
1 parent 472a40c commit 45d919f

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

camel/types/enums.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class ModelType(Enum):
8282
MISTRAL_MIXTRAL_8x7B = "open-mixtral-8x7b"
8383
MISTRAL_MIXTRAL_8x22B = "open-mixtral-8x22b"
8484
MISTRAL_CODESTRAL_MAMBA = "open-codestral-mamba"
85+
MISTRAL_PIXTRAL_12B = "pixtral-12b-2409"
8586

8687
# Reka models
8788
REKA_CORE = "reka-core"
@@ -186,6 +187,7 @@ def is_mistral(self) -> bool:
186187
ModelType.MISTRAL_MIXTRAL_8x7B,
187188
ModelType.MISTRAL_MIXTRAL_8x22B,
188189
ModelType.MISTRAL_CODESTRAL_MAMBA,
190+
ModelType.MISTRAL_PIXTRAL_12B,
189191
}
190192

191193
@property
@@ -278,6 +280,7 @@ def token_limit(self) -> int:
278280
ModelType.O1_MINI,
279281
ModelType.MISTRAL_LARGE,
280282
ModelType.MISTRAL_NEMO,
283+
ModelType.MISTRAL_PIXTRAL_12B,
281284
ModelType.QWEN_2,
282285
}:
283286
return 128_000

examples/models/mistral_model_example.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14+
from io import BytesIO
15+
16+
import requests
17+
from PIL import Image
18+
1419
from camel.agents import ChatAgent
1520
from camel.configs import MistralConfig
1621
from camel.messages import BaseMessage
@@ -47,3 +52,32 @@
4752
of autonomous and communicative agents. How can I assist you today?
4853
===============================================================================
4954
'''
55+
56+
model = ModelFactory.create(
57+
model_platform=ModelPlatformType.MISTRAL,
58+
model_type=ModelType.MISTRAL_PIXTRAL_12B,
59+
model_config_dict=MistralConfig(temperature=0.0).as_dict(),
60+
)
61+
62+
# Set agent
63+
camel_agent = ChatAgent(system_message=sys_msg, model=model)
64+
65+
# URL of the image
66+
url = "https://raw.githubusercontent.com/camel-ai/camel/master/misc/primary_logo.png"
67+
response = requests.get(url)
68+
img = Image.open(BytesIO(response.content))
69+
70+
user_msg = BaseMessage.make_user_message(
71+
role_name="User", content="""what's in the image?""", image_list=[img]
72+
)
73+
74+
# Get response information
75+
response = camel_agent.step(user_msg)
76+
print(response.msgs[0].content)
77+
'''
78+
===============================================================================
79+
The image features a logo with a purple camel illustration on the left side
80+
and the word "CAMEL" written in purple capital letters to the right of the
81+
camel.
82+
===============================================================================
83+
'''

test/models/test_mistral_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ModelType.MISTRAL_MIXTRAL_8x22B,
3333
ModelType.MISTRAL_CODESTRAL,
3434
ModelType.MISTRAL_CODESTRAL_MAMBA,
35+
ModelType.MISTRAL_PIXTRAL_12B,
3536
],
3637
)
3738
def test_mistral_model(model_type):

0 commit comments

Comments
 (0)