AI/MiMoV25.psm1
|
# MiMo-v2.5 Integration Module for MiMo CLI # Optimized for mimo-v2.5 model function Invoke-MiMoV25Completion { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$Prompt, [int]$MaxTokens = 2000, [double]$Temperature = 0.3, [string]$ApiKey = $env:MIMO_API_KEY, [string]$BaseUrl = "https://api.xiaomimimo.com/v1" ) if (-not $ApiKey) { Write-Error "MiMo API key not found. Set MIMO_API_KEY environment variable." return $null } $url = "$BaseUrl/chat/completions" $headers = @{ "api-key" = $ApiKey "Content-Type" = "application/json" } $body = @{ model = "mimo-v2-pro" messages = @( @{ role = "system" content = "You are MiMo Code Agent, an expert AI assistant for software development. You help with code explanation, optimization, generation, and debugging. Always provide clear, concise, and practical responses." } @{ role = "user" content = $Prompt } ) max_tokens = $MaxTokens temperature = $Temperature top_p = 0.9 frequency_penalty = 0.1 presence_penalty = 0.1 } | ConvertTo-Json -Depth 10 try { $response = Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body return $response.choices[0].message.content } catch { Write-Error "Failed to call MiMo API: $_" return $null } } function Get-MiMoV25Models { [CmdletBinding()] param( [string]$ApiKey = $env:MIMO_API_KEY, [string]$BaseUrl = "https://api.xiaomimimo.com/v1" ) if (-not $ApiKey) { Write-Error "MiMo API key not found." return $null } $url = "$BaseUrl/models" $headers = @{ "api-key" = $ApiKey } try { $response = Invoke-RestMethod -Uri $url -Method Get -Headers $headers return $response.data | Select-Object id, created, owned_by } catch { Write-Error "Failed to fetch MiMo models: $_" return $null } } function Test-MiMoV25Connection { [CmdletBinding()] param( [string]$ApiKey = $env:MIMO_API_KEY, [string]$BaseUrl = "https://api.xiaomimimo.com/v1" ) Write-Host "Testing MiMo-v2.5 connection..." try { $result = Invoke-MiMoV25Completion -Prompt "Hello, respond with 'Connection successful'" -MaxTokens 50 if ($result) { Write-Host "MiMo-v2.5 connection successful" -ForegroundColor Green return $true } else { Write-Host "MiMo-v2.5 connection failed" -ForegroundColor Red return $false } } catch { Write-Host "MiMo-v2.5 connection error: $_" -ForegroundColor Red return $false } } # Export functions Export-ModuleMember -Function Invoke-MiMoV25Completion, Get-MiMoV25Models, Test-MiMoV25Connection |