steveagi commited on
Commit
c964edf
·
1 Parent(s): f3bdb49
Files changed (2) hide show
  1. games/game_angrybird.py +16 -2
  2. games/game_snake.py +6 -5
games/game_angrybird.py CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  from games.angrybirds.angrybirds import angrybird
2
 
3
 
@@ -5,5 +9,15 @@ game = angrybird()
5
 
6
 
7
  def process(command: str):
8
- res1, _ = game.query_entry_point(command)
9
- return res1
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import requests
4
+
5
  from games.angrybirds.angrybirds import angrybird
6
 
7
 
 
9
 
10
 
11
  def process(command: str):
12
+ url = f'https://{os.getenv("hfs_space")}.hf.space/games/angrybird'
13
+ # url = 'http://127.0.0.1:8080/nlp'
14
+ myobj = {
15
+ 'command': command,
16
+ }
17
+ headers = {'Authorization': f'Bearer {os.getenv("hfs_token")}'}
18
+
19
+ x = requests.post(url, json=myobj, headers=headers)
20
+ print(x.text)
21
+
22
+ # res1, _ = game.query_entry_point(command)
23
+ return json.loads(x.text)
games/game_snake.py CHANGED
@@ -1,19 +1,20 @@
 
1
  import json
2
  import requests
3
- import urllib.parse
4
 
5
  from games.snake.snake import snake
6
 
 
7
  game = snake()
8
 
9
- def process(token: str, command: str):
10
- url = 'https://steveagi-pgtrain.hf.space/games/snake'
 
11
  # url = 'http://127.0.0.1:8080/nlp'
12
  myobj = {
13
  'command': command,
14
  }
15
- auth_token = token
16
- headers = {'Authorization': f'Bearer {auth_token}'}
17
 
18
  x = requests.post(url, json=myobj, headers=headers)
19
  print(x.text)
 
1
+ import os
2
  import json
3
  import requests
 
4
 
5
  from games.snake.snake import snake
6
 
7
+
8
  game = snake()
9
 
10
+
11
+ def process(command: str):
12
+ url = f'https://{os.getenv("hfs_space")}.hf.space/games/snake'
13
  # url = 'http://127.0.0.1:8080/nlp'
14
  myobj = {
15
  'command': command,
16
  }
17
+ headers = {'Authorization': f'Bearer {os.getenv("hfs_token")}'}
 
18
 
19
  x = requests.post(url, json=myobj, headers=headers)
20
  print(x.text)