Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

587 B
Raw Blame
// Fixture: fixed tuples stay on Promise.all, including inside a loop.
import { agentModel, topicModel } from './model';

export const loadPair = async (agentId: string, topicId: string) => {
  const [agent, topic] = await Promise.all([
    agentModel.findById(agentId),
    topicModel.findById(topicId),
  ]);
  return { agent, topic };
};

export const loadEach = async (ids: string[]) => {
  const out = [];
  for (const id of ids) {
    const [meta, stats] = await Promise.all([agentModel.findMeta(id), agentModel.findStats(id)]);
    out.push({ meta, stats });
  }
  return out;
};