Skip to content

Commit

Permalink
feat: fix OPENROUTER_API_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 24, 2024
1 parent d9cd798 commit 629d080
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"mixtral",
"nemo",
"Reranking",
"mistralai"
"mistralai",
"OPENROUTER"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
Expand Down
3 changes: 2 additions & 1 deletion .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
OPENAI_API_KEY=""
SUPABASE_URL=""
SUPABASE_KEY=""
VOYAGEAI_API_KEY=""
VOYAGEAI_API_KEY=""
OPENROUTER_API_KEY=""
2 changes: 2 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
VOYAGEAI_API_KEY: ${{ secrets.VOYAGEAI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
UBIQUITY_OS_APP_NAME: ${{ secrets.UBIQUITY_OS_APP_NAME }}

steps:
Expand All @@ -49,4 +50,5 @@ jobs:
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
VOYAGEAI_API_KEY: ${{ secrets.VOYAGEAI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
UBIQUITY_OS_APP_NAME: ${{ secrets.UBIQUITY_OS_APP_NAME }}
8 changes: 8 additions & 0 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
OPENAI_API_KEY
SUPABASE_URL
SUPABASE_KEY
VOYAGEAI_API_KEY
OPENROUTER_API_KEY
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
VOYAGEAI_API_KEY: ${{ secrets.VOYAGEAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}

- name: Write Deployment URL to Summary
run: |
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ plugins:
`.dev.vars` (for local testing):

If you plan on using the OpenRouter API, set both the `OPENROUTER_API_KEY` and the `openAiBaseUrl` in the `ubiquibot-config.yml` file. Otherwise, use the `OPENAI_API_KEY`.

```sh
# OpenAI API key
OPENAI_API_KEY=your-api-key
UBIQUITY_OS_APP_NAME="UbiquityOS"
OPENROUTER_API_KEY=your-api-key
```

## Testing
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function plugin(inputs: PluginInputs, env: Env) {
apiKey: env.VOYAGEAI_API_KEY,
});
const openAiObject = {
apiKey: env.OPENAI_API_KEY,
apiKey: (inputs.settings.openAiBaseUrl && env.OPENROUTER_API_KEY) || env.OPENAI_API_KEY,
...(inputs.settings.openAiBaseUrl && { baseURL: inputs.settings.openAiBaseUrl }),
};
const openaiClient = new OpenAI(openAiObject);
Expand Down
1 change: 1 addition & 0 deletions src/types/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const envSchema = T.Object({
VOYAGEAI_API_KEY: T.String(),
SUPABASE_URL: T.String(),
SUPABASE_KEY: T.String(),
OPENROUTER_API_KEY: T.String(),
});

export const envValidator = new StandardValidator(envSchema);
Expand Down

0 comments on commit 629d080

Please sign in to comment.