MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / apiMockPrompt

Function apiMockPrompt

lib/prompts/apiMock.ts:4–121  ·  view source on GitHub ↗
(
  path: string,
  requestMethod: RequestMethod,
  requestParameters: Chunk[] | null,
  responseType: Properties | null,
  orgInfo?: {
    name: string;
    description: string;
  },
  isArray: boolean = false,
)

Source from the content-addressed store, hash-verified

2import { chunkToString } from "../utils";
3
4export 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
27Your task is to generate a mock API response to the user's request.
28
29Today'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}
48Below are two examples of how to generate your response from these fields.
49
50-- EXAMPLE 1 --
51
52Fields
53---
54
55Name (string): The user's name
56Age (integer): The user's age
57City (string): where the user lives
58
59Response
60---
61

Callers 2

getMockedPropertiesFunction · 0.85

Calls 1

chunkToStringFunction · 0.90

Tested by

no test coverage detected