Skip to content

Commit 4a31fda

Browse files
committed
feat(stage-ui/providers): added 302.AI
1 parent 7a0d7f3 commit 4a31fda

File tree

11 files changed

+507
-171
lines changed

11 files changed

+507
-171
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ npx bumpp --no-commit --no-tag
183183

184184
## Support of LLM API Providers (powered by [xsai](https://github.com/moeru-ai/xsai))
185185

186+
- [x] [302.AI (sponsored)](https://share.302.ai/514k2v)
186187
- [x] [OpenRouter](https://openrouter.ai/)
187188
- [x] [vLLM](https://github.com/vllm-project/vllm)
188189
- [x] [SGLang](https://github.com/sgl-project/sglang)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<script setup lang="ts">
2+
import type { RemovableRef } from '@vueuse/core'
3+
4+
import {
5+
Alert,
6+
ProviderAdvancedSettings,
7+
ProviderApiKeyInput,
8+
ProviderBaseUrlInput,
9+
ProviderBasicSettings,
10+
ProviderSettingsContainer,
11+
ProviderSettingsLayout,
12+
} from '@proj-airi/stage-ui/components'
13+
import { useProviderValidation } from '@proj-airi/stage-ui/composables/useProviderValidation'
14+
import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers'
15+
import { storeToRefs } from 'pinia'
16+
import { computed } from 'vue'
17+
18+
const providerId = '302-ai'
19+
const providersStore = useProvidersStore()
20+
const { providers } = storeToRefs(providersStore) as { providers: RemovableRef<Record<string, any>> }
21+
22+
// Define computed properties for credentials
23+
const apiKey = computed({
24+
get: () => providers.value[providerId]?.apiKey || '',
25+
set: (value) => {
26+
if (!providers.value[providerId])
27+
providers.value[providerId] = {}
28+
providers.value[providerId].apiKey = value
29+
},
30+
})
31+
32+
const baseUrl = computed({
33+
get: () => providers.value[providerId]?.baseUrl || '',
34+
set: (value) => {
35+
if (!providers.value[providerId])
36+
providers.value[providerId] = {}
37+
providers.value[providerId].baseUrl = value
38+
},
39+
})
40+
41+
// Use the composable to get validation logic and state
42+
const {
43+
t,
44+
router,
45+
providerMetadata,
46+
isValidating,
47+
isValid,
48+
validationMessage,
49+
handleResetSettings,
50+
} = useProviderValidation(providerId)
51+
</script>
52+
53+
<template>
54+
<ProviderSettingsLayout
55+
:provider-name="providerMetadata?.localizedName"
56+
:provider-icon-color="providerMetadata?.iconColor"
57+
:on-back="() => router.back()"
58+
>
59+
<ProviderSettingsContainer>
60+
<ProviderBasicSettings
61+
:title="t('settings.pages.providers.common.section.basic.title')"
62+
:description="t('settings.pages.providers.common.section.basic.description')"
63+
:on-reset="handleResetSettings"
64+
>
65+
<ProviderApiKeyInput
66+
v-model="apiKey"
67+
:provider-name="providerMetadata?.localizedName"
68+
placeholder="sk-..."
69+
/>
70+
</ProviderBasicSettings>
71+
72+
<ProviderAdvancedSettings :title="t('settings.pages.providers.common.section.advanced.title')">
73+
<ProviderBaseUrlInput
74+
v-model="baseUrl"
75+
placeholder="https://api.302.ai/v1/"
76+
/>
77+
</ProviderAdvancedSettings>
78+
79+
<!-- Validation Status -->
80+
<Alert v-if="!isValid && isValidating === 0 && validationMessage" type="error">
81+
<template #title>
82+
{{ t('settings.dialogs.onboarding.validationFailed') }}
83+
</template>
84+
<template v-if="validationMessage" #content>
85+
<div class="whitespace-pre-wrap break-all">
86+
{{ validationMessage }}
87+
</div>
88+
</template>
89+
</Alert>
90+
<Alert v-if="isValid && isValidating === 0" type="success">
91+
<template #title>
92+
{{ t('settings.dialogs.onboarding.validationSuccess') }}
93+
</template>
94+
</Alert>
95+
</ProviderSettingsContainer>
96+
</ProviderSettingsLayout>
97+
</template>
98+
99+
<route lang="yaml">
100+
meta:
101+
layout: settings
102+
stageTransition:
103+
name: slide
104+
</route>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<script setup lang="ts">
2+
import type { RemovableRef } from '@vueuse/core'
3+
4+
import {
5+
Alert,
6+
ProviderAdvancedSettings,
7+
ProviderApiKeyInput,
8+
ProviderBaseUrlInput,
9+
ProviderBasicSettings,
10+
ProviderSettingsContainer,
11+
ProviderSettingsLayout,
12+
} from '@proj-airi/stage-ui/components'
13+
import { useProviderValidation } from '@proj-airi/stage-ui/composables/useProviderValidation'
14+
import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers'
15+
import { storeToRefs } from 'pinia'
16+
import { computed } from 'vue'
17+
18+
const providerId = '302-ai'
19+
const providersStore = useProvidersStore()
20+
const { providers } = storeToRefs(providersStore) as { providers: RemovableRef<Record<string, any>> }
21+
22+
// Define computed properties for credentials
23+
const apiKey = computed({
24+
get: () => providers.value[providerId]?.apiKey || '',
25+
set: (value) => {
26+
if (!providers.value[providerId])
27+
providers.value[providerId] = {}
28+
providers.value[providerId].apiKey = value
29+
},
30+
})
31+
32+
const baseUrl = computed({
33+
get: () => providers.value[providerId]?.baseUrl || '',
34+
set: (value) => {
35+
if (!providers.value[providerId])
36+
providers.value[providerId] = {}
37+
providers.value[providerId].baseUrl = value
38+
},
39+
})
40+
41+
// Use the composable to get validation logic and state
42+
const {
43+
t,
44+
router,
45+
providerMetadata,
46+
isValidating,
47+
isValid,
48+
validationMessage,
49+
handleResetSettings,
50+
} = useProviderValidation(providerId)
51+
</script>
52+
53+
<template>
54+
<ProviderSettingsLayout
55+
:provider-name="providerMetadata?.localizedName"
56+
:provider-icon-color="providerMetadata?.iconColor"
57+
:on-back="() => router.back()"
58+
>
59+
<ProviderSettingsContainer>
60+
<ProviderBasicSettings
61+
:title="t('settings.pages.providers.common.section.basic.title')"
62+
:description="t('settings.pages.providers.common.section.basic.description')"
63+
:on-reset="handleResetSettings"
64+
>
65+
<ProviderApiKeyInput
66+
v-model="apiKey"
67+
:provider-name="providerMetadata?.localizedName"
68+
placeholder="sk-..."
69+
/>
70+
</ProviderBasicSettings>
71+
72+
<ProviderAdvancedSettings :title="t('settings.pages.providers.common.section.advanced.title')">
73+
<ProviderBaseUrlInput
74+
v-model="baseUrl"
75+
placeholder="https://api.302.ai/v1/"
76+
/>
77+
</ProviderAdvancedSettings>
78+
79+
<!-- Validation Status -->
80+
<Alert v-if="!isValid && isValidating === 0 && validationMessage" type="error">
81+
<template #title>
82+
{{ t('settings.dialogs.onboarding.validationFailed') }}
83+
</template>
84+
<template v-if="validationMessage" #content>
85+
<div class="whitespace-pre-wrap break-all">
86+
{{ validationMessage }}
87+
</div>
88+
</template>
89+
</Alert>
90+
<Alert v-if="isValid && isValidating === 0" type="success">
91+
<template #title>
92+
{{ t('settings.dialogs.onboarding.validationSuccess') }}
93+
</template>
94+
</Alert>
95+
</ProviderSettingsContainer>
96+
</ProviderSettingsLayout>
97+
</template>
98+
99+
<route lang="yaml">
100+
meta:
101+
layout: settings
102+
stageTransition:
103+
name: slide
104+
</route>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<script setup lang="ts">
2+
import type { RemovableRef } from '@vueuse/core'
3+
4+
import {
5+
Alert,
6+
ProviderAdvancedSettings,
7+
ProviderApiKeyInput,
8+
ProviderBaseUrlInput,
9+
ProviderBasicSettings,
10+
ProviderSettingsContainer,
11+
ProviderSettingsLayout,
12+
} from '@proj-airi/stage-ui/components'
13+
import { useProviderValidation } from '@proj-airi/stage-ui/composables/useProviderValidation'
14+
import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers'
15+
import { storeToRefs } from 'pinia'
16+
import { computed } from 'vue'
17+
18+
const providerId = '302-ai'
19+
const providersStore = useProvidersStore()
20+
const { providers } = storeToRefs(providersStore) as { providers: RemovableRef<Record<string, any>> }
21+
22+
// Define computed properties for credentials
23+
const apiKey = computed({
24+
get: () => providers.value[providerId]?.apiKey || '',
25+
set: (value) => {
26+
if (!providers.value[providerId])
27+
providers.value[providerId] = {}
28+
providers.value[providerId].apiKey = value
29+
},
30+
})
31+
32+
const baseUrl = computed({
33+
get: () => providers.value[providerId]?.baseUrl || '',
34+
set: (value) => {
35+
if (!providers.value[providerId])
36+
providers.value[providerId] = {}
37+
providers.value[providerId].baseUrl = value
38+
},
39+
})
40+
41+
// Use the composable to get validation logic and state
42+
const {
43+
t,
44+
router,
45+
providerMetadata,
46+
isValidating,
47+
isValid,
48+
validationMessage,
49+
handleResetSettings,
50+
} = useProviderValidation(providerId)
51+
</script>
52+
53+
<template>
54+
<ProviderSettingsLayout
55+
:provider-name="providerMetadata?.localizedName"
56+
:provider-icon-color="providerMetadata?.iconColor"
57+
:on-back="() => router.back()"
58+
>
59+
<ProviderSettingsContainer>
60+
<ProviderBasicSettings
61+
:title="t('settings.pages.providers.common.section.basic.title')"
62+
:description="t('settings.pages.providers.common.section.basic.description')"
63+
:on-reset="handleResetSettings"
64+
>
65+
<ProviderApiKeyInput
66+
v-model="apiKey"
67+
:provider-name="providerMetadata?.localizedName"
68+
placeholder="sk-..."
69+
/>
70+
</ProviderBasicSettings>
71+
72+
<ProviderAdvancedSettings :title="t('settings.pages.providers.common.section.advanced.title')">
73+
<ProviderBaseUrlInput
74+
v-model="baseUrl"
75+
placeholder="https://api.302.ai/v1/"
76+
/>
77+
</ProviderAdvancedSettings>
78+
79+
<!-- Validation Status -->
80+
<Alert v-if="!isValid && isValidating === 0 && validationMessage" type="error">
81+
<template #title>
82+
{{ t('settings.dialogs.onboarding.validationFailed') }}
83+
</template>
84+
<template v-if="validationMessage" #content>
85+
<div class="whitespace-pre-wrap break-all">
86+
{{ validationMessage }}
87+
</div>
88+
</template>
89+
</Alert>
90+
<Alert v-if="isValid && isValidating === 0" type="success">
91+
<template #title>
92+
{{ t('settings.dialogs.onboarding.validationSuccess') }}
93+
</template>
94+
</Alert>
95+
</ProviderSettingsContainer>
96+
</ProviderSettingsLayout>
97+
</template>
98+
99+
<route lang="yaml">
100+
meta:
101+
layout: settings
102+
stageTransition:
103+
name: slide
104+
</route>

docs/README.fr.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ npx bumpp --no-commit --no-tag
181181

182182
## Support des fournisseurs d'API LLM suivants (propulsé par [xsai](https://github.com/moeru-ai/xsai))
183183

184+
- [x] [302.AI](https://share.302.ai/514k2v)
184185
- [x] [OpenRouter](https://openrouter.ai/)
185186
- [x] [vLLM](https://github.com/vllm-project/vllm)
186187
- [x] [SGLang](https://github.com/sgl-project/sglang)

docs/README.ja-JP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pnpm dev:docs
158158

159159
## サポートされているLLM APIプロバイダー([xsai](https://github.com/moeru-ai/xsai)によって提供)
160160

161+
- [x] [302.AI](https://share.302.ai/514k2v)
161162
- [x] [OpenRouter](https://openrouter.ai/)
162163
- [x] [vLLM](https://github.com/vllm-project/vllm)
163164
- [x] [SGLang](https://github.com/sgl-project/sglang)

docs/README.ru-RU.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ npx bumpp --no-commit --no-tag
182182

183183
## Поддержка провайдеров LLM API (на базе [xsai](https://github.com/moeru-ai/xsai))
184184

185+
- [x] [302.AI](https://share.302.ai/514k2v)
185186
- [x] [OpenRouter](https://openrouter.ai/)
186187
- [x] [vLLM](https://github.com/vllm-project/vllm)
187188
- [x] [SGLang](https://github.com/sgl-project/sglang)

docs/README.vi.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ npx bumpp --no-commit --no-tag
180180

181181
## Các LLM API hỗ trợ (cung cấp bởi [xsai](https://github.com/moeru-ai/xsai))
182182

183+
- [x] [302.AI](https://share.302.ai/514k2v)
183184
- [x] [OpenRouter](https://openrouter.ai/)
184185
- [x] [vLLM](https://github.com/vllm-project/vllm)
185186
- [x] [SGLang](https://github.com/sgl-project/sglang)

docs/README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pnpm -F @proj-airi/docs dev
150150

151151
## 原生支持的 LLM API 服务来源列表(由 [xsai](https://github.com/moeru-ai/xsai) 驱动)
152152

153+
- [x] [302.AI](https://share.302.ai/514k2v)
153154
- [x] [OpenRouter](https://openrouter.ai/)
154155
- [x] [vLLM](https://github.com/vllm-project/vllm)
155156
- [x] [SGLang](https://github.com/sgl-project/sglang)

0 commit comments

Comments
 (0)