Spaces:
Sleeping
Sleeping
Update app.py
Browse files9 unmodified lines1011121314151617181920212223242526272829303132333457 unmodified lines929394959697989 unmodified linesfrom openai import OpenAIimport osdef get_aliyun_response(prompt, model_name="qwen-turbo"):client = OpenAI(api_key=os.getenv('API_KEY'), # 请在此处用您的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):57 unmodified linesraise NotImplementedErrordef llm_caller(self, prompt):return get_aliyun_response(prompt)if __name__ == '__main__':9 unmodified lines10111213141557 unmodified lines737475767778798081828384858687888990919293949 unmodified linesfrom openai import OpenAIimport osclass SpyAgent(BasicAgent):57 unmodified linesraise NotImplementedErrordef llm_caller(self, prompt):client = OpenAI(api_key=os.getenv('API_KEY'))completion = client.chat.completions.create(model="gpt-4o-mini",messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},{'role': 'user', 'content': prompt}],temperature=0)try:return completion.choices[0].message.contentexcept Exception as e:print(e)return Noneif __name__ == '__main__':
app.py+16-20