-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(copilot): enterprise configuration #3184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
59cb2f0
Copilot enterprise models
Sg312 f959d78
Fix azure anthropic
Sg312 81bf1e1
Fix
Sg312 8dbec38
Consolidation
Sg312 5793681
Cleanup
Sg312 b5b0c39
Clean up code
Sg312 73f2e73
Fix lint
Sg312 a88d5f6
cleanup
Sg312 78751c7
Fix greptile
Sg312 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Copilot enterprise models
- Loading branch information
commit 59cb2f0d2db9238e724e0389e88192f471a2c83e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { createLogger } from '@sim/logger' | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { SIM_AGENT_API_URL } from '@/lib/copilot/constants' | ||
| import { authenticateCopilotRequestSessionOnly } from '@/lib/copilot/request-helpers' | ||
| import { env } from '@/lib/core/config/env' | ||
| import type { AvailableModel } from '@/lib/copilot/types' | ||
|
|
||
| const logger = createLogger('CopilotModelsAPI') | ||
|
|
||
| export async function GET(_req: NextRequest) { | ||
| const { userId, isAuthenticated } = await authenticateCopilotRequestSessionOnly() | ||
| if (!isAuthenticated || !userId) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) | ||
| } | ||
|
|
||
| const headers: Record<string, string> = { | ||
| 'Content-Type': 'application/json', | ||
| } | ||
| if (env.COPILOT_API_KEY) { | ||
| headers['x-api-key'] = env.COPILOT_API_KEY | ||
| } | ||
|
|
||
| try { | ||
| const response = await fetch(`${SIM_AGENT_API_URL}/api/get-available-models`, { | ||
| method: 'GET', | ||
| headers, | ||
| cache: 'no-store', | ||
| }) | ||
|
|
||
| const payload = await response.json().catch(() => ({})) | ||
| if (!response.ok) { | ||
| logger.warn('Failed to fetch available models from copilot backend', { | ||
| status: response.status, | ||
| }) | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: payload?.error || 'Failed to fetch available models', | ||
| models: [], | ||
| }, | ||
| { status: response.status } | ||
| ) | ||
| } | ||
|
|
||
| const rawModels = Array.isArray(payload?.models) ? payload.models : [] | ||
| const models: AvailableModel[] = rawModels | ||
| .filter((item: any) => item && typeof item.id === 'string') | ||
| .map((item: any) => ({ | ||
| id: item.id, | ||
| friendlyName: item.friendlyName || item.displayName || item.id, | ||
| provider: item.provider || 'unknown', | ||
| })) | ||
|
|
||
| return NextResponse.json({ success: true, models }) | ||
| } catch (error) { | ||
| logger.error('Error fetching available models', { | ||
| error: error instanceof Error ? error.message : String(error), | ||
| }) | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| error: 'Failed to fetch available models', | ||
| models: [], | ||
| }, | ||
| { status: 500 } | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.