jiangjunguang1123
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,29 @@ from agent_build_sdk.sdk.agent import format_prompt
|
|
7 |
from prompts import DESC_PROMPT, VOTE_PROMPT
|
8 |
from agent_build_sdk.utils.logger import logger
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
class SpyAgent(BasicAgent):
|
11 |
|
12 |
def perceive(self, req=AgentReq):
|
@@ -68,6 +91,9 @@ class SpyAgent(BasicAgent):
|
|
68 |
else:
|
69 |
raise NotImplementedError
|
70 |
|
|
|
|
|
|
|
71 |
|
72 |
if __name__ == '__main__':
|
73 |
name = 'spy'
|
|
|
7 |
from prompts import DESC_PROMPT, VOTE_PROMPT
|
8 |
from agent_build_sdk.utils.logger import logger
|
9 |
|
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="sk-e37d575e0b2746569573d17c2b60b941", # 请在此处用您的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 |
|
35 |
def perceive(self, req=AgentReq):
|
|
|
91 |
else:
|
92 |
raise NotImplementedError
|
93 |
|
94 |
+
def llm_caller(self, prompt):
|
95 |
+
return get_aliyun_response(prompt)
|
96 |
+
|
97 |
|
98 |
if __name__ == '__main__':
|
99 |
name = 'spy'
|