o1 (has vision) and o3-mini (no vision)
This commit is contained in:
@@ -7,7 +7,6 @@ from .utils import is_image_path, encode_image
|
||||
def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: str, max_tokens=256, temperature=0, provider_base_url: str = "https://api.openai.com/v1"):
|
||||
headers = {"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {api_key}"}
|
||||
|
||||
final_messages = [{"role": "system", "content": system}]
|
||||
|
||||
if type(messages) == list:
|
||||
@@ -16,7 +15,8 @@ def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: s
|
||||
if isinstance(item, dict):
|
||||
for cnt in item["content"]:
|
||||
if isinstance(cnt, str):
|
||||
if is_image_path(cnt):
|
||||
if is_image_path(cnt) and 'o3-mini' not in model_name:
|
||||
# 03 mini does not support images
|
||||
base64_image = encode_image(cnt)
|
||||
content = {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{base64_image}"}}
|
||||
else:
|
||||
@@ -41,9 +41,12 @@ def run_oai_interleaved(messages: list, system: str, model_name: str, api_key: s
|
||||
payload = {
|
||||
"model": model_name,
|
||||
"messages": final_messages,
|
||||
"max_tokens": max_tokens,
|
||||
"temperature": temperature
|
||||
}
|
||||
if 'o1' in model_name or 'o3-mini' in model_name:
|
||||
payload['reasoning_effort'] = 'low'
|
||||
payload['max_completion_tokens'] = max_tokens
|
||||
else:
|
||||
payload['max_tokens'] = max_tokens
|
||||
|
||||
response = requests.post(
|
||||
f"{provider_base_url}/chat/completions", headers=headers, json=payload
|
||||
Reference in New Issue
Block a user