zcfrank1st commited on
Commit
308b157
·
verified ·
1 Parent(s): 112376f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -20,9 +20,34 @@ def call_company(p):
20
  else:
21
  return response.output.text
22
 
 
 
 
23
  def call_summary(p):
24
  return "Working hard on it..."
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  def run_flow(scene, text):
28
  print(scene, text)
@@ -30,6 +55,8 @@ def run_flow(scene, text):
30
  return call_company(text)
31
  if scene == "企业舆情总结":
32
  return call_summary(text)
 
 
33
  else:
34
  pass
35
 
@@ -38,7 +65,7 @@ with gr.Blocks() as demo:
38
  with gr.Row():
39
  with gr.Column():
40
  scene = gr.Dropdown(
41
- ["企业净调", "企业舆情总结"], label="场景", info="请选择场景"
42
  )
43
  text = gr.Textbox(label="输入")
44
  btn = gr.Button("开始")
 
20
  else:
21
  return response.output.text
22
 
23
+ URL="https://api.coze.cn/v3/chat"
24
+ HEADERS={"Authorization":os.getenv("COZE_TEMP"), "Content-Type":"application/json"}
25
+
26
  def call_summary(p):
27
  return "Working hard on it..."
28
 
29
+ def call_examine(p):
30
+ file_url = ""
31
+ data = {
32
+ "bot_id": "7448073169124573218",
33
+ "user_id": "111",
34
+ "stream": False,
35
+ "auto_save_history": True,
36
+ "additional_messages":[
37
+ {
38
+ "role":"user",
39
+ "content":"[{\"type\":\"text\",\"text\":\"帮我分析一下广告图片\"},{\"type\":\"image\",\"file_url\":"+ file_url + "}]",
40
+ "content_type":"object_string"
41
+ }
42
+ ]
43
+ }
44
+
45
+ res = requests.post(URL, headers=HEADERS, data=data)
46
+
47
+ print(res.json())
48
+ print(res.json()['code'])
49
+ return "Working hard on it..."
50
+
51
 
52
  def run_flow(scene, text):
53
  print(scene, text)
 
55
  return call_company(text)
56
  if scene == "企业舆情总结":
57
  return call_summary(text)
58
+ if scene == "金融产品广告合规检查":
59
+ return call_examine(text)
60
  else:
61
  pass
62
 
 
65
  with gr.Row():
66
  with gr.Column():
67
  scene = gr.Dropdown(
68
+ ["企业净调", "企业舆情总结", "金融产品广告合规检查"], label="场景", info="请选择场景"
69
  )
70
  text = gr.Textbox(label="输入")
71
  btn = gr.Button("开始")