Sunday, June 11, 2023

Vercel database Prisma setup

 


PrismaClientKnownRequestError:
Invalid `prisma.workspace.findMany()` invocation:
The table `public.workspaces` does not exist in the current database.
at pn.handleRequestError (/vercel/path0/node_modules/@prisma/client/runtime/library.js:176:6477)
at pn.handleAndLogRequestError


npx prisma migrate dev

% npx prisma migrate dev

Environment variables loaded from .env

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "verceldb", schema "public" at "ep-delicate-dust-021378.us-east-1.postgres.vercel-storage.com:5432"


Error: P3014


% npx prisma migrate resolve --applied 20220223015914_init_database

Environment variables loaded from .env

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "verceldb", schema "public" at "ep-delicate-dust-021378.us-east-1.postgres.vercel-storage.com:5432"

Migration 20220223015914_init_database marked as applied.

% npx prisma migrate resolve --applied 20220508151141_add_domain_verification_columns

Environment variables loaded from .env

Prisma schema loaded from prisma/schema.prisma

Datasource "db": PostgreSQL database "verceldb", schema "public" at "ep-delicate-dust-021378.us-east-1.postgres.vercel-storage.com:5432"

Migration 20220508151141_add_domain_verification_columns marked as applied.



Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow


Original error:

db error: ERROR: permission denied to create database

   0: schema_core::state::DevDiagnostic

             at schema-engine/core/src/state.rs:266



Put env vars to vercel except VERCEL_ prefixed env vars

The value is not a valid System Environment name


Friday, June 2, 2023

Vector store pricings

 

candidates

https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/


typesense cloud $14.40

https://cloud.typesense.org/pricing



https://qdrant.tech/pricing/





https://www.pinecone.io/pricing/

Free plan is not available for now.




https://weaviate.io/pricing

Standard

from

$ 25 /mo
  • $0.050 per 1M vector dimensions stored
    or queried per month




  • supabase

  • https://supabase.com/blog/openai-embeddings-postgres-vector
  • vercel postgres

  • https://vercel.com/templates/next.js/postgres-pgvector




  • Sunday, April 30, 2023

    Using async in inline Editor of GCP Dialogflow. But, timeout too short.

     


    Using async in inline Editor of GCP Dialogflow 

    /* experimental: [asyncawait] */

    https://stackoverflow.com/questions/42637630/does-jshint-support-async-await/48772304#48772304


    to know queryText from the user

    https://stackoverflow.com/questions/60408929/how-do-you-read-query-the-response-body-in-api-v2-of-dialogflow-fulfillment


    function handleRequest(request, response) { const queryText = request.body.queryResult.queryText; // use the queryText variable to process the user's input }


    sample code (without async)

    https://github.com/priyankavergadia/AppointmentScheduler-GoogleCalendar/blob/master/index.js


    Dialogflow CX timeout only 30 sec

    Dialogflow ES timeout only 15 sec

    https://groups.google.com/g/dialogflow-cx-edition-users/c/jajSEPqhYZE


    Following code didn't work.

      async function answerQuestion(agent) {

        const response = await axios.post(

    ...    {

          message: JSON.stringify(request.body.queryResult.queryText)

        },

        {

          headers: { 'Content-Type': 'application/json' },

          timeout: 2 * 60 * 1000

        }

        );

        agent.setContext({ name: "Question", result: response });

        agent.add(`${response.data.data.answer} \n\n ${response.data.data.sources}`);

      }


    Wednesday, June 30, 2021

    mysql 5.7 mac app my.cnf

     Mysql 5.7 from mysql 

    $ /usr/local/mysql-5.7.31-macos10.14-x86_64/bin/mysql --help --verbose | grep my.cnf

                          order of preference, my.cnf, $MYSQL_TCP_PORT,

    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf


    It works when I created /etc/my.cnf

    $ cat /etc/my.cnf

    [mysqld]

    default_time_zone='-08:00'


    Homebrew mysql

    $ mysql --help --verbose | grep my.cnf

                          order of preference, my.cnf, $MYSQL_TCP_PORT,

    /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf


    /usr/local/etc/my.cnf exists


    Thursday, November 5, 2020

    python json serialization dacite

     

     Handle nested Dict

    https://github.com/konradhalas/dacite


    Tuple issue

    Tuple --> json list --> python list

    from_dict(A, {'x': x}, config=Config(check_types=False))