feat: add better provider support, icons, regen, and a lot more
This commit is contained in:
@@ -1,14 +1,34 @@
|
||||
import type schema from "#triplit/schema";
|
||||
import type { Entity } from "@triplit/client";
|
||||
|
||||
export const useAgents = async () => {
|
||||
const triplit = useTriplitClient();
|
||||
|
||||
const { results: agents } = await useQuery('agents', triplit, triplit.query('agents').Include('topics'));
|
||||
const { results: agents, unsubscribe } = await useQuery('agents', triplit, triplit.query('agents').Include('topics'));
|
||||
|
||||
const getAgent = (id: string) => {
|
||||
return agents.value?.find((a) => a.id === id);
|
||||
const createAgent = async (): Promise<Readonly<Entity<typeof schema, 'agents'>> | null> => {
|
||||
const { user } = useAuth();
|
||||
if (!user.value) {
|
||||
console.error('No user');
|
||||
return null;
|
||||
}
|
||||
|
||||
return triplit.insert('agents', {
|
||||
name: 'New Agent',
|
||||
userId: user.value.id,
|
||||
systemPrompt: 'You are a helpful assistant.',
|
||||
defaultModelId: null,
|
||||
imageUrl: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
agents,
|
||||
getAgent,
|
||||
unsubscribe,
|
||||
getAgent: (id: string) => {
|
||||
return agents.value?.find((a: any) => a.id === id);
|
||||
},
|
||||
createAgent,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user