Update app.py
Browse files
app.py
CHANGED
|
@@ -10,25 +10,6 @@ from agent_build_sdk.utils.logger import logger
|
|
| 10 |
from openai import OpenAI
|
| 11 |
import os
|
| 12 |
|
| 13 |
-
def get_aliyun_response(prompt, model_name="qwen-turbo"):
|
| 14 |
-
client = OpenAI(
|
| 15 |
-
api_key=os.getenv('API_KEY'), # 请在此处用您的API Key进行替换
|
| 16 |
-
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", # 填写DashScope服务的base_url
|
| 17 |
-
)
|
| 18 |
-
completion = client.chat.completions.create(
|
| 19 |
-
model=model_name,
|
| 20 |
-
messages=[
|
| 21 |
-
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
| 22 |
-
{'role': 'user', 'content': prompt}],
|
| 23 |
-
temperature=0.8,
|
| 24 |
-
top_p=0.8
|
| 25 |
-
)
|
| 26 |
-
try:
|
| 27 |
-
return completion.choices[0].message.content
|
| 28 |
-
except Exception as e:
|
| 29 |
-
print(e)
|
| 30 |
-
return None
|
| 31 |
-
|
| 32 |
|
| 33 |
class SpyAgent(BasicAgent):
|
| 34 |
|
|
@@ -92,7 +73,22 @@ class SpyAgent(BasicAgent):
|
|
| 92 |
raise NotImplementedError
|
| 93 |
|
| 94 |
def llm_caller(self, prompt):
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
if __name__ == '__main__':
|
|
|
|
| 10 |
from openai import OpenAI
|
| 11 |
import os
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
class SpyAgent(BasicAgent):
|
| 15 |
|
|
|
|
| 73 |
raise NotImplementedError
|
| 74 |
|
| 75 |
def llm_caller(self, prompt):
|
| 76 |
+
client = OpenAI(
|
| 77 |
+
api_key=os.getenv('API_KEY')
|
| 78 |
+
)
|
| 79 |
+
completion = client.chat.completions.create(
|
| 80 |
+
model="gpt-4o-mini",
|
| 81 |
+
messages=[
|
| 82 |
+
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
| 83 |
+
{'role': 'user', 'content': prompt}
|
| 84 |
+
],
|
| 85 |
+
temperature=0
|
| 86 |
+
)
|
| 87 |
+
try:
|
| 88 |
+
return completion.choices[0].message.content
|
| 89 |
+
except Exception as e:
|
| 90 |
+
print(e)
|
| 91 |
+
return None
|
| 92 |
|
| 93 |
|
| 94 |
if __name__ == '__main__':
|