Skip to content

Commit 43c39f1

Browse files
authored
chore: set openai compatibility model examples to folder (#1065)
1 parent 90b0949 commit 43c39f1

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2+
# Licensed under the Apache License, Version 2.0 (the “License”);
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an “AS IS” BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14+
15+
from camel.agents import ChatAgent
16+
from camel.messages import BaseMessage
17+
from camel.models import ModelFactory
18+
from camel.types import ModelPlatformType
19+
20+
# Take calling model from DashScope as an example
21+
# Refer: https://dashscope.console.aliyun.com/overview
22+
model = ModelFactory.create(
23+
model_platform=ModelPlatformType.OPENAI_COMPATIBILITY_MODEL,
24+
model_type="qwen-plus",
25+
api_key="sk-xxxx",
26+
url="https://dashscope.aliyuncs.com/compatible-mode/v1",
27+
model_config_dict={"temperature": 0.4},
28+
)
29+
30+
assistant_sys_msg = BaseMessage.make_assistant_message(
31+
role_name="Assistant",
32+
content="You are a helpful assistant.",
33+
)
34+
35+
agent = ChatAgent(assistant_sys_msg, model=model, token_limit=4096)
36+
37+
user_msg = BaseMessage.make_user_message(
38+
role_name="User",
39+
content="""Say hi to CAMEL AI, one open-source community
40+
dedicated to the study of autonomous and communicative agents.""",
41+
)
42+
assistant_response = agent.step(user_msg)
43+
print(assistant_response.msg.content)
44+
45+
"""
46+
===============================================================================
47+
Hi to the CAMEL AI community! It's great to connect with an open-source
48+
community focused on the study of autonomous and communicative agents. How can
49+
I assist you or your projects today?
50+
===============================================================================
51+
"""

0 commit comments

Comments
 (0)