Skip to content

Commit dfb391f

Browse files
committed
feat: support openrouter
1 parent 11a5da7 commit dfb391f

File tree

6 files changed

+46
-3
lines changed

6 files changed

+46
-3
lines changed

app/composables/useLlm.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { createFetch } from '@vueuse/core'
33

44
const _GOOGLE_AI_MODELS = GOOGLE_AI_MODELS.map(({ model }) => model)
55
const _DEEPSEEK_MODELS = DEEPSEEK_MODELS.map(({ model }) => model)
6+
const _OPENROUTER_MODELS = OPENROUTER_MODELS.map(({ model }) => model)
67

78
const _MODELS = [
89
..._GOOGLE_AI_MODELS,
910
..._DEEPSEEK_MODELS,
11+
..._OPENROUTER_MODELS,
1012
]
1113

1214
export function useLlm(model: MaybeRef<string>) {
@@ -15,7 +17,7 @@ export function useLlm(model: MaybeRef<string>) {
1517
const _model = computed(() => unref(model))
1618

1719
const store = useSettingsStore()
18-
const { googleAPIKey, deepseekApiKey } = storeToRefs(store)
20+
const { googleAPIKey, deepseekApiKey, openrouterApiKey } = storeToRefs(store)
1921

2022
const openai = computed(() => {
2123
if (!_MODELS.includes(_model.value))
@@ -31,6 +33,11 @@ export function useLlm(model: MaybeRef<string>) {
3133
_baseURL = 'https://api.deepseek.com/v1'
3234
}
3335

36+
if (_OPENROUTER_MODELS.includes(_model.value) && openrouterApiKey.value && openrouterApiKey.value.startsWith('sk-')) {
37+
_apiKey = openrouterApiKey.value
38+
_baseURL = 'https://openrouter.ai/api/v1'
39+
}
40+
3441
if (!_apiKey)
3542
return
3643

app/pages/[id].vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const llm = computed(() => {
2929
const _MODELS = [
3030
...GOOGLE_AI_MODELS,
3131
...DEEPSEEK_MODELS,
32+
...OPENROUTER_MODELS,
3233
]
3334
3435
return _MODELS.find(m => m.model === model.value)

app/pages/[id]/queries/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ async function onGenerateSqlByLlm() {
296296
</StepperTitle>
297297

298298
<StepperDescription class="text-xs text-zinc-600/50">
299-
{{ step.description }}
299+
<div class="truncate w-52">
300+
{{ step.description }}
301+
</div>
300302
</StepperDescription>
301303
</div>
302304
</StepperItem>

app/pages/[id]/settings/index.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Input } from '~/components/ui/input'
33
44
const store = useSettingsStore()
5-
const { language, googleAPIKey, deepseekApiKey, model } = storeToRefs(store)
5+
const { language, googleAPIKey, deepseekApiKey, openrouterApiKey, model } = storeToRefs(store)
66
</script>
77

88
<template>
@@ -68,6 +68,15 @@ const { language, googleAPIKey, deepseekApiKey, model } = storeToRefs(store)
6868
{{ m.alias }}
6969
</SelectItem>
7070
</SelectGroup>
71+
72+
<SelectGroup v-if="openrouterApiKey">
73+
<SelectLabel class="cursor-default">
74+
OpenRouter
75+
</SelectLabel>
76+
<SelectItem v-for="m in OPENROUTER_MODELS" :key="m.model" :value="m.model">
77+
{{ m.alias }}
78+
</SelectItem>
79+
</SelectGroup>
7180
</SelectContent>
7281
</Select>
7382
</div>
@@ -113,6 +122,24 @@ const { language, googleAPIKey, deepseekApiKey, model } = storeToRefs(store)
113122
<Input v-model="deepseekApiKey" type="password" class="h-8" placeholder="sk-..." />
114123
</div>
115124

125+
<div>
126+
<div class="text-sm font-semibold mb-2">
127+
OpenRouter
128+
</div>
129+
130+
<div class="text-xs text-zinc-600/50 mb-4 cursor-default">
131+
<div>To use tablite assistant with OpenRouter you need to add an API key. Follow these steps:</div>
132+
<div>
133+
Create one by visiting <Button variant="link" class="text-xs p-0 h-4 text-zinc-600 font-normal">
134+
https://openrouter.ai/settings/keys
135+
</Button>
136+
</div>
137+
<div>Paste your API key below and hit enter to use the assistant</div>
138+
</div>
139+
140+
<Input v-model="openrouterApiKey" type="password" class="text-sm h-8" placeholder="sk-..." />
141+
</div>
142+
116143
<div>
117144
<div class="text-sm font-semibold mb-2">
118145
OpenAI

app/utils/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ export const DEEPSEEK_MODELS = [
119119
{ model: 'deepseek-reasoner', alias: 'DeepSeek R1', icon: '/images/deepseek.svg' },
120120
]
121121

122+
export const OPENROUTER_MODELS = [
123+
{ model: 'google/gemini-2.0-flash-lite-preview-02-05:free', alias: 'Gemini Flash Lite 2.0', icon: '/images/openrouter.svg' },
124+
{ model: 'google/gemini-2.0-pro-exp-02-05:free', alias: 'Gemini Pro 2.0 Experimental', icon: '/images/openrouter.svg' },
125+
]
126+
122127
export const SQL_KEYWORDS = [
123128
'ACCESSIBLE',
124129
'ADD',

public/images/openrouter.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)