Skip to content

Commit

Permalink
feat: ai generated page summaries and meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeaturner committed Oct 14, 2024
1 parent c0fa2a6 commit d7b7084
Show file tree
Hide file tree
Showing 23 changed files with 1,368 additions and 171 deletions.
117 changes: 92 additions & 25 deletions client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ import {
HarvestRequest,
Homework,
HomeworkSearchParams,
PageDetailsResponse,
PeerReview,
Project,
ProjectFile,
ProjectSearchParams,
TableOfContents,
User,
UserSearchParams,
} from "./types";
import { AddableProjectTeamMember, CIDDescriptor, ProjectFileAuthor, ProjectTag } from "./types/Project";
import {
AddableProjectTeamMember,
CIDDescriptor,
ProjectFileAuthor,
ProjectTag,
} from "./types/Project";
import { Collection } from "./types/Collection";
import {
AuthorSearchParams,
Expand Down Expand Up @@ -217,10 +224,11 @@ class API {
return res;
}

public cloudflareStreamUploadURL: string = `${import.meta.env.MODE === "development"
? import.meta.env.VITE_DEV_BASE_URL
: ""
}/api/v1/cloudflare/stream-url`;
public cloudflareStreamUploadURL: string = `${
import.meta.env.MODE === "development"
? import.meta.env.VITE_DEV_BASE_URL
: ""
}/api/v1/cloudflare/stream-url`;

// Authors
async getAuthors({
Expand Down Expand Up @@ -321,6 +329,51 @@ class API {
return res;
}

async getBookTOC(bookID: string) {
const res = await axios.get<
{
toc: TableOfContents;
} & ConductorBaseResponse
>(`/commons/book/${bookID}/toc`);
return res;
}

async getPageDetails(pageID: string) {
const res = await axios.get<PageDetailsResponse & ConductorBaseResponse>(
`/commons/pages/${pageID}`
);
return res;
}

async getPageAISummary(pageID: string) {
const res = await axios.get<
{
summary: string;
} & ConductorBaseResponse
>(`/commons/pages/${pageID}/ai-summary`);
return res;
}

async getPageAITags(pageID: string) {
const res = await axios.get<
{
tags: string[];
} & ConductorBaseResponse
>(`/commons/pages/${pageID}/ai-tags`);
return res;
}

async updatePageDetails(
pageID: string,
data: { summary: string; tags: string[] }
) {
const res = await axios.patch<ConductorBaseResponse>(
`/commons/pages/${pageID}`,
data
);
return res;
}

// Central Identity
async getCentralIdentityOrgs({
activePage,
Expand Down Expand Up @@ -371,16 +424,20 @@ class API {
}

async generateADAPTAccessCode() {
const res = await axios.get<{
access_code: string;
} & ConductorBaseResponse>("/central-identity/adapt-access-code");
const res = await axios.get<
{
access_code: string;
} & ConductorBaseResponse
>("/central-identity/adapt-access-code");
return res;
}

async getCentralIdentityApps(){
const res = await axios.get<{
applications: CentralIdentityApp[];
} & ConductorBaseResponse>("/central-identity/apps");
async getCentralIdentityApps() {
const res = await axios.get<
{
applications: CentralIdentityApp[];
} & ConductorBaseResponse
>("/central-identity/apps");
return res;
}

Expand Down Expand Up @@ -420,7 +477,11 @@ class API {
return res;
}

async getCentralIdentityVerificationRequests(queryParams: { page?: number; limit?: number, status?: 'open' | 'closed' }) {
async getCentralIdentityVerificationRequests(queryParams: {
page?: number;
limit?: number;
status?: "open" | "closed";
}) {
const res = await axios.get<
{
requests: CentralIdentityVerificationRequest[];
Expand Down Expand Up @@ -570,9 +631,9 @@ class API {
page: params.page?.toString() || "1",
limit: params.limit?.toString() || "20",
});
const res = await axios.get<{ users: AddableProjectTeamMember[] } & ConductorBaseResponse>(
`/project/${params.projectID}/team/addable?${queryParams}`
);
const res = await axios.get<
{ users: AddableProjectTeamMember[] } & ConductorBaseResponse
>(`/project/${params.projectID}/team/addable?${queryParams}`);
return res;
}
async getPublicProjects(params?: { page?: number; limit?: number }) {
Expand Down Expand Up @@ -771,7 +832,7 @@ class API {
{
resources: CollectionResource[];
total_items: number;
cursor?: number
cursor?: number;
} & ConductorBaseResponse
>(
`/commons/collection/${encodeURIComponent(
Expand Down Expand Up @@ -805,7 +866,7 @@ class API {
{
collections: Collection[];
total_items: number;
cursor?: number
cursor?: number;
} & ConductorBaseResponse
>(`/commons/collections`, {
params: {
Expand Down Expand Up @@ -848,11 +909,15 @@ class API {
}

async deleteCollection(id: string) {
return await axios.delete<ConductorBaseResponse>(`/commons/collection/${id}`);
return await axios.delete<ConductorBaseResponse>(
`/commons/collection/${id}`
);
}

async deleteCollectionResource(collID: string, resourceID: string) {
return await axios.delete<ConductorBaseResponse>(`/commons/collection/${collID}/resources/${resourceID}`);
return await axios.delete<ConductorBaseResponse>(
`/commons/collection/${collID}/resources/${resourceID}`
);
}

// USERS (Control Panel)
Expand All @@ -862,11 +927,13 @@ class API {
limit?: number;
sort?: string;
}) {
return await axios.get<{
results: User[];
total_items: number;
} & ConductorBaseResponse>("/users", {
params
return await axios.get<
{
results: User[];
total_items: number;
} & ConductorBaseResponse
>("/users", {
params,
});
}
}
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/ControlledInputs/CtlTextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { FieldValues, FieldPath, Controller } from "react-hook-form";
import { Form, FormTextAreaProps } from "semantic-ui-react";
import { ControlledInputProps } from "../../types";
import "../../styles/global.css";

interface CtlTextAreaProps extends FormTextAreaProps {
label?: string;
required?: boolean;
maxLength?: number;
showRemaining?: boolean;
fluid?: boolean;
bordered?: boolean;
}

/**
Expand All @@ -24,6 +27,8 @@ export default function CtlTextArea<
required = false,
maxLength,
showRemaining = false,
fluid = false,
bordered = false,
...rest
}: ControlledInputProps<TFieldValues, TName> & CtlTextAreaProps) {
const { className: restClassName } = rest;
Expand Down Expand Up @@ -57,7 +62,7 @@ export default function CtlTextArea<
onChange={onChange}
onBlur={onBlur}
error={error?.message}
className="!m-0"
className={`!m-0 ${fluid ? "fluid-textarea" : ""} ${bordered ? 'border border-slate-400 rounded-md padded-textarea': ''}`}
{...rest}
/>
{maxLength && showRemaining && typeof value === "string" && (
Expand Down
3 changes: 0 additions & 3 deletions client/src/components/TreeView/TreeView.css

This file was deleted.

104 changes: 0 additions & 104 deletions client/src/components/TreeView/index.jsx

This file was deleted.

Loading

0 comments on commit d7b7084

Please sign in to comment.