Spaces:
Sleeping
Sleeping
Update app.py
Browse files6 unmodified lines78910111255 unmodified lines6869707172736 unmodified linesfrom prompts import DESC_PROMPT, VOTE_PROMPTfrom agent_build_sdk.utils.logger import loggerclass SpyAgent(BasicAgent):def perceive(self, req=AgentReq):55 unmodified lineselse:raise NotImplementedErrorif __name__ == '__main__':name = 'spy'6 unmodified lines789101112131415161718192021222324252627282930313233343555 unmodified lines9192939495969798996 unmodified linesfrom prompts import DESC_PROMPT, VOTE_PROMPTfrom agent_build_sdk.utils.logger import loggerfrom openai import OpenAIimport osdef get_aliyun_response(prompt, model_name="qwen-turbo"):client = OpenAI(api_key="sk-e37d575e0b2746569573d17c2b60b941", # 请在此处用您的API Key进行替换base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", # 填写DashScope服务的base_url)completion = client.chat.completions.create(model=model_name,messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},{'role': 'user', 'content': prompt}],temperature=0.8,top_p=0.8)try:return completion.choices[0].message.contentexcept Exception as e:print(e)return Noneclass SpyAgent(BasicAgent):def perceive(self, req=AgentReq):55 unmodified lineselse:raise NotImplementedErrordef llm_caller(self, prompt):return get_aliyun_response(prompt)if __name__ == '__main__':name = 'spy'
app.py+26