xusenlinzy / api-for-open-llm

Openai style api for open large language models, using LLMs just as chatgpt! Support for LLaMA, LLaMA-2, BLOOM, Falcon, Baichuan, Qwen, Xverse, SqlCoder, CodeLLaMA, ChatGLM, ChatGLM2, ChatGLM3 etc. 开源大模型的统一后端接口
Apache License 2.0
2.31k stars 262 forks source link

💡 [REQUEST] - 是否有计划增加对autogen的支持? #160

Closed darvsum closed 3 months ago

darvsum commented 10 months ago

起始日期 | Start Date

No response

实现PR | Implementation PR

No response

相关Issues | Reference Issues

No response

摘要 | Summary

希望能支持autogen直接调用api-for-open-llm的api接口。

基本示例 | Basic Example

希望能支持autogen

缺陷 | Drawbacks

未解决问题 | Unresolved questions

No response

darvsum commented 9 months ago

API-FOR-OPEN-LLM当前支持autogen单个agent使用,但是多个agent调用时报错。 报错信息如下: user_proxy (to chat_manager):

find a lastest paper about gpt-4 on arxiv and find its potential applications in software.


Traceback (most recent call last): File "/tools/codes/test-autogen02/react_demo4.py", line 697, in test_autogen15() File "/tools/codes/test-autogen02/react_demo4.py", line 690, in test_autogen15 user_proxy.initiate_chat( File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/conversable_agent.py", line 550, in initiate_chat self.send(self.generate_init_message(context), recipient, silent=silent) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/conversable_agent.py", line 348, in send recipient.receive(message, self, request_reply, silent) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/conversable_agent.py", line 481, in receive reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/conversable_agent.py", line 906, in generate_reply final, reply = reply_func(self, messages=messages, sender=sender, config=reply_func_tuple["config"]) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/groupchat.py", line 269, in run_chat speaker = groupchat.select_speaker(speaker, self) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/groupchat.py", line 158, in select_speaker final, name = selector.generate_oai_reply( File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/agentchat/conversable_agent.py", line 625, in generate_oai_reply response = client.create( File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/oai/client.py", line 247, in create response = self._completions_create(client, params) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/autogen/oai/client.py", line 327, in _completions_create response = completions.create(params) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/openai/_utils/_utils.py", line 299, in wrapper return func(*args, **kwargs) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/openai/resources/chat/completions.py", line 598, in create return self._post( File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/openai/_base_client.py", line 1063, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/openai/_base_client.py", line 842, in request return self._request( File "/root/anaconda3/envs/test-autogen02/lib/python3.10/site-packages/openai/_base_client.py", line 885, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'detail': 'Invalid request: Incorrect role system.'}

Process finished with exit code 1

这是调用模型时的请求:

2023-12-01 09:05:37.232 | DEBUG | api.routes.chat:create_chat_completion:46 - ==== request ==== {'model': 'Qwen-14B-Chat', 'frequency_penalty': 0.0, 'function_call': None, 'functions': None, 'logit_bias': None, 'max_tokens': 1024, 'n': 1, 'presence_penalty': 0.0, 'response_format': None, 'seed': None, 'stop': ['<|endoftext|>', '<|im_end|>'], 'temperature': 0.0, 'tool_choice': None, 'tools': None, 'top_p': 1.0, 'user': None, 'stream': False, 'prompt_or_messages': [{'content': 'You are in a role play game. The following roles are available:\nuser_proxy: a human admin.\ncoder: You are a helpful AI assistant.\nSolve tasks using your coding and language skills.\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can\'t modify your code. So do not suggest incomplete code which requires users to modify. Don\'t use a code block if it\'s not intended to be executed by the user.\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don\'t include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use \'print\' function for the output when relevant. Check the execution result returned by the user.\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can\'t be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\nReply "TERMINATE" in the end when everything is done.\n \npm: creative in software product ideas..\n\nRead the following conversation.\nThen select the next role from [\'user_proxy\', \'coder\', \'pm\'] to play. Only return the role.', 'role': 'system'}, {'content': 'find a lastest paper about gpt-4 on arxiv and find its potential applications in software.', 'role': 'user'}, {'content': "Read the above conversation. Then select the next role from ['user_proxy', 'coder', 'pm'] to play. Only return the role.", 'role': 'system'}], 'echo': False, 'stop_token_ids': [151643, 151644, 151645]} INFO: 10.249.250.190:60878 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request