Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/create project property and add it to LogDetails #93

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions front/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ async function main() {
password: hashed,
},
});
const project = await prisma.project.create({
data: {
name: "Default Project",
},
});
const tagSeeded = await prisma.tag.create({
data: {
name: "Seeded",
Expand All @@ -47,6 +52,11 @@ async function main() {
id: tagSeeded.id,
},
},
project: {
connect: {
name: project.name,
},
},
},
});
await prisma.llmLogs.create({
Expand All @@ -66,6 +76,11 @@ async function main() {
},
],
},
project: {
connect: {
name: project.name,
},
},
},
});
}
Expand Down
4 changes: 4 additions & 0 deletions front/src/features/tables/views/LogDetailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const LogDetailsTable = ({ logDetails }: { logDetails: LogData }) => {
logId={logDetails.id}
/>
</tr>
<tr>
<td className="font-bold px-4 py-2">Project</td>
<td className="px-4 py-2">{logDetails.project.name}</td>
</tr>
</tbody>
</table>
</CardAtom>
Expand Down
2 changes: 2 additions & 0 deletions front/src/services/prisma/LogsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const LogsData = {
},
take: 5,
},
project: true,
},
});
},
Expand All @@ -33,6 +34,7 @@ export const LogsData = {
name: "asc",
},
},
project: true,
},
});

Expand Down
4 changes: 2 additions & 2 deletions front/src/types/logDisplayOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tag, llmLogs } from "@prisma/client";
import { Project, Tag, llmLogs } from "@prisma/client";

export type LogDisplayOptions = {
sortBy?: SortOptions;
Expand All @@ -14,5 +14,5 @@ export type TimeOption = "last-hour" | "last-day" | "last-week";
export type Order = "asc" | "desc";
export type SortOptions = "datetime_utc" | "total_tokens" | "id" | "cost";

export type LogData = llmLogs & { tags: Tag[] };
export type LogData = llmLogs & { tags: Tag[] } & { project: Project };
export type LogDataArray = LogData[];
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Warnings:

- Added the required column `projectId` to the `llmLogs` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "llmLogs" ADD COLUMN "projectId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "Project" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,

CONSTRAINT "Project_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Project_name_key" ON "Project"("name");

-- AddForeignKey
ALTER TABLE "llmLogs" ADD CONSTRAINT "llmLogs_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
8 changes: 8 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ model llmLogs {
total_tokens Int
cost Float?
tags Tag[]
project Project @relation(fields: [projectId], references: [id])
projectId String
}

model Tag {
Expand All @@ -33,6 +35,12 @@ model Tag {
logs llmLogs[]
}

model Project {
id String @id @default(uuid())
name String @unique
llmLogs llmLogs[]
}

model omnilogUser {
id String @id @default(uuid())
email String @unique
Expand Down