(
path: string,
requestMethod: RequestMethod,
requestParameters: Chunk[] | null,
responseType: Properties | null,
orgInfo?: {
name: string;
description: string;
},
isArray: boolean = false,
)
| 2 | import { chunkToString } from "../utils"; |
| 3 | |
| 4 | export default function apiMockPrompt( |
| 5 | path: string, |
| 6 | requestMethod: RequestMethod, |
| 7 | requestParameters: Chunk[] | null, |
| 8 | responseType: Properties | null, |
| 9 | orgInfo?: { |
| 10 | name: string; |
| 11 | description: string; |
| 12 | }, |
| 13 | isArray: boolean = false, |
| 14 | ): ChatGPTMessage[] { |
| 15 | // TODO: Maybe add Examples to prompt type as e.g for retrieve_event_counts_for_a_team it's required to infer the shape of |
| 16 | // the array they want back |
| 17 | // TODO: randomly select the length of the array rather than hardcoding 3 |
| 18 | return [ |
| 19 | { |
| 20 | role: "system", |
| 21 | content: `The user is sending a request to ${ |
| 22 | orgInfo?.name ? `${orgInfo.name}'s` : "an" |
| 23 | } API. ${ |
| 24 | orgInfo?.description ?? "" |
| 25 | }. However, they do not have access to the real API. |
| 26 | |
| 27 | Your task is to generate a mock API response to the user's request. |
| 28 | |
| 29 | Today's date is ${new Date().toISOString().split("T")[0]}.`, |
| 30 | }, |
| 31 | { |
| 32 | role: "user", |
| 33 | content: `I am sending a ${requestMethod} request to the ${path} endpoint${ |
| 34 | requestParameters |
| 35 | ? ` with parameters: |
| 36 | ${requestParameters.map((param) => chunkToString(param)).join("\n")}` |
| 37 | : " with no parameters." |
| 38 | } |
| 39 | |
| 40 | ${ |
| 41 | responseType |
| 42 | ? `There are specific fields that I want to be returned in the response. |
| 43 | ${ |
| 44 | isArray |
| 45 | ? "These fields form an array. I want the array to be of length 3." |
| 46 | : "" |
| 47 | } |
| 48 | Below are two examples of how to generate your response from these fields. |
| 49 | |
| 50 | -- EXAMPLE 1 -- |
| 51 | |
| 52 | Fields |
| 53 | --- |
| 54 | |
| 55 | Name (string): The user's name |
| 56 | Age (integer): The user's age |
| 57 | City (string): where the user lives |
| 58 | |
| 59 | Response |
| 60 | --- |
| 61 |
no test coverage detected