-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support custom providers #530
Conversation
Notes from team meeting:
Future PRs:
|
Deploying chatcraft-org with Cloudflare Pages
|
@humphd I've completed this. Code could use some refactoring but I've implemented everything. I have a question about models though. I console logged all the models I got when I called queryModels on openAI and I got a list of 28 models. But in chatcraft production we already have displayed only 16 models. What is causing this difference? Are we filtering out the models somewhere, where and why? [update] Question answered during team meeting - we are filtering out the models for openai deliberately |
…to a trailing space in url or key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kliu57 This is a great improvement. Just left some comments/suggestions
…er row cancel icon
…eir respective provider classes
@Amnish04 made all the requested changes minus the ones you still need input from dave. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kliu57 Another thing I noticed is that when you click on Add Provider and a new form appears Closing the modal and returning does not make that go away. Maybe you should implement and call a |
This is me telling @kliu57 to do it as a table. Sorry we didn't have more clarity before you began, Katie. Is it possible for us to do UI changes in a follow-up so that we can land the rest of the work in here? As far as I can tell, what you want is cosmetic. |
Yeah always happy to land and iterate. lgtm for now :) |
This is now fixed |
@Amnish04 @mingming-ma Please review Changes made:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
src/components/PasswordInput.tsx
Outdated
|
||
const paddingRight = size === "sm" ? "2.5rem" : "4.5rem"; | ||
const paddingLeft = size === "sm" ? "0.4rem" : undefined; | ||
const inputSize = size === "sm" ? "sm" : "md"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this. We can use the size prop passed as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a follow up issue that we can use to discuss during next week's meeting.
src/components/PasswordInput.tsx
Outdated
type PasswordInputProps = ComponentPropsWithRef<typeof Input> & { | ||
size?: "sm" | "md"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InputProps already have size, we shouldn't override it.
type PasswordInputProps = ComponentPropsWithRef<typeof Input> & { | |
size?: "sm" | "md"; | |
type PasswordInputProps =InputProps & { |
Make sure to import InputProps from "@chakra-ui/react"
src/components/PasswordInput.tsx
Outdated
const paddingRight = size === "sm" ? "2.5rem" : "4.5rem"; | ||
const paddingLeft = size === "sm" ? "0.4rem" : undefined; | ||
const inputSize = size === "sm" ? "sm" : "md"; | ||
const buttonSize = size === "sm" ? "xs" : "sm"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rather add hideButtonSize
prop to your props interface
src/components/PasswordInput.tsx
Outdated
const paddingRight = size === "sm" ? "2.5rem" : "4.5rem"; | ||
const paddingLeft = size === "sm" ? "0.4rem" : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the user of this component can pass these props explicitly and you can pass to Input directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
We can discuss #553 after landing this.
Closes #503
Closes #440
Users are now able to add custom providers and the user settings modal now shows a table of providers.
Implemented functionalities:
Add Provider button:
Other buttons/fields:
Code changes (only summary of important points):
PreferencesModal.tsx
(core code is here)focusedProvider
state var tracks which provider row we are editing. This is what allows us to display the "Key is invalid" message on the correct corresponding row.selectedProvider
state var tracks which provider we have clicked the checkbox onnewCustomProvider
stat var stores the data user typed in the new provider rowSmallRevealablePasswordInput.tsx
created this so I don't mess with the styles of
RevealablePasswordInput.tsx
since we still use that in Instructions page and we may bring back Instructions page somedayuse-alert.ts
Had to make changes to
OpenAiProvider.ts
andOpenRouterProvider.ts
to take in a name param so that users will be able to have multiple Open AI or Open Router providers with different names
Had to add
defaultModel
member var toChatCraftProvider
classto store the defaultModel, since for the custom providers users will add themselves we have no way of hardcoding the defaultModel. So we will query the first model from list of models and store it in this
ChatCraftProvider
member var.Follow ups issues:
#524
#542
#548
#550
#551
#552
#553
How to test:
Currently I don't have any custom provider urls/keys to use for testing. If anyone has any please help me to test if those providers are open ai compatible.
You may add new providers using the providers we currently support: