import sys import os parent_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') sys.path.append(parent_dir) from qwen_agent.planning.plan_executor import PlanExecutor import importlib import json prompt_lan = 'CN' llm_name = 'qwen-plus' max_ref_token = 4000 # workstation_port = int(sys.argv[4]) # model_server = 'http://10.10.0.10:7907/v1' model_server = 'http://127.0.0.1:7903/v1' api_key = '' server_host = '127.0.0.1' if model_server.startswith('http'): source = 'local' elif model_server.startswith('dashscope'): source = 'dashscope' async def run(executor): async for rsp in executor.run('上海安谱实验科技股份有限公司近几年中标金额折线图', []): # pass print(f"-----execute response: {rsp}") if __name__ == '__main__': if llm_name.startswith('gpt'): module = 'qwen_agent.llm.gpt' llm = importlib.import_module(module).GPT(llm_name) elif llm_name.startswith('Qwen') or llm_name.startswith('qwen'): module = 'qwen_agent.llm.qwen' llm = importlib.import_module(module).Qwen(llm_name, model_server=model_server, api_key=api_key) else: raise NotImplementedError executor = PlanExecutor( enable_critic=False, llm=llm, stream=True ) # with open("/home/ys/LianqiaiAgent/tmp.out", "w") as fout: # for rsp in executor.run('请分析下浙江万维空间信息技术有限公司的中标城市的分布情况', []): # fout.write(json.dumps(rsp, ensure_ascii=False)) # executor = PlanExecutor( # enable_critic=False, # llm=llm, # stream=True # ) # for rsp in executor.run('你好你是谁', []): # pass # print(f"-----execute response: {rsp}")