Liyonghui commited on
Commit
7372a64
1 Parent(s): 2a7bd60

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. app.py +57 -0
  3. logo.jpg +3 -0
  4. requirements.txt +2 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ logo.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+
4
+ API_KEY="4d95a8e9615d73939d5f0b8997bc4614eaf96f854a5ab503f5d781e1c5521c73"
5
+ url = "https://api.tigerbot.com/v1/chat/completions"
6
+
7
+ headers = {
8
+ 'Authorization': 'Bearer ' + API_KEY
9
+ }
10
+ payload = {
11
+ "model": "tigerbot-13b-chat",
12
+ "query": "",
13
+ "session":[],
14
+ "internet": True
15
+ }
16
+ def getAnsBytiger(t):
17
+ payload['query'] = t
18
+ response = requests.post(url, headers=headers, json=payload)
19
+ res = response.json()
20
+ res = res["result"]
21
+ payload['session'].append({"human": t, "assistant": res})
22
+ return res
23
+
24
+
25
+ if 'prompts' not in st.session_state:
26
+ st.session_state['prompts'] = []
27
+
28
+ if 'generated' not in st.session_state:
29
+ st.session_state['generated'] = []
30
+
31
+ if 'past' not in st.session_state:
32
+ st.session_state['past'] = []
33
+
34
+ def end_click():
35
+ st.session_state['prompts'] = []
36
+ st.session_state['past'] = []
37
+ st.session_state['generated'] = []
38
+ st.session_state['user'] = ""
39
+ def chat_click():
40
+ if st.session_state['user'] != '':
41
+ chat_input = st.session_state['user']
42
+ output = getAnsBytiger(chat_input)
43
+ st.session_state['past'].append(chat_input)
44
+ st.session_state['generated'].append(output)
45
+ st.session_state['prompts'].append(output)
46
+ st.session_state['user'] = ""
47
+ st.image("./logo.jpg", use_column_width='auto')
48
+ st.title("珠宝贝专属聊天机器人")
49
+
50
+ user_input = st.text_input("输入:", key="user")
51
+ chat_button = st.button("发送", on_click=chat_click)
52
+ end_button = st.button("新聊天", on_click=end_click)
53
+
54
+ if st.session_state['generated']:
55
+ for i in range(0, len(st.session_state['generated']), 1):
56
+ message(st.session_state['past'][i], is_user=True)
57
+ message(st.session_state['generated'][i], key=str(i))
logo.jpg ADDED

Git LFS Details

  • SHA256: 7b42e8ea68f5080e29d84428f931785476552b1d19032c80d274d6a71665543f
  • Pointer size: 132 Bytes
  • Size of remote file: 2.38 MB
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ requests
2
+ json