INNER CODE UNIT · TypeScript

index

agentscope-ai/agentscope-runtime · web/starter_webui/src/components/Chat/sessionApi/index.ts:25

    const index = this.sessionList.findIndex((item) => item.id === session.id);
    if (index > -1) {
      this.sessionList[index] = {
        ...this.sessionList[index],
        ...session,
      };
      localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
    }

    return [...this.sessionList];
  }

  async createSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
    session.id = Date.now().toString();
    this.sessionList.unshift(session as IAgentScopeRuntimeWebUISession);
    localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
    return [...this.sessionList];
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…