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

Update src/DAG2poster.py

Browse files
Files changed (1) hide show
  1. src/DAG2poster.py +12 -2
src/DAG2poster.py CHANGED
@@ -157,10 +157,15 @@ def generate_poster_outline_txt(
157
  api_keys_config = config.get("api_keys", {}) if config else {}
158
 
159
  if is_gemini:
 
 
 
 
 
160
  # Setup Google GenAI Client
161
  api_key = api_key or api_keys_config.get("gemini_api_key") or os.getenv("GOOGLE_API_KEY")
162
 
163
- client = genai.Client(api_key=api_key)
164
  else:
165
  # Setup OpenAI Client
166
  api_key = api_key or api_keys_config.get("openai_api_key") or os.getenv("OPENAI_API_KEY")
@@ -781,10 +786,15 @@ def modified_poster_logic(
781
  out_text = ""
782
 
783
  if is_gemini:
 
 
 
 
 
784
  # --- Gemini Client Setup ---
785
  api_key = api_keys_config.get("gemini_api_key") or os.getenv("GOOGLE_API_KEY")
786
 
787
- client = genai.Client(api_key=api_key)
788
 
789
  # Call Gemini
790
  # 将 system prompt 放入配置中,user content 放入 contents
 
157
  api_keys_config = config.get("api_keys", {}) if config else {}
158
 
159
  if is_gemini:
160
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
161
+ if raw_url.endswith("/v1"):
162
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
163
+ else:
164
+ base_url = raw_url
165
  # Setup Google GenAI Client
166
  api_key = api_key or api_keys_config.get("gemini_api_key") or os.getenv("GOOGLE_API_KEY")
167
 
168
+ client = genai.Client(api_key=api_key, http_options={'base_url': base_url} if base_url else None)
169
  else:
170
  # Setup OpenAI Client
171
  api_key = api_key or api_keys_config.get("openai_api_key") or os.getenv("OPENAI_API_KEY")
 
786
  out_text = ""
787
 
788
  if is_gemini:
789
+ raw_url = config.get('api_base_url', '').strip().rstrip("/")
790
+ if raw_url.endswith("/v1"):
791
+ base_url = raw_url[:-3].rstrip("/") # 去掉最后的 /v1
792
+ else:
793
+ base_url = raw_url
794
  # --- Gemini Client Setup ---
795
  api_key = api_keys_config.get("gemini_api_key") or os.getenv("GOOGLE_API_KEY")
796
 
797
+ client = genai.Client(api_key=api_key, http_options={'base_url': base_url} if base_url else None)
798
 
799
  # Call Gemini
800
  # 将 system prompt 放入配置中,user content 放入 contents