Compare commits

..

1 Commits

Author SHA1 Message Date
shokollm
4cc0d982d6 fix: update MiniMax API endpoint from api.minimax.chat to api.minimax.io
The MiniMax API endpoint should be api.minimax.io, not api.minimax.chat.

See: https://platform.minimax.io/docs/api-reference/text-anthropic-api

Fixes #43
2026-04-10 02:59:24 +00:00
6 changed files with 22 additions and 37 deletions

View File

@@ -32,7 +32,7 @@ MINIMAX_API_KEY=your-minimax-api-key
# MiniMax model to use
# Common options: MiniMax-Text-01, MiniMax-M2.1
MINIMAX_MODEL=MiniMax-M2.7
MINIMAX_MODEL=MiniMax-Text-01
# =============================================================================
# AVE CLOUD API

View File

@@ -58,7 +58,7 @@ def get_current_user(
@router.post(
"/register", response_model=Token, status_code=status.HTTP_201_CREATED
"/register", response_model=UserResponse, status_code=status.HTTP_201_CREATED
)
def register(user: UserCreate, db: Session = Depends(get_db)):
existing_user = db.query(User).filter(User.email == user.email).first()
@@ -75,10 +75,7 @@ def register(user: UserCreate, db: Session = Depends(get_db)):
db.add(db_user)
db.commit()
db.refresh(db_user)
# Generate and return access token so frontend can proceed immediately
access_token = create_access_token(data={"sub": db_user.id})
return Token(access_token=access_token, token_type="bearer")
return db_user
@router.post("/login", response_model=Token)

View File

@@ -1,6 +1,6 @@
from typing import List, Optional, Dict, Any
from crewai import Agent, Task, Crew, LLM
from .llm_connector import MiniMaxConnector
from crewai import Agent, Task, Crew
from .llm_connector import MiniMaxConnector, MiniMaxLLM
from ...core.config import get_settings
@@ -120,7 +120,7 @@ class StrategyExplainer:
def create_trading_designer_agent(
api_key: str, model: str = "MiniMax-M2.7"
api_key: str, model: str = "MiniMax-Text-01"
) -> Agent:
connector = MiniMaxConnector(api_key=api_key, model=model)
@@ -141,13 +141,13 @@ def create_trading_designer_agent(
role="Trading Strategy Designer",
goal="Convert natural language trading requests into precise strategy configurations",
backstory=system_prompt,
llm=LLM(model=model, api_key=api_key, api_base="https://api.minimax.io/v1"),
llm=MiniMaxLLM(api_key=api_key, model=model),
verbose=True,
)
def create_strategy_validator_agent(
api_key: str, model: str = "MiniMax-M2.7"
api_key: str, model: str = "MiniMax-Text-01"
) -> Agent:
return Agent(
role="Strategy Validator",
@@ -155,13 +155,13 @@ def create_strategy_validator_agent(
backstory="""You are a meticulous strategy validator with expertise in trading systems.
You check that all required parameters are present, values are reasonable, and the
strategy makes logical sense. You never approve strategies with missing or invalid data.""",
llm=LLM(model=model, api_key=api_key, api_base="https://api.minimax.io/v1"),
llm=MiniMaxLLM(api_key=api_key, model=model),
verbose=True,
)
def create_strategy_explainer_agent(
api_key: str, model: str = "MiniMax-M2.7"
api_key: str, model: str = "MiniMax-Text-01"
) -> Agent:
return Agent(
role="Strategy Explainer",
@@ -169,13 +169,13 @@ def create_strategy_explainer_agent(
backstory="""You are a patient trading strategy explainer. You translate complex
strategy configurations into easy-to-understand language. You help users understand
exactly what their strategies will do when triggered.""",
llm=LLM(model=model, api_key=api_key, api_base="https://api.minimax.io/v1"),
llm=MiniMaxLLM(api_key=api_key, model=model),
verbose=True,
)
class TradingCrew:
def __init__(self, api_key: str, model: str = "MiniMax-M2.7"):
def __init__(self, api_key: str, model: str = "MiniMax-Text-01"):
self.api_key = api_key
self.model = model
self.validator = StrategyValidator()

View File

@@ -1,9 +1,11 @@
from typing import Optional, List, Dict, Any
import httpx
from crewai import LLM
class MiniMaxLLM:
def __init__(self, api_key: str, model: str = "MiniMax-M2.7", **kwargs):
class MiniMaxLLM(LLM):
def __init__(self, api_key: str, model: str = "MiniMax-Text-01", **kwargs):
super().__init__(**kwargs)
self.api_key = api_key
self.model = model
self.base_url = "https://api.minimax.io/v1"
@@ -21,7 +23,7 @@ class MiniMaxLLM:
}
with httpx.Client(timeout=60.0) as client:
response = client.post(
f"{self.base_url}/text/chatcompletion_v2",
f"{self.base_url}/chat/completions",
headers=headers,
json=payload,
)
@@ -33,7 +35,7 @@ class MiniMaxLLM:
class MiniMaxConnector:
def __init__(self, api_key: str, model: str = "MiniMax-M2.7"):
def __init__(self, api_key: str, model: str = "MiniMax-Text-01"):
self.api_key = api_key
self.model = model

View File

@@ -104,12 +104,11 @@ export const api = {
}
},
async chat(id: string, message: string, signal?: AbortSignal): Promise<BotChatResponse> {
async chat(id: string, message: string): Promise<BotChatResponse> {
const response = await fetch(`${API_URL}/bots/${id}/chat`, {
method: 'POST',
headers: getAuthHeaders(),
body: JSON.stringify({ message } as BotChatRequest),
signal
body: JSON.stringify({ message } as BotChatRequest)
});
return handleResponse<BotChatResponse>(response);
},

View File

@@ -44,17 +44,8 @@
isSending = true;
// Add user's message immediately so it shows even before API response
addMessage({ role: 'user', content: message });
try {
// Add timeout to prevent hanging requests
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 30000);
const response = await api.bots.chat(botId, message, controller.signal);
clearTimeout(timeoutId);
const response = await api.bots.chat(botId, message);
addMessage({ role: 'assistant', content: response.response });
if (response.strategy_config) {
@@ -62,11 +53,7 @@
setCurrentBot(bot);
}
} catch (e) {
if (e instanceof Error && e.name === 'AbortError') {
addMessage({ role: 'assistant', content: 'Request timed out. Please try again.' });
} else {
addMessage({ role: 'assistant', content: 'Sorry, I encountered an error. Please try again.' });
}
} finally {
isSending = false;
}