zcfrank1st commited on
Commit
46bcf44
·
verified ·
1 Parent(s): c1930c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -79
app.py CHANGED
@@ -52,85 +52,6 @@ def call_examine(p):
52
  return "Working hard on it..."
53
 
54
 
55
- def run_flow(scene, text):
56
- print(scene, text)
57
- if scene == "企业净调":
58
- return call_company(text)
59
- if scene == "企业舆情总结":
60
- return call_summary(text)
61
- if scene == "金融产品广告合规检查":
62
- return call_examine(text)
63
- else:
64
- pass
65
-
66
- with gr.Blocks() as demo:
67
- gr.Markdown("# 💰金融场景AI助手")
68
- with gr.Row():
69
- with gr.Column():
70
- scene = gr.Dropdown(
71
- ["企业净调", "企业舆情总结", "金融产品广告合规检查"], label="场景", info="请选择场景"
72
- )
73
- text = gr.Textbox(label="输入")
74
- btn = gr.Button("开始")
75
- with gr.Column():
76
- result = gr.Markdown(label="结果", show_label=True, container=True, min_height=100)
77
-
78
- btn.click(fn=run_flow, inputs=[scene, text], outputs=result)
79
-
80
- demo.launch()import gradio as gr
81
- from http import HTTPStatus
82
- import os
83
- import requests
84
- import json
85
-
86
- from dashscope import Application
87
-
88
- def call_company(p):
89
- prompt = p
90
- response = Application.call(
91
- # 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
92
- api_key=os.getenv("DASHSCOPE_API_KEY"),
93
- app_id=os.getenv("APP_ID"), # 替换为实际的应用 ID
94
- prompt=prompt,
95
- # biz_params=biz_params # 传递业务参数
96
- )
97
-
98
- if response.status_code != HTTPStatus.OK:
99
- return response.message
100
- else:
101
- return response.output.text
102
-
103
- URL="https://api.coze.cn/v3/chat"
104
- HEADERS={"Authorization":os.getenv("COZE_TEMP"), "Content-Type":"application/json"}
105
-
106
- def call_summary(p):
107
- return "Working hard on it..."
108
-
109
- def call_examine(p):
110
- file_url = p
111
- data = {
112
- "bot_id": "7448073169124573218",
113
- "user_id": "111",
114
- "stream": False,
115
- "auto_save_history": True,
116
- "additional_messages":[
117
- {
118
- "role":"user",
119
- "content":"[{\"type\":\"text\",\"text\":\"帮我分析一下广告图片\"},{\"type\":\"image\",\"file_url\":\""+ file_url + "\"}]",
120
- "content_type":"object_string"
121
- }
122
- ]
123
- }
124
-
125
- print(data)
126
-
127
- res = requests.post(URL, headers=HEADERS, data=json.dumps(data))
128
-
129
- print(res.json())
130
- print(res.json()['code'])
131
- return "Working hard on it..."
132
-
133
-
134
  def run_flow(scene, text):
135
  print(scene, text)
136
  if scene == "企业净调":
 
52
  return "Working hard on it..."
53
 
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  def run_flow(scene, text):
56
  print(scene, text)
57
  if scene == "企业净调":