Add a python client library

We still don't have any documentation and things are in flux, but you can report your OpenAI API calls to OpenPipe now.
This commit is contained in:
Kyle Corbitt
2023-08-11 16:54:50 -07:00
parent d9db6d80ea
commit 8ed47eb4dd
32 changed files with 2698 additions and 85 deletions

View File

@@ -37,7 +37,7 @@ export default function LoggedCalls() {
);
return (
<AppShell requireAuth>
<AppShell title="Logged Calls" requireAuth>
<PageHeaderContainer>
<Breadcrumb>
<BreadcrumbItem>

View File

@@ -35,6 +35,7 @@ export const externalApiRouter = createTRPCRouter({
method: "POST",
path: "/v1/check-cache",
description: "Check if a prompt is cached",
protect: true,
},
})
.input(
@@ -102,6 +103,7 @@ export const externalApiRouter = createTRPCRouter({
method: "POST",
path: "/v1/report",
description: "Report an API call",
protect: true,
},
})
.input(
@@ -122,6 +124,7 @@ export const externalApiRouter = createTRPCRouter({
)
.output(z.void())
.mutation(async ({ input, ctx }) => {
console.log("GOT TAGS", input.tags);
const apiKey = ctx.apiKey;
if (!apiKey) {
throw new TRPCError({ code: "UNAUTHORIZED" });

View File

@@ -64,7 +64,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => {
// Get the session from the server using the getServerSession wrapper function
const session = await getServerAuthSession({ req, res });
const apiKey = req.headers["x-openpipe-api-key"] as string | null;
const apiKey = req.headers.authorization?.split(" ")[1] as string | null;
return createInnerTRPCContext({
session,