free mode wip
This commit is contained in:
parent
8887ed349d
commit
bbc2739832
4 changed files with 62 additions and 16 deletions
|
|
@ -84,7 +84,7 @@ Clone of [T3 Chat](https://t3.chat/)
|
|||
|
||||
### Final push
|
||||
|
||||
- [ ] Private mode for greeting
|
||||
- [x] Private mode for greeting
|
||||
- [ ] Free mode
|
||||
- [ ] make things prettier
|
||||
- [ ] mobile adjustments
|
||||
|
|
|
|||
|
|
@ -114,3 +114,41 @@ export const set = mutation({
|
|||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const enable_initial = mutation({
|
||||
args: {
|
||||
session_token: v.string(),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const session = await ctx.runQuery(internal.betterAuth.getSession, {
|
||||
sessionToken: args.session_token,
|
||||
});
|
||||
|
||||
if (!session) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
// Check if any models are enabled
|
||||
const enabledModels = await ctx.db
|
||||
.query('user_enabled_models')
|
||||
.withIndex('by_user', (q) => q.eq('user_id', session.userId))
|
||||
.collect();
|
||||
|
||||
if (enabledModels.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const initialModels = ['google/gemini-2.5-flash', 'deepseek/deepseek-chat-v3-0324:free'];
|
||||
|
||||
await Promise.all(
|
||||
initialModels.map((model) =>
|
||||
ctx.db.insert('user_enabled_models', {
|
||||
user_id: session.userId,
|
||||
provider: Provider.OpenRouter,
|
||||
model_id: model,
|
||||
pinned: null,
|
||||
})
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -81,11 +81,7 @@
|
|||
|
||||
let ruleName = $derived(rule.name);
|
||||
|
||||
let renaming = $state(false);
|
||||
|
||||
async function renameRule() {
|
||||
renaming = true;
|
||||
|
||||
await ResultAsync.fromPromise(
|
||||
client.mutation(api.user_rules.rename, {
|
||||
ruleId: rule._id,
|
||||
|
|
@ -94,8 +90,6 @@
|
|||
}),
|
||||
(e) => e
|
||||
);
|
||||
|
||||
renaming = false;
|
||||
}
|
||||
|
||||
const ruleNameExists = $derived.by(() => {
|
||||
|
|
@ -111,15 +105,23 @@
|
|||
<Card.Root>
|
||||
<Card.Header>
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2">
|
||||
<Input bind:value={ruleName} aria-invalid={ruleNameExists} />
|
||||
<Button
|
||||
variant="outline"
|
||||
onClickPromise={renameRule}
|
||||
disabled={ruleNameExists || ruleName === rule.name}
|
||||
>
|
||||
Rename
|
||||
</Button>
|
||||
<div class="flex flex-col gap-2">
|
||||
<Label for="rule-name">Name</Label>
|
||||
<div class="flex items-center gap-2">
|
||||
<Input
|
||||
bind:value={ruleName}
|
||||
aria-invalid={ruleNameExists}
|
||||
id="rule-name"
|
||||
name="rule-name"
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClickPromise={renameRule}
|
||||
disabled={ruleNameExists || ruleName === rule.name}
|
||||
>
|
||||
Rename
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="destructive" size="icon" onclick={deleteRule} disabled={deleting}>
|
||||
<TrashIcon class="size-4" />
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@
|
|||
let textarea = $state<HTMLTextAreaElement>();
|
||||
let abortController = $state<AbortController | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
client.mutation(api.user_enabled_models.enable_initial, {
|
||||
session_token: session.current?.session.token ?? '',
|
||||
});
|
||||
});
|
||||
|
||||
const currentConversationQuery = useCachedQuery(api.conversations.getById, () => ({
|
||||
conversation_id: page.params.id as Id<'conversations'>,
|
||||
session_token: session.current?.session.token ?? '',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue