Skip to content

Commit

Permalink
docs: refactor types and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
crnvl authored Nov 22, 2024
1 parent f256218 commit c97f8f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
9 changes: 8 additions & 1 deletion app/api/openai/raw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OpenAiRawRequestParams } from "@/misc/apiRoutes";
import { NextApiRequest, NextApiResponse } from "next";
import OpenAI from "openai";
const openai = new OpenAI();
Expand All @@ -18,3 +17,11 @@ const _handler = async (req: NextApiRequest, res: NextApiResponse) => {

res.status(200).json({ data: completion.choices[0].message });
};

export interface OpenAiRawRequestParams {
prompt: string;
}

export interface OpenAiRawResponseParams {
data: string;
}
10 changes: 10 additions & 0 deletions docs/openai/raw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# POST `/openai/raw`
```ts
export interface OpenAiRawRequestParams {
prompt: string;
}

export interface OpenAiRawResponseParams {
data: string;
}
```
9 changes: 3 additions & 6 deletions misc/apiRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { OpenAiRawRequestParams, OpenAiRawResponseParams } from '@/app/api/openai/raw';
import axios from 'axios';

const api = axios.create();

export const endpoints = {
openAi: {
getRawResponse: async (params: OpenAiRawRequestParams) => {
getRawResponse: async (params: OpenAiRawRequestParams): Promise<OpenAiRawResponseParams> => {
return api.post('/openai/raw', params);
},
}
};

export interface OpenAiRawRequestParams {
prompt: string;
}
};

0 comments on commit c97f8f5

Please sign in to comment.