|
513 | 513 | local M = {} |
514 | 514 |
|
515 | 515 | M.copilot = { |
516 | | - route_model = function(headers, hints) |
517 | | - hints = hints or { 'auto' } |
518 | | - local token = headers['Authorization'] and headers['Authorization']:gsub('^Bearer%s+', '') |
519 | | - if not token then |
520 | | - return nil, 'No authorization token available' |
521 | | - end |
522 | | - |
523 | | - local url = 'https://api.individual.githubcopilot.com/models/session' |
524 | | - local response, err = curl.post(url, { |
525 | | - headers = { |
526 | | - ['Authorization'] = 'Bearer ' .. token, |
527 | | - ['editor-version'] = 'vscode/1.109.0-insider', |
528 | | - ['user-agent'] = 'GitHubCopilotChat/0.38.0', |
529 | | - ['x-github-api-version'] = '2025-10-01', |
530 | | - }, |
531 | | - body = { auto_mode = { model_hints = hints } }, |
532 | | - json_response = true, |
533 | | - json_request = true, |
534 | | - }) |
535 | | - |
536 | | - if err then |
537 | | - return nil, 'Auto selection request failed: ' .. tostring(err) |
538 | | - end |
539 | | - |
540 | | - if not response or response.status ~= 200 then |
541 | | - return nil, 'Auto selection returned status: ' .. tostring(response and response.status or 'unknown') |
542 | | - end |
543 | | - |
544 | | - if not response.body or not response.body.selected_model then |
545 | | - return nil, 'No model selected in response' |
546 | | - end |
547 | | - |
548 | | - return response.body.selected_model, nil |
549 | | - end, |
550 | 516 | get_headers = function() |
551 | 517 | local response, err = curl.get('https://api.github.com/copilot_internal/v2/token', { |
552 | 518 | json_response = true, |
@@ -675,6 +641,41 @@ M.copilot = { |
675 | 641 | return models |
676 | 642 | end, |
677 | 643 |
|
| 644 | + route_model = function(headers, hints) |
| 645 | + hints = hints or { 'auto' } |
| 646 | + local token = headers['Authorization'] and headers['Authorization']:gsub('^Bearer%s+', '') |
| 647 | + if not token then |
| 648 | + return nil, 'No authorization token available' |
| 649 | + end |
| 650 | + |
| 651 | + local url = 'https://api.individual.githubcopilot.com/models/session' |
| 652 | + local response, err = curl.post(url, { |
| 653 | + headers = { |
| 654 | + ['Authorization'] = 'Bearer ' .. token, |
| 655 | + ['editor-version'] = 'vscode/1.109.0-insider', |
| 656 | + ['user-agent'] = 'GitHubCopilotChat/0.38.0', |
| 657 | + ['x-github-api-version'] = '2025-10-01', |
| 658 | + }, |
| 659 | + body = { auto_mode = { model_hints = hints } }, |
| 660 | + json_response = true, |
| 661 | + json_request = true, |
| 662 | + }) |
| 663 | + |
| 664 | + if err then |
| 665 | + return nil, 'Auto selection request failed: ' .. tostring(err) |
| 666 | + end |
| 667 | + |
| 668 | + if not response or response.status ~= 200 then |
| 669 | + return nil, 'Auto selection returned status: ' .. tostring(response and response.status or 'unknown') |
| 670 | + end |
| 671 | + |
| 672 | + if not response.body or not response.body.selected_model then |
| 673 | + return nil, 'No model selected in response' |
| 674 | + end |
| 675 | + |
| 676 | + return response.body.selected_model, nil |
| 677 | + end, |
| 678 | + |
678 | 679 | prepare_input = function(inputs, opts) |
679 | 680 | if opts.model.use_responses then |
680 | 681 | return prepare_responses_input(inputs, opts) |
|
0 commit comments