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

Function getMissingParam

lib/edge-runtime/missingParamCorrection.ts:55–85  ·  view source on GitHub ↗
(
  missingParam: string,
  action: Action,
  previousConversation: ChatGPTMessage[],
  model: string,
)

Source from the content-addressed store, hash-verified

53}
54
55async function getMissingParam(
56 missingParam: string,
57 action: Action,
58 previousConversation: ChatGPTMessage[],
59 model: string,
60): Promise<string | null> {
61 console.log(`Parameter ${missingParam} is missing. Attempt to get it`);
62 const correctionPrompt = requestCorrectionPrompt(missingParam, action);
63 if (!correctionPrompt) return null;
64 const prompt = removeOldestFunctionCalls(
65 [...previousConversation].concat(correctionPrompt),
66 "4",
67 200,
68 );
69 console.log("Request correction prompt:\n", prompt);
70 let response = await getLLMResponse(
71 prompt,
72 {
73 frequency_penalty: 0,
74 max_tokens: 200,
75 },
76 model,
77 );
78 response = response.trim().replace(/\n/g, "");
79 console.log("Response from gpt:\n", response);
80 try {
81 // Type casts to the most appropriate type, errors and returns a string if no casting possible
82 response = JSON.parse(response);
83 } catch {}
84 return response;
85}
86
87function getRequiredParams(action: Action): string[] {
88 if (!action.parameters) return [];

Callers 1

getMissingArgCorrectionsFunction · 0.85

Calls 3

getLLMResponseFunction · 0.90
requestCorrectionPromptFunction · 0.85

Tested by

no test coverage detected