-
Notifications
You must be signed in to change notification settings - Fork 26
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
Added validation for OpenRouter API key #306
Conversation
I like it, thank you for improving this! |
@kliu57 I invited you as a collaborator, I hope you accept. For all new work, please push as a branch to chatcraft.org repo, then we can benefit from cloudflare branch deployments. |
Sure, I can do that for future PRs. Do you need me to recreate my current PRs? (this one or PR#308) |
@humphd ok to accept this one as is? |
…h validates both OpenAi and OpenRouter
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.
A few small things, this is looking good.
@humphd Made the three code fixes as suggested. Also, I noticed in |
@kliu57 This needs to be rebased to pick up the change we just landed in I think the call to |
Great work @kliu57. I hope you'll keep working ChatCraft in the future. |
Closes #230
Added validation for OpenRouter API key
Current code (before PR):
PR Code changes:
src/lib/ai.ts
, created new functionvalidateApiKey()
which validates both OpenAI and OpenRouter keys, by callingvalidateOpenAiApiKey()
orvalidateOpenRouterApiKey()
src/lib/ai.ts
, create new functionvalidateOpenRouterApiKey()
, which uses response from https://openrouter.ai/docs#limits to check if OpenRouter API key is validsrc/components/Message/AppMessage/Instructions.tsx
, replaced call ofvalidateOpenAiApiKey()
withvalidateApiKey()
src/components/PreferencesModal.tsx
, replaced call ofvalidateOpenAiApiKey()
withvalidateApiKey()
Testing:
Invalid OpenRouter API key:
Valid OpenRouter API key:
Regression Testing:
Invalid OpenAI API key:
Valid OpenAI API key: