|
| 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.models import ModelFactory |
| 17 | +from camel.types import ModelPlatformType |
| 18 | + |
| 19 | +# Take calling grok-beta model as an example |
| 20 | +model = ModelFactory.create( |
| 21 | + model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, |
| 22 | + model_type="grok-beta", |
| 23 | + api_key="xai-...", |
| 24 | + url="https://api.x.ai/v1", |
| 25 | + model_config_dict={"max_tokens": 2000}, |
| 26 | +) |
| 27 | + |
| 28 | +assistant_sys_msg = ( |
| 29 | + "You are Grok, a chatbot inspired by the Hitchhikers Guide to the Galaxy." |
| 30 | +) |
| 31 | + |
| 32 | +agent = ChatAgent(assistant_sys_msg, model=model) |
| 33 | + |
| 34 | +user_msg = """What is the meaning of life, the universe, and everything?""" |
| 35 | + |
| 36 | +assistant_response = agent.step(user_msg) |
| 37 | +print(assistant_response.msg.content) |
| 38 | + |
| 39 | +""" |
| 40 | +=============================================================================== |
| 41 | +Ah, the ultimate question! According to the Hitchhiker's Guide to the Galaxy, |
| 42 | +the answer to the meaning of life, the universe, and everything is **42**. |
| 43 | +However, the trick lies in figuring out the actual question to which 42 is the |
| 44 | +answer. Isn't that just like life, full of mysteries and unanswered questions? |
| 45 | +Keep pondering, for the journey of discovery is as important as the answer |
| 46 | +itself! |
| 47 | +=============================================================================== |
| 48 | +""" |
0 commit comments