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

Function runCodeGen

lib/v2/edge-runtime/ai.ts:898–962  ·  view source on GitHub ↗
(
  userRequest: string,
  actions: ActionPlusApiInfo[],
  org: Pick<
    Organization,
    | "id"
    | "name"
    | "description"
    | "chatbot_instructions"
    | "fun_loading_messages"
  >,
  dbData: { conversationId: number; index: number },
  userDescription: string,
  chatMessageCache: LlmResponseCache,
  streamInfo: (step: StreamingStepInput) => void,
  userApiKey: string | undefined,
)

Source from the content-addressed store, hash-verified

896}
897
898async function runCodeGen(
899 userRequest: string,
900 actions: ActionPlusApiInfo[],
901 org: Pick<
902 Organization,
903 | "id"
904 | "name"
905 | "description"
906 | "chatbot_instructions"
907 | "fun_loading_messages"
908 >,
909 dbData: { conversationId: number; index: number },
910 userDescription: string,
911 chatMessageCache: LlmResponseCache,
912 streamInfo: (step: StreamingStepInput) => void,
913 userApiKey: string | undefined,
914): Promise<FunctionMessage[]> {
915 console.log("Running data analysis!");
916 const graphData = await runDataAnalysis(
917 userRequest,
918 actions,
919 org,
920 dbData,
921 userDescription,
922 chatMessageCache,
923 streamInfo,
924 userApiKey,
925 );
926 // Used in if statements further down
927 const fnMsg: FunctionMessage = {
928 role: "function",
929 name: dataAnalysisActionName,
930 content: "",
931 };
932 // Return graph data to the user & add message to chat history
933 if (graphData === null) {
934 fnMsg.content = "Failed to run data analysis";
935 streamInfo(fnMsg);
936 return [fnMsg];
937 } else if ("error" in graphData) {
938 // Handle error - add function message
939 fnMsg.content = graphData.error;
940 streamInfo(fnMsg);
941 return [fnMsg];
942 } else {
943 // Stream API calls
944 graphData
945 .filter((m) => m.type === "call-human-format")
946 .map((m) =>
947 streamInfo({
948 role: "debug",
949 // @ts-ignore
950 content: m.args.message,
951 }),
952 );
953 const graphDataArr = convertToGraphData(graphData);
954 graphDataArr.map(streamInfo);
955 return graphDataArr.map((m) => ({

Callers 1

BertieFunction · 0.85

Calls 3

runDataAnalysisFunction · 0.90
convertToGraphDataFunction · 0.90
streamInfoFunction · 0.50

Tested by

no test coverage detected