-
Notifications
You must be signed in to change notification settings - Fork 937
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0955829
commit 7d1c74b
Showing
6 changed files
with
49 additions
and
22 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/chainlit/frontend/src/components/organisms/playground/helpers.tsx
This file contains 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,26 @@ | ||
import { Playground } from 'state/playground'; | ||
|
||
export default function getProvider(playground: Playground) { | ||
const isChat = !!playground?.prompt?.messages; | ||
|
||
const providers = playground?.providers | ||
? playground.providers.filter((p) => p.is_chat === isChat) | ||
: []; | ||
|
||
if (!providers?.length) { | ||
throw new Error('No LLM provider available'); | ||
} | ||
|
||
let provider = providers.find( | ||
(provider) => provider.id === playground.prompt?.provider | ||
); | ||
|
||
const providerFound = !!provider; | ||
|
||
provider = provider || providers[0]; | ||
|
||
return { | ||
provider, | ||
providerFound | ||
}; | ||
} |
This file contains 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 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 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 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 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