Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,12 +6,12 @@ import gradio as gr
|
|
6 |
from langchain_openai import AzureChatOpenAI
|
7 |
|
8 |
# 讀取 config.ini 文件
|
9 |
-
def load_config(
|
10 |
config = configparser.ConfigParser()
|
11 |
|
12 |
-
#
|
13 |
try:
|
14 |
-
config.
|
15 |
if not config.sections(): # 檢查是否包含區段標題
|
16 |
raise ValueError("config.ini 檔案缺少區段標題,請確認檔案格式正確。")
|
17 |
except Exception as e:
|
@@ -61,7 +61,9 @@ def generate_monthly_report(weekly_reports_files, last_month_report_file, llm_gp
|
|
61 |
|
62 |
def process_reports(weekly_reports_files, last_month_report_file, config_file):
|
63 |
try:
|
64 |
-
|
|
|
|
|
65 |
llm_gpt4o = create_openai_client(config) # 創建 AzureOpenAI 客戶端
|
66 |
|
67 |
if not weekly_reports_files or not last_month_report_file:
|
|
|
6 |
from langchain_openai import AzureChatOpenAI
|
7 |
|
8 |
# 讀取 config.ini 文件
|
9 |
+
def load_config(config_file_path):
|
10 |
config = configparser.ConfigParser()
|
11 |
|
12 |
+
# 使用配置檔案路徑直接讀取文件
|
13 |
try:
|
14 |
+
config.read(config_file_path) # 使用檔案路徑來讀取
|
15 |
if not config.sections(): # 檢查是否包含區段標題
|
16 |
raise ValueError("config.ini 檔案缺少區段標題,請確認檔案格式正確。")
|
17 |
except Exception as e:
|
|
|
61 |
|
62 |
def process_reports(weekly_reports_files, last_month_report_file, config_file):
|
63 |
try:
|
64 |
+
# 將 config_file 參數傳遞為檔案路徑
|
65 |
+
config_file_path = config_file.name
|
66 |
+
config = load_config(config_file_path) # 讀取上傳的 config.ini
|
67 |
llm_gpt4o = create_openai_client(config) # 創建 AzureOpenAI 客戶端
|
68 |
|
69 |
if not weekly_reports_files or not last_month_report_file:
|