@@ -53,38 +53,56 @@ def construct_society(question: str) -> RolePlaying:
5353 models = {
5454 "user" : ModelFactory .create (
5555 model_platform = ModelPlatformType .OPENAI_COMPATIBLE_MODEL ,
56- model_type = "qwen-max" ,
57- api_key = os .getenv ("QWEN_API_KEY" ),
58- url = "https://dashscope.aliyuncs.com/compatible-mode/v1" ,
59- model_config_dict = {"temperature" : 0.4 , "max_tokens" : 128000 },
56+
57+ model_type = os .getenv ("USER_ROLE_API_MODEL_TYPE" , os .getenv ("LLM_ROLE_API_MODEL_TYPE" , "qwen-max" )),
58+ api_key = os .getenv ("USER_ROLE_API_KEY" , os .getenv ("LLM_ROLE_API_KEY" , os .getenv ("QWEN_API_KEY" , "Your_Key" ))),
59+ url = os .getenv ("USER_ROLE_API_BASE_URL" , os .getenv ("LLM_ROLE_API_BASE_URL" , "https://dashscope.aliyuncs.com/compatible-mode/v1" )),
60+ model_config_dict = {
61+ "temperature" : float (os .getenv ("USER_ROLE_API_MODEL_TEMPERATURE" , os .getenv ("LLM_ROLE_API_MODEL_TEMPERATURE" , "0.4" ))),
62+ "max_tokens" : int (os .getenv ("USER_ROLE_API_MODEL_MAX_TOKENS" , os .getenv ("LLM_ROLE_API_MODEL_MAX_TOKENS" , "4096" )))
63+ },
6064 ),
6165 "assistant" : ModelFactory .create (
6266 model_platform = ModelPlatformType .OPENAI_COMPATIBLE_MODEL ,
63- model_type = "qwen-max" ,
64- api_key = os .getenv ("QWEN_API_KEY" ),
65- url = "https://dashscope.aliyuncs.com/compatible-mode/v1" ,
66- model_config_dict = {"temperature" : 0.4 , "max_tokens" : 128000 },
67+ model_type = os .getenv ("ASSISTANT_ROLE_API_MODEL_TYPE" , os .getenv ("LLM_ROLE_API_MODEL_TYPE" , "qwen-max" )),
68+ api_key = os .getenv ("ASSISTANT_ROLE_API_KEY" , os .getenv ("LLM_ROLE_API_KEY" , os .getenv ("QWEN_API_KEY" , "Your_Key" ))),
69+ url = os .getenv ("ASSISTANT_ROLE_API_BASE_URL" , os .getenv ("LLM_ROLE_API_BASE_URL" , "https://dashscope.aliyuncs.com/compatible-mode/v1" )),
70+ model_config_dict = {
71+ "temperature" : float (os .getenv ("ASSISTANT_ROLE_API_MODEL_TEMPERATURE" , os .getenv ("LLM_ROLE_API_MODEL_TEMPERATURE" , "0.4" ))),
72+ "max_tokens" : int (os .getenv ("ASSISTANT_ROLE_API_MODEL_MAX_TOKENS" , os .getenv ("LLM_ROLE_API_MODEL_MAX_TOKENS" , "4096" )))
73+ },
74+
6775 ),
6876 "browsing" : ModelFactory .create (
6977 model_platform = ModelPlatformType .OPENAI_COMPATIBLE_MODEL ,
70- model_type = "qwen-vl-max" ,
71- api_key = os .getenv ("QWEN_API_KEY" ),
72- url = "https://dashscope.aliyuncs.com/compatible-mode/v1" ,
73- model_config_dict = {"temperature" : 0.4 , "max_tokens" : 128000 },
78+
79+ model_type = os .getenv ("WEB_ROLE_API_BASE_URL" , os .getenv ("VLLM_ROLE_API_MODEL_TYPE" , "qwen-vl-max" )),
80+ api_key = os .getenv ("WEB_ROLE_API_KEY" , os .getenv ("VLLM_ROLE_API_KEY" , os .getenv ("QWEN_API_KEY" , "Your_Key" ))),
81+ url = os .getenv ("USER_ROLE_API_BASE_URL" , os .getenv ("VLLM_ROLE_API_BASE_URL" , "https://dashscope.aliyuncs.com/compatible-mode/v1" )),
82+ model_config_dict = {
83+ "temperature" : float (os .getenv ("WEB_ROLE_API_MODEL_TEMPERATURE" , os .getenv ("VLLM_ROLE_API_MODEL_TEMPERATURE" , "0.4" ))),
84+ "max_tokens" : int (os .getenv ("WEB_ROLE_API_MODEL_MAX_TOKENS" , os .getenv ("VLLM_ROLE_API_MODEL_MAX_TOKENS" , "4096" )))
85+ },
7486 ),
7587 "planning" : ModelFactory .create (
7688 model_platform = ModelPlatformType .OPENAI_COMPATIBLE_MODEL ,
77- model_type = "qwen-max" ,
78- api_key = os .getenv ("QWEN_API_KEY" ),
79- url = "https://dashscope.aliyuncs.com/compatible-mode/v1" ,
80- model_config_dict = {"temperature" : 0.4 , "max_tokens" : 128000 },
89+ model_type = os .getenv ("PLANNING_ROLE_API_MODEL_TYPE" , os .getenv ("LLM_ROLE_API_MODEL_TYPE" , "qwen-max" )),
90+ api_key = os .getenv ("PLANNING_ROLE_API_KEY" , os .getenv ("LLM_ROLE_API_KEY" , os .getenv ("QWEN_API_KEY" , "Your_Key" ))),
91+ url = os .getenv ("PLANNING_ROLE_API_BASE_URL" , os .getenv ("LLM_ROLE_API_BASE_URL" , "https://dashscope.aliyuncs.com/compatible-mode/v1" )),
92+ model_config_dict = {
93+ "temperature" : float (os .getenv ("PLANNING_ROLE_API_MODEL_TEMPERATURE" , os .getenv ("LLM_ROLE_API_MODEL_TEMPERATURE" , "0.4" ))),
94+ "max_tokens" : int (os .getenv ("PLANNING_ROLE_API_MODEL_MAX_TOKENS" , os .getenv ("LLM_ROLE_API_MODEL_MAX_TOKENS" , "4096" )))
95+ },
8196 ),
8297 "image" : ModelFactory .create (
8398 model_platform = ModelPlatformType .OPENAI_COMPATIBLE_MODEL ,
84- model_type = "qwen-vl-max" ,
85- api_key = os .getenv ("QWEN_API_KEY" ),
86- url = "https://dashscope.aliyuncs.com/compatible-mode/v1" ,
87- model_config_dict = {"temperature" : 0.4 , "max_tokens" : 128000 },
99+ model_type = os .getenv ("IMAGE_ROLE_API_MODEL_TYPE" , os .getenv ("VLLM_ROLE_API_MODEL_TYPE" , "qwen-vl-max" )),
100+ api_key = os .getenv ("IMAGE_ROLE_API_KEY" , os .getenv ("VLLM_ROLE_API_KEY" , os .getenv ("QWEN_API_KEY" , "Your_Key" ))),
101+ url = os .getenv ("IMAGE_ROLE_API_BASE_URL" , os .getenv ("VLLM_ROLE_API_BASE_URL" , "https://dashscope.aliyuncs.com/compatible-mode/v1" )),
102+ model_config_dict = {
103+ "temperature" : float (os .getenv ("IMAGE_ROLE_API_MODEL_TEMPERATURE" , os .getenv ("VLLM_ROLE_API_MODEL_TEMPERATURE" , "0.4" ))),
104+ "max_tokens" : int (os .getenv ("IMAGE_ROLE_API_MODEL_MAX_TOKENS" , os .getenv ("VLLM_ROLE_API_MODEL_MAX_TOKENS" , "4096" )))
105+ },
88106 ),
89107 }
90108
@@ -126,13 +144,16 @@ def construct_society(question: str) -> RolePlaying:
126144 return society
127145
128146
129- def main ():
130- r"""Main function to run the OWL system with an example question."""
131- # Example research question
132- default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
133147
134- # Override default task if command line argument is provided
135- task = sys .argv [1 ] if len (sys .argv ) > 1 else default_task
148+ def main (question : str = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer." ):
149+ r"""Main function to run the OWL system with an example question.
150+ Args:
151+ question (str): The task or question to be addressed by the society.
152+ If not provided, a default question will be used.
153+ Defaults to "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
154+ Returns:
155+ None
156+ """
136157
137158 # Construct and run the society
138159 society = construct_society (task )
@@ -141,7 +162,9 @@ def main():
141162
142163 # Output the result
143164 print (f"\033 [94mAnswer: { answer } \033 [0m" )
165+ # Output the token count
166+ print (f"\033 [94mToken count: { token_count } \033 [0m" )
144167
145168
146169if __name__ == "__main__" :
147- main ()
170+ main (sys . argv [ 1 ] if len ( sys . argv ) > 1 else "" )
0 commit comments