wenkai26 commited on
Commit
d82c1ce
·
verified ·
1 Parent(s): 9697ddf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  from volcengine.maas.v2 import MaasService
3
  from volcengine.maas import MaasException, ChatRole
4
  import json
5
-
6
 
7
  def maas_chat(input):
8
  query = input.split('\n')
@@ -10,9 +10,12 @@ def maas_chat(input):
10
  query = json.dumps(query, ensure_ascii=False)
11
  maas = MaasService('maas-api.ml-platform-cn-beijing.volces.com', 'cn-beijing')
12
 
13
- # set ak&sk
14
- maas.set_ak("AKLTYWE0OWIzODc0YjU0NGRjOGE2N2RjMzE2NTUwZjA3OGQ")
15
- maas.set_sk("T0dJd1pHUXlNemxoWkRJME5HRmlORGxoWWpGa05ESTJOR1EyTURSbFpqTQ==")
 
 
 
16
 
17
  # chat
18
  req = {
@@ -35,7 +38,8 @@ def maas_chat(input):
35
  ]
36
  }
37
 
38
- endpoint_id = 'ep-20240402173628-s7zd6'
 
39
  resp = maas.chat(endpoint_id, req)
40
  output = resp.choices[0].message['content']
41
  #去除output'符号
 
2
  from volcengine.maas.v2 import MaasService
3
  from volcengine.maas import MaasException, ChatRole
4
  import json
5
+ import os
6
 
7
  def maas_chat(input):
8
  query = input.split('\n')
 
10
  query = json.dumps(query, ensure_ascii=False)
11
  maas = MaasService('maas-api.ml-platform-cn-beijing.volces.com', 'cn-beijing')
12
 
13
+
14
+ # 使用 os 模块来访问变量和秘密值
15
+ ak = os.getenv('AK')
16
+ sk = os.getenv('SK')
17
+ maas.set_ak(ak)
18
+ maas.set_sk(sk)
19
 
20
  # chat
21
  req = {
 
38
  ]
39
  }
40
 
41
+ ID = os.getenv('ID')
42
+ endpoint_id = ID
43
  resp = maas.chat(endpoint_id, req)
44
  output = resp.choices[0].message['content']
45
  #去除output'符号