From ae612ad7256a614bd150d101661105f4aef71b33 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Fri, 10 Apr 2026 09:50:36 +0000 Subject: [PATCH] fix: use requests instead of OpenAI client for thinking endpoint --- .../app/services/ai_agent/conversational.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/app/services/ai_agent/conversational.py b/src/backend/app/services/ai_agent/conversational.py index f91fd15..da85bcb 100644 --- a/src/backend/app/services/ai_agent/conversational.py +++ b/src/backend/app/services/ai_agent/conversational.py @@ -10,8 +10,8 @@ Uses MiniMax extended thinking API for proper thinking/reasoning separation. import json import re +import requests from typing import List, Optional, Dict, Any -from openai import OpenAI from ...core.config import get_settings from ...db.models import Bot @@ -64,13 +64,6 @@ class ConversationalAgent: self.model = model self.bot_id = bot_id - # Create OpenAI-compatible client for MiniMax - # Use the extended thinking endpoint - self.client = OpenAI( - api_key=api_key, - base_url="https://api.minimax.io/v1" - ) - # Extended thinking endpoint self.thinking_endpoint = "https://api.minimax.io/v1/text/chatcompletion_v2" @@ -98,8 +91,15 @@ class ConversationalAgent: messages.append({"role": "user", "content": user_message}) # Make API call to extended thinking endpoint - response = self.client.post( + # Use requests library directly for this endpoint since it's not OpenAI-compatible + import requests + + resp = requests.post( self.thinking_endpoint, + headers={ + "Authorization": f"Bearer {self.api_key}", + "Content-Type": "application/json" + }, json={ "model": self.model, "messages": messages, @@ -112,7 +112,7 @@ class ConversationalAgent: } ) - result = response.json() + result = resp.json() # Extract thinking from reasoning_content thinking = None