Skip to content

Does not work in Cloud Functions environment #11

@zallesov

Description

@zallesov

First of all - great idea and great library. If it works it works great! but I'm having a hard time making it run inside a cloud function. This is my function for reference

/** @description Given `cities` a list of city names with country codes, 
 * returns a the same list with added latitude, longitude. */
function hidrateCitiesCoordinates(cities: TripPoint[]): (TripPoint & { lat: number, lng: number })[] | void { }
export const hidrateCitiesCoordinatesAI = toAIFunction(hidrateCitiesCoordinates)

I could make it work locally in plain typescript app ran with tsup-node or ts-node

Describe the bug
I attempted to run it in the Google Cloud Functions environment which is "compiled" to javascript.
I get this error

TypeError: Cannot read properties of undefined (reading 'type')
    at toAIFunction (file:///Users/username/Projects/air/node_modules/.pnpm/@typeai+core@0.6.1_@deepkit+core@1.0.1-alpha.147_@jefflaporte+deepkit-type@1.0.1-alpha.97-jl_openai@3.3.0/node_modules/@typeai/core/dist/index.js:4186:40)

and Indeed in the js files there is no implementation of the function

import { toAIFunction } from "@typeai/core";
function hidrateCitiesCoordinates(cities) {
}
var hidrateCitiesCoordinatesAI = toAIFunction(hidrateCitiesCoordinates);

tsconfig.json

  "compilerOptions": {
    "outDir": "dist",
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "lib": [
      "esnext"
    ],
    "sourceMap": true,
    "types": [
      "node"
    ],
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "src/*"
      ]
    },
    "experimentalDecorators": true
  },
  "reflection": true,
  "include": [
    "src"
  ]
}

I also did the step with deepkit-type-install

Is it even possible to achieve this?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions