Skip to content

Commit 64613eb

Browse files
authored
file path auto adaptation (#61)
2 parents 4862a6c + 1a36475 commit 64613eb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: app/daily_hot_news.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
import feedparser
55
import html2text
66
import concurrent.futures
7-
7+
import os
88
from app.gpt import get_answer_from_llama_web
99

10-
with open("app/data/hot_news_rss.json", "r") as f:
10+
current_file_path = os.path.abspath(__file__)
11+
current_dir_path = os.path.dirname(current_file_path)
12+
hot_news_file_path = os.path.join(current_dir_path, "data", "hot_news_rss.json")
13+
14+
with open(hot_news_file_path, "r") as f:
1115
rss_urls = json.load(f)
1216

1317
TODAY = today = date.today()

Diff for: app/slash_command.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import json
2+
import os
23

3-
with open("app/data/prompt.json", "r") as f:
4+
5+
current_file_path = os.path.abspath(__file__)
6+
current_dir_path = os.path.dirname(current_file_path)
7+
slash_propmt_file_path = os.path.join(current_dir_path, "data", "prompt.json")
8+
9+
with open(slash_propmt_file_path, "r") as f:
410
prompt_data = json.load(f)
511

612
def register_slack_slash_commands(slack_app):
@@ -256,4 +262,4 @@ def handle_command_gpt_as_regex_master(ack, say, command):
256262
text=f"<@{user_id}>, let's talk!",
257263
blocks=blocks,
258264
reply_broadcast=True
259-
)
265+
)

0 commit comments

Comments
 (0)