Laramie2 commited on
Commit
c949916
·
verified ·
1 Parent(s): 6b075de

Update src/DAG2ppt.py

Browse files
Files changed (1) hide show
  1. src/DAG2ppt.py +28 -4
src/DAG2ppt.py CHANGED
@@ -177,8 +177,14 @@ def outline_initialize(dag_json_path, outline_initialize_prompt, model, config):
177
  # --- Gemini Call (google-genai SDK) ---
178
  api_key = config['api_keys'].get('gemini_api_key')
179
 
 
 
 
 
 
 
180
  # 配置 Client
181
- client = genai.Client(api_key=api_key)
182
 
183
  # 构造 user 消息内容
184
  user_content = f"{outline_initialize_prompt}\n\nData Context:\n{first_node_text}"
@@ -312,7 +318,13 @@ def generate_complete_outline(
312
  if is_gemini:
313
  api_key = config['api_keys'].get('gemini_api_key')
314
 
315
- client = genai.Client(api_key=api_key)
 
 
 
 
 
 
316
  else:
317
  api_key = config['api_keys'].get('openai_api_key')
318
  client = OpenAI(api_key=api_key)
@@ -427,7 +439,13 @@ def arrange_template(
427
  if is_gemini:
428
  api_key = config['api_keys'].get('gemini_api_key')
429
 
430
- client = genai.Client(api_key=api_key)
 
 
 
 
 
 
431
  else:
432
  api_key = config['api_keys'].get('openai_api_key')
433
 
@@ -647,8 +665,14 @@ def generate_ppt(
647
 
648
  if is_gemini:
649
  api_key = config['api_keys'].get('gemini_api_key')
 
 
 
 
 
 
650
 
651
- client = genai.Client(api_key=api_key)
652
  else:
653
  api_key = config['api_keys'].get('openai_api_key')
654
 
 
177
  # --- Gemini Call (google-genai SDK) ---
178
  api_key = config['api_keys'].get('gemini_api_key')
179
 
180
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
181
+ if raw_url.endswith("/v1"):
182
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
183
+ else:
184
+ base_url = raw_url
185
+
186
  # 配置 Client
187
+ client = genai.Client(api_key=api_key,http_options={'base_url': base_url} if base_url else None)
188
 
189
  # 构造 user 消息内容
190
  user_content = f"{outline_initialize_prompt}\n\nData Context:\n{first_node_text}"
 
318
  if is_gemini:
319
  api_key = config['api_keys'].get('gemini_api_key')
320
 
321
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
322
+ if raw_url.endswith("/v1"):
323
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
324
+ else:
325
+ base_url = raw_url
326
+
327
+ client = genai.Client(api_key=api_key, http_options={'base_url': base_url} if base_url else None)
328
  else:
329
  api_key = config['api_keys'].get('openai_api_key')
330
  client = OpenAI(api_key=api_key)
 
439
  if is_gemini:
440
  api_key = config['api_keys'].get('gemini_api_key')
441
 
442
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
443
+ if raw_url.endswith("/v1"):
444
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
445
+ else:
446
+ base_url = raw_url
447
+
448
+ client = genai.Client(api_key=api_key, http_options={'base_url': base_url} if base_url else None)
449
  else:
450
  api_key = config['api_keys'].get('openai_api_key')
451
 
 
665
 
666
  if is_gemini:
667
  api_key = config['api_keys'].get('gemini_api_key')
668
+
669
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
670
+ if raw_url.endswith("/v1"):
671
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
672
+ else:
673
+ base_url = raw_url
674
 
675
+ client = genai.Client(api_key=api_key, http_options={'base_url': base_url} if base_url else None)
676
  else:
677
  api_key = config['api_keys'].get('openai_api_key')
678