| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | import argparse |
| | import logging |
| | import os |
| |
|
| | import sys |
| |
|
| | from camel.typing import ModelType |
| |
|
| | root = os.path.dirname(__file__) |
| | sys.path.append(root) |
| |
|
| | from chatdev.chat_chain import ChatChain |
| |
|
| |
|
| | def get_config(company): |
| | """ |
| | return configuration json files for ChatChain |
| | user can customize only parts of configuration json files, other files will be left for default |
| | Args: |
| | company: customized configuration name under CompanyConfig/ |
| | |
| | Returns: |
| | path to three configuration jsons: [config_path, config_phase_path, config_role_path] |
| | """ |
| | config_dir = os.path.join(root, "CompanyConfig", company) |
| | default_config_dir = os.path.join(root, "CompanyConfig", "Default") |
| |
|
| | config_files = [ |
| | "ChatChainConfig.json", |
| | "PhaseConfig.json", |
| | "RoleConfig.json" |
| | ] |
| |
|
| | config_paths = [] |
| |
|
| | for config_file in config_files: |
| | company_config_path = os.path.join(config_dir, config_file) |
| | default_config_path = os.path.join(default_config_dir, config_file) |
| |
|
| | if os.path.exists(company_config_path): |
| | config_paths.append(company_config_path) |
| | else: |
| | config_paths.append(default_config_path) |
| |
|
| | return tuple(config_paths) |
| |
|
| |
|
| |
|
| | def runchatdev(task, config): |
| |
|
| | parser = argparse.ArgumentParser(description='argparse') |
| | parser.add_argument('--config', type=str, default="Default", |
| | help="Name of config, which is used to load configuration under CompanyConfig/") |
| | parser.add_argument('--org', type=str, default="Company", |
| | help="Name of organization, your software will be generated in WareHouse/name_org_timestamp") |
| | parser.add_argument('--task', type=str, default="Develop a basic Gomoku game.", |
| | help="Prompt of software") |
| | parser.add_argument('--name', type=str, default="Game", |
| | help="Name of software, your software will be generated in WareHouse/name_org_timestamp") |
| | parser.add_argument('--model', type=str, default="GPT_3_5_TURBO", |
| | help="GPT Model, choose from {'GPT_3_5_TURBO','GPT_4','GPT_4_32K'}") |
| | args = parser.parse_args() |
| |
|
| | args.config = config |
| | args.task = task |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | config_path, config_phase_path, config_role_path = get_config(args.config) |
| | args2type = {'GPT_3_5_TURBO': ModelType.GPT_3_5_TURBO, 'GPT_4': ModelType.GPT_4, 'GPT_4_32K': ModelType.GPT_4_32k} |
| | chat_chain = ChatChain(config_path=config_path, |
| | config_phase_path=config_phase_path, |
| | config_role_path=config_role_path, |
| | task_prompt=args.task, |
| | project_name=args.name, |
| | org_name=args.org, |
| | model_type=args2type[args.model]) |
| |
|
| | |
| | |
| | |
| |
|
| | logging.basicConfig(filename=chat_chain.log_filepath, level=logging.DEBUG, |
| | format='[%(asctime)s %(levelname)s] %(message)s', |
| | datefmt='%Y-%d-%m %H:%M:%S', encoding="utf-8") |
| |
|
| | |
| | |
| | |
| |
|
| | chat_chain.pre_processing() |
| |
|
| | |
| | |
| | |
| |
|
| | chat_chain.make_recruitment() |
| |
|
| | |
| | |
| | |
| |
|
| | chat_chain.execute_chain() |
| |
|
| | |
| | |
| | |
| |
|
| | chat_chain.post_processing() |
| |
|
| | if __name__ == "__main__": |
| | runchatdev() |