@ax-llm/ax 10.0.25 → 10.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -22
- package/ai/anthropic/api.d.ts +0 -20
- package/ai/anthropic/api.js +0 -353
- package/ai/anthropic/api.js.map +0 -1
- package/ai/anthropic/index.d.ts +0 -3
- package/ai/anthropic/index.js +0 -4
- package/ai/anthropic/index.js.map +0 -1
- package/ai/anthropic/info.d.ts +0 -2
- package/ai/anthropic/info.js +0 -49
- package/ai/anthropic/info.js.map +0 -1
- package/ai/anthropic/types.d.ts +0 -181
- package/ai/anthropic/types.js +0 -11
- package/ai/anthropic/types.js.map +0 -1
- package/ai/azure-openai/api.d.ts +0 -20
- package/ai/azure-openai/api.js +0 -30
- package/ai/azure-openai/api.js.map +0 -1
- package/ai/azure-openai/index.d.ts +0 -1
- package/ai/azure-openai/index.js +0 -2
- package/ai/azure-openai/index.js.map +0 -1
- package/ai/balance.d.ts +0 -40
- package/ai/balance.js +0 -104
- package/ai/balance.js.map +0 -1
- package/ai/base.d.ts +0 -66
- package/ai/base.js +0 -490
- package/ai/base.js.map +0 -1
- package/ai/cohere/api.d.ts +0 -23
- package/ai/cohere/api.js +0 -267
- package/ai/cohere/api.js.map +0 -1
- package/ai/cohere/index.d.ts +0 -3
- package/ai/cohere/index.js +0 -4
- package/ai/cohere/index.js.map +0 -1
- package/ai/cohere/info.d.ts +0 -2
- package/ai/cohere/info.js +0 -52
- package/ai/cohere/info.js.map +0 -1
- package/ai/cohere/types.d.ts +0 -102
- package/ai/cohere/types.js +0 -23
- package/ai/cohere/types.js.map +0 -1
- package/ai/deepseek/api.d.ts +0 -18
- package/ai/deepseek/api.js +0 -33
- package/ai/deepseek/api.js.map +0 -1
- package/ai/deepseek/index.d.ts +0 -3
- package/ai/deepseek/index.js +0 -4
- package/ai/deepseek/index.js.map +0 -1
- package/ai/deepseek/info.d.ts +0 -2
- package/ai/deepseek/info.js +0 -16
- package/ai/deepseek/info.js.map +0 -1
- package/ai/deepseek/types.d.ts +0 -8
- package/ai/deepseek/types.js +0 -10
- package/ai/deepseek/types.js.map +0 -1
- package/ai/google-gemini/api.d.ts +0 -43
- package/ai/google-gemini/api.js +0 -346
- package/ai/google-gemini/api.js.map +0 -1
- package/ai/google-gemini/index.d.ts +0 -3
- package/ai/google-gemini/index.js +0 -4
- package/ai/google-gemini/index.js.map +0 -1
- package/ai/google-gemini/info.d.ts +0 -6
- package/ai/google-gemini/info.js +0 -36
- package/ai/google-gemini/info.js.map +0 -1
- package/ai/google-gemini/types.d.ts +0 -159
- package/ai/google-gemini/types.js +0 -29
- package/ai/google-gemini/types.js.map +0 -1
- package/ai/groq/api.d.ts +0 -20
- package/ai/groq/api.js +0 -54
- package/ai/groq/api.js.map +0 -1
- package/ai/groq/index.d.ts +0 -3
- package/ai/groq/index.js +0 -4
- package/ai/groq/index.js.map +0 -1
- package/ai/groq/info.d.ts +0 -6
- package/ai/groq/info.js +0 -36
- package/ai/groq/info.js.map +0 -1
- package/ai/groq/types.d.ts +0 -6
- package/ai/groq/types.js +0 -8
- package/ai/groq/types.js.map +0 -1
- package/ai/huggingface/api.d.ts +0 -20
- package/ai/huggingface/api.js +0 -116
- package/ai/huggingface/api.js.map +0 -1
- package/ai/huggingface/index.d.ts +0 -3
- package/ai/huggingface/index.js +0 -4
- package/ai/huggingface/index.js.map +0 -1
- package/ai/huggingface/info.d.ts +0 -6
- package/ai/huggingface/info.js +0 -6
- package/ai/huggingface/info.js.map +0 -1
- package/ai/huggingface/types.d.ts +0 -34
- package/ai/huggingface/types.js +0 -5
- package/ai/huggingface/types.js.map +0 -1
- package/ai/index.d.ts +0 -16
- package/ai/index.js +0 -16
- package/ai/index.js.map +0 -1
- package/ai/mistral/api.d.ts +0 -18
- package/ai/mistral/api.js +0 -33
- package/ai/mistral/api.js.map +0 -1
- package/ai/mistral/index.d.ts +0 -3
- package/ai/mistral/index.js +0 -4
- package/ai/mistral/index.js.map +0 -1
- package/ai/mistral/info.d.ts +0 -2
- package/ai/mistral/info.js +0 -53
- package/ai/mistral/info.js.map +0 -1
- package/ai/mistral/types.d.ts +0 -13
- package/ai/mistral/types.js +0 -17
- package/ai/mistral/types.js.map +0 -1
- package/ai/ollama/api.d.ts +0 -23
- package/ai/ollama/api.js +0 -33
- package/ai/ollama/api.js.map +0 -1
- package/ai/ollama/index.d.ts +0 -1
- package/ai/ollama/index.js +0 -2
- package/ai/ollama/index.js.map +0 -1
- package/ai/openai/api.d.ts +0 -31
- package/ai/openai/api.js +0 -315
- package/ai/openai/api.js.map +0 -1
- package/ai/openai/index.d.ts +0 -3
- package/ai/openai/index.js +0 -4
- package/ai/openai/index.js.map +0 -1
- package/ai/openai/info.d.ts +0 -6
- package/ai/openai/info.js +0 -74
- package/ai/openai/info.js.map +0 -1
- package/ai/openai/types.d.ts +0 -177
- package/ai/openai/types.js +0 -22
- package/ai/openai/types.js.map +0 -1
- package/ai/reka/api.d.ts +0 -27
- package/ai/reka/api.js +0 -203
- package/ai/reka/api.js.map +0 -1
- package/ai/reka/index.d.ts +0 -3
- package/ai/reka/index.js +0 -4
- package/ai/reka/index.js.map +0 -1
- package/ai/reka/info.d.ts +0 -6
- package/ai/reka/info.js +0 -26
- package/ai/reka/info.js.map +0 -1
- package/ai/reka/types.d.ts +0 -67
- package/ai/reka/types.js +0 -7
- package/ai/reka/types.js.map +0 -1
- package/ai/together/api.d.ts +0 -16
- package/ai/together/api.js +0 -29
- package/ai/together/api.js.map +0 -1
- package/ai/together/index.d.ts +0 -2
- package/ai/together/index.js +0 -3
- package/ai/together/index.js.map +0 -1
- package/ai/together/info.d.ts +0 -2
- package/ai/together/info.js +0 -2
- package/ai/together/info.js.map +0 -1
- package/ai/types.d.ts +0 -202
- package/ai/types.js +0 -2
- package/ai/types.js.map +0 -1
- package/ai/util.d.ts +0 -12
- package/ai/util.js +0 -63
- package/ai/util.js.map +0 -1
- package/ai/wrap.d.ts +0 -42
- package/ai/wrap.js +0 -88
- package/ai/wrap.js.map +0 -1
- package/cjs/ai/anthropic/api.d.ts +0 -20
- package/cjs/ai/anthropic/api.js +0 -358
- package/cjs/ai/anthropic/api.js.map +0 -1
- package/cjs/ai/anthropic/index.d.ts +0 -3
- package/cjs/ai/anthropic/index.js +0 -20
- package/cjs/ai/anthropic/index.js.map +0 -1
- package/cjs/ai/anthropic/info.d.ts +0 -2
- package/cjs/ai/anthropic/info.js +0 -52
- package/cjs/ai/anthropic/info.js.map +0 -1
- package/cjs/ai/anthropic/types.d.ts +0 -181
- package/cjs/ai/anthropic/types.js +0 -14
- package/cjs/ai/anthropic/types.js.map +0 -1
- package/cjs/ai/azure-openai/api.d.ts +0 -20
- package/cjs/ai/azure-openai/api.js +0 -34
- package/cjs/ai/azure-openai/api.js.map +0 -1
- package/cjs/ai/azure-openai/index.d.ts +0 -1
- package/cjs/ai/azure-openai/index.js +0 -18
- package/cjs/ai/azure-openai/index.js.map +0 -1
- package/cjs/ai/balance.d.ts +0 -40
- package/cjs/ai/balance.js +0 -110
- package/cjs/ai/balance.js.map +0 -1
- package/cjs/ai/base.d.ts +0 -66
- package/cjs/ai/base.js +0 -496
- package/cjs/ai/base.js.map +0 -1
- package/cjs/ai/cohere/api.d.ts +0 -23
- package/cjs/ai/cohere/api.js +0 -273
- package/cjs/ai/cohere/api.js.map +0 -1
- package/cjs/ai/cohere/index.d.ts +0 -3
- package/cjs/ai/cohere/index.js +0 -20
- package/cjs/ai/cohere/index.js.map +0 -1
- package/cjs/ai/cohere/info.d.ts +0 -2
- package/cjs/ai/cohere/info.js +0 -55
- package/cjs/ai/cohere/info.js.map +0 -1
- package/cjs/ai/cohere/types.d.ts +0 -102
- package/cjs/ai/cohere/types.js +0 -26
- package/cjs/ai/cohere/types.js.map +0 -1
- package/cjs/ai/deepseek/api.d.ts +0 -18
- package/cjs/ai/deepseek/api.js +0 -39
- package/cjs/ai/deepseek/api.js.map +0 -1
- package/cjs/ai/deepseek/index.d.ts +0 -3
- package/cjs/ai/deepseek/index.js +0 -20
- package/cjs/ai/deepseek/index.js.map +0 -1
- package/cjs/ai/deepseek/info.d.ts +0 -2
- package/cjs/ai/deepseek/info.js +0 -19
- package/cjs/ai/deepseek/info.js.map +0 -1
- package/cjs/ai/deepseek/types.d.ts +0 -8
- package/cjs/ai/deepseek/types.js +0 -13
- package/cjs/ai/deepseek/types.js.map +0 -1
- package/cjs/ai/google-gemini/api.d.ts +0 -43
- package/cjs/ai/google-gemini/api.js +0 -352
- package/cjs/ai/google-gemini/api.js.map +0 -1
- package/cjs/ai/google-gemini/index.d.ts +0 -3
- package/cjs/ai/google-gemini/index.js +0 -20
- package/cjs/ai/google-gemini/index.js.map +0 -1
- package/cjs/ai/google-gemini/info.d.ts +0 -6
- package/cjs/ai/google-gemini/info.js +0 -39
- package/cjs/ai/google-gemini/info.js.map +0 -1
- package/cjs/ai/google-gemini/types.d.ts +0 -159
- package/cjs/ai/google-gemini/types.js +0 -32
- package/cjs/ai/google-gemini/types.js.map +0 -1
- package/cjs/ai/groq/api.d.ts +0 -20
- package/cjs/ai/groq/api.js +0 -58
- package/cjs/ai/groq/api.js.map +0 -1
- package/cjs/ai/groq/index.d.ts +0 -3
- package/cjs/ai/groq/index.js +0 -20
- package/cjs/ai/groq/index.js.map +0 -1
- package/cjs/ai/groq/info.d.ts +0 -6
- package/cjs/ai/groq/info.js +0 -39
- package/cjs/ai/groq/info.js.map +0 -1
- package/cjs/ai/groq/types.d.ts +0 -6
- package/cjs/ai/groq/types.js +0 -11
- package/cjs/ai/groq/types.js.map +0 -1
- package/cjs/ai/huggingface/api.d.ts +0 -20
- package/cjs/ai/huggingface/api.js +0 -122
- package/cjs/ai/huggingface/api.js.map +0 -1
- package/cjs/ai/huggingface/index.d.ts +0 -3
- package/cjs/ai/huggingface/index.js +0 -20
- package/cjs/ai/huggingface/index.js.map +0 -1
- package/cjs/ai/huggingface/info.d.ts +0 -6
- package/cjs/ai/huggingface/info.js +0 -9
- package/cjs/ai/huggingface/info.js.map +0 -1
- package/cjs/ai/huggingface/types.d.ts +0 -34
- package/cjs/ai/huggingface/types.js +0 -8
- package/cjs/ai/huggingface/types.js.map +0 -1
- package/cjs/ai/index.d.ts +0 -16
- package/cjs/ai/index.js +0 -32
- package/cjs/ai/index.js.map +0 -1
- package/cjs/ai/mistral/api.d.ts +0 -18
- package/cjs/ai/mistral/api.js +0 -39
- package/cjs/ai/mistral/api.js.map +0 -1
- package/cjs/ai/mistral/index.d.ts +0 -3
- package/cjs/ai/mistral/index.js +0 -20
- package/cjs/ai/mistral/index.js.map +0 -1
- package/cjs/ai/mistral/info.d.ts +0 -2
- package/cjs/ai/mistral/info.js +0 -56
- package/cjs/ai/mistral/info.js.map +0 -1
- package/cjs/ai/mistral/types.d.ts +0 -13
- package/cjs/ai/mistral/types.js +0 -20
- package/cjs/ai/mistral/types.js.map +0 -1
- package/cjs/ai/ollama/api.d.ts +0 -23
- package/cjs/ai/ollama/api.js +0 -39
- package/cjs/ai/ollama/api.js.map +0 -1
- package/cjs/ai/ollama/index.d.ts +0 -1
- package/cjs/ai/ollama/index.js +0 -18
- package/cjs/ai/ollama/index.js.map +0 -1
- package/cjs/ai/openai/api.d.ts +0 -31
- package/cjs/ai/openai/api.js +0 -323
- package/cjs/ai/openai/api.js.map +0 -1
- package/cjs/ai/openai/index.d.ts +0 -3
- package/cjs/ai/openai/index.js +0 -20
- package/cjs/ai/openai/index.js.map +0 -1
- package/cjs/ai/openai/info.d.ts +0 -6
- package/cjs/ai/openai/info.js +0 -77
- package/cjs/ai/openai/info.js.map +0 -1
- package/cjs/ai/openai/types.d.ts +0 -177
- package/cjs/ai/openai/types.js +0 -25
- package/cjs/ai/openai/types.js.map +0 -1
- package/cjs/ai/reka/api.d.ts +0 -27
- package/cjs/ai/reka/api.js +0 -211
- package/cjs/ai/reka/api.js.map +0 -1
- package/cjs/ai/reka/index.d.ts +0 -3
- package/cjs/ai/reka/index.js +0 -20
- package/cjs/ai/reka/index.js.map +0 -1
- package/cjs/ai/reka/info.d.ts +0 -6
- package/cjs/ai/reka/info.js +0 -29
- package/cjs/ai/reka/info.js.map +0 -1
- package/cjs/ai/reka/types.d.ts +0 -67
- package/cjs/ai/reka/types.js +0 -10
- package/cjs/ai/reka/types.js.map +0 -1
- package/cjs/ai/together/api.d.ts +0 -16
- package/cjs/ai/together/api.js +0 -34
- package/cjs/ai/together/api.js.map +0 -1
- package/cjs/ai/together/index.d.ts +0 -2
- package/cjs/ai/together/index.js +0 -19
- package/cjs/ai/together/index.js.map +0 -1
- package/cjs/ai/together/info.d.ts +0 -2
- package/cjs/ai/together/info.js +0 -5
- package/cjs/ai/together/info.js.map +0 -1
- package/cjs/ai/types.d.ts +0 -202
- package/cjs/ai/types.js +0 -3
- package/cjs/ai/types.js.map +0 -1
- package/cjs/ai/util.d.ts +0 -12
- package/cjs/ai/util.js +0 -71
- package/cjs/ai/util.js.map +0 -1
- package/cjs/ai/wrap.d.ts +0 -42
- package/cjs/ai/wrap.js +0 -92
- package/cjs/ai/wrap.js.map +0 -1
- package/cjs/db/base.d.ts +0 -23
- package/cjs/db/base.js +0 -91
- package/cjs/db/base.js.map +0 -1
- package/cjs/db/cloudflare.d.ts +0 -21
- package/cjs/db/cloudflare.js +0 -102
- package/cjs/db/cloudflare.js.map +0 -1
- package/cjs/db/index.d.ts +0 -6
- package/cjs/db/index.js +0 -23
- package/cjs/db/index.js.map +0 -1
- package/cjs/db/memory.d.ts +0 -21
- package/cjs/db/memory.js +0 -103
- package/cjs/db/memory.js.map +0 -1
- package/cjs/db/pinecone.d.ts +0 -21
- package/cjs/db/pinecone.js +0 -75
- package/cjs/db/pinecone.js.map +0 -1
- package/cjs/db/types.d.ts +0 -35
- package/cjs/db/types.js +0 -4
- package/cjs/db/types.js.map +0 -1
- package/cjs/db/weaviate.d.ts +0 -21
- package/cjs/db/weaviate.js +0 -131
- package/cjs/db/weaviate.js.map +0 -1
- package/cjs/db/wrap.d.ts +0 -13
- package/cjs/db/wrap.js +0 -39
- package/cjs/db/wrap.js.map +0 -1
- package/cjs/docs/index.d.ts +0 -4
- package/cjs/docs/index.js +0 -21
- package/cjs/docs/index.js.map +0 -1
- package/cjs/docs/manager.d.ts +0 -45
- package/cjs/docs/manager.js +0 -165
- package/cjs/docs/manager.js.map +0 -1
- package/cjs/docs/reranker.d.ts +0 -7
- package/cjs/docs/reranker.js +0 -30
- package/cjs/docs/reranker.js.map +0 -1
- package/cjs/docs/rewriter.d.ts +0 -4
- package/cjs/docs/rewriter.js +0 -13
- package/cjs/docs/rewriter.js.map +0 -1
- package/cjs/docs/tika.d.ts +0 -18
- package/cjs/docs/tika.js +0 -50
- package/cjs/docs/tika.js.map +0 -1
- package/cjs/dsp/asserts.d.ts +0 -32
- package/cjs/dsp/asserts.js +0 -98
- package/cjs/dsp/asserts.js.map +0 -1
- package/cjs/dsp/datetime.d.ts +0 -4
- package/cjs/dsp/datetime.js +0 -72
- package/cjs/dsp/datetime.js.map +0 -1
- package/cjs/dsp/eval.d.ts +0 -43
- package/cjs/dsp/eval.js +0 -128
- package/cjs/dsp/eval.js.map +0 -1
- package/cjs/dsp/evaluate.d.ts +0 -15
- package/cjs/dsp/evaluate.js +0 -38
- package/cjs/dsp/evaluate.js.map +0 -1
- package/cjs/dsp/extract.d.ts +0 -9
- package/cjs/dsp/extract.js +0 -169
- package/cjs/dsp/extract.js.map +0 -1
- package/cjs/dsp/functions.d.ts +0 -23
- package/cjs/dsp/functions.js +0 -121
- package/cjs/dsp/functions.js.map +0 -1
- package/cjs/dsp/generate.d.ts +0 -58
- package/cjs/dsp/generate.js +0 -254
- package/cjs/dsp/generate.js.map +0 -1
- package/cjs/dsp/index.d.ts +0 -15
- package/cjs/dsp/index.js +0 -27
- package/cjs/dsp/index.js.map +0 -1
- package/cjs/dsp/jsonschema.d.ts +0 -2
- package/cjs/dsp/jsonschema.js +0 -101
- package/cjs/dsp/jsonschema.js.map +0 -1
- package/cjs/dsp/loader.d.ts +0 -30
- package/cjs/dsp/loader.js +0 -85
- package/cjs/dsp/loader.js.map +0 -1
- package/cjs/dsp/modelinfo.d.ts +0 -8
- package/cjs/dsp/modelinfo.js +0 -35
- package/cjs/dsp/modelinfo.js.map +0 -1
- package/cjs/dsp/optimize.d.ts +0 -30
- package/cjs/dsp/optimize.js +0 -101
- package/cjs/dsp/optimize.js.map +0 -1
- package/cjs/dsp/parser.d.ts +0 -40
- package/cjs/dsp/parser.js +0 -169
- package/cjs/dsp/parser.js.map +0 -1
- package/cjs/dsp/program.d.ts +0 -104
- package/cjs/dsp/program.js +0 -198
- package/cjs/dsp/program.js.map +0 -1
- package/cjs/dsp/prompt.d.ts +0 -48
- package/cjs/dsp/prompt.js +0 -380
- package/cjs/dsp/prompt.js.map +0 -1
- package/cjs/dsp/registry.d.ts +0 -6
- package/cjs/dsp/registry.js +0 -19
- package/cjs/dsp/registry.js.map +0 -1
- package/cjs/dsp/router.d.ts +0 -25
- package/cjs/dsp/router.js +0 -75
- package/cjs/dsp/router.js.map +0 -1
- package/cjs/dsp/sig.d.ts +0 -38
- package/cjs/dsp/sig.js +0 -205
- package/cjs/dsp/sig.js.map +0 -1
- package/cjs/dsp/stopwords.d.ts +0 -1
- package/cjs/dsp/stopwords.js +0 -1167
- package/cjs/dsp/stopwords.js.map +0 -1
- package/cjs/dsp/strutil.d.ts +0 -11
- package/cjs/dsp/strutil.js +0 -63
- package/cjs/dsp/strutil.js.map +0 -1
- package/cjs/dsp/util.d.ts +0 -10
- package/cjs/dsp/util.js +0 -169
- package/cjs/dsp/util.js.map +0 -1
- package/cjs/dsp/validate.d.ts +0 -17
- package/cjs/dsp/validate.js +0 -30
- package/cjs/dsp/validate.js.map +0 -1
- package/cjs/funcs/code.d.ts +0 -16
- package/cjs/funcs/code.js +0 -86
- package/cjs/funcs/code.js.map +0 -1
- package/cjs/funcs/docker.d.ts +0 -101
- package/cjs/funcs/docker.js +0 -217
- package/cjs/funcs/docker.js.map +0 -1
- package/cjs/funcs/embed.d.ts +0 -17
- package/cjs/funcs/embed.js +0 -42
- package/cjs/funcs/embed.js.map +0 -1
- package/cjs/funcs/index.d.ts +0 -3
- package/cjs/funcs/index.js +0 -20
- package/cjs/funcs/index.js.map +0 -1
- package/cjs/index.d.ts +0 -9
- package/cjs/index.js +0 -34
- package/cjs/index.js.map +0 -1
- package/cjs/mem/index.d.ts +0 -2
- package/cjs/mem/index.js +0 -19
- package/cjs/mem/index.js.map +0 -1
- package/cjs/mem/memory.d.ts +0 -15
- package/cjs/mem/memory.js +0 -78
- package/cjs/mem/memory.js.map +0 -1
- package/cjs/mem/types.d.ts +0 -14
- package/cjs/mem/types.js +0 -3
- package/cjs/mem/types.js.map +0 -1
- package/cjs/prompts/agent.d.ts +0 -37
- package/cjs/prompts/agent.js +0 -128
- package/cjs/prompts/agent.js.map +0 -1
- package/cjs/prompts/cot.d.ts +0 -8
- package/cjs/prompts/cot.js +0 -21
- package/cjs/prompts/cot.js.map +0 -1
- package/cjs/prompts/index.d.ts +0 -3
- package/cjs/prompts/index.js +0 -20
- package/cjs/prompts/index.js.map +0 -1
- package/cjs/prompts/rag.d.ts +0 -23
- package/cjs/prompts/rag.js +0 -33
- package/cjs/prompts/rag.js.map +0 -1
- package/cjs/trace/index.d.ts +0 -171
- package/cjs/trace/index.js +0 -70
- package/cjs/trace/index.js.map +0 -1
- package/cjs/util/apicall.d.ts +0 -18
- package/cjs/util/apicall.js +0 -58
- package/cjs/util/apicall.js.map +0 -1
- package/cjs/util/log.d.ts +0 -14
- package/cjs/util/log.js +0 -35
- package/cjs/util/log.js.map +0 -1
- package/cjs/util/other.d.ts +0 -1
- package/cjs/util/other.js +0 -8
- package/cjs/util/other.js.map +0 -1
- package/cjs/util/rate-limit.d.ts +0 -24
- package/cjs/util/rate-limit.js +0 -53
- package/cjs/util/rate-limit.js.map +0 -1
- package/cjs/util/sse.d.ts +0 -12
- package/cjs/util/sse.js +0 -97
- package/cjs/util/sse.js.map +0 -1
- package/cjs/util/stream.d.ts +0 -9
- package/cjs/util/stream.js +0 -33
- package/cjs/util/stream.js.map +0 -1
- package/cjs/util/transform.d.ts +0 -4
- package/cjs/util/transform.js +0 -33
- package/cjs/util/transform.js.map +0 -1
- package/db/base.d.ts +0 -23
- package/db/base.js +0 -87
- package/db/base.js.map +0 -1
- package/db/cloudflare.d.ts +0 -21
- package/db/cloudflare.js +0 -98
- package/db/cloudflare.js.map +0 -1
- package/db/index.d.ts +0 -6
- package/db/index.js +0 -7
- package/db/index.js.map +0 -1
- package/db/memory.d.ts +0 -21
- package/db/memory.js +0 -99
- package/db/memory.js.map +0 -1
- package/db/pinecone.d.ts +0 -21
- package/db/pinecone.js +0 -71
- package/db/pinecone.js.map +0 -1
- package/db/types.d.ts +0 -35
- package/db/types.js +0 -3
- package/db/types.js.map +0 -1
- package/db/weaviate.d.ts +0 -21
- package/db/weaviate.js +0 -127
- package/db/weaviate.js.map +0 -1
- package/db/wrap.d.ts +0 -13
- package/db/wrap.js +0 -35
- package/db/wrap.js.map +0 -1
- package/docs/index.d.ts +0 -4
- package/docs/index.js +0 -5
- package/docs/index.js.map +0 -1
- package/docs/manager.d.ts +0 -45
- package/docs/manager.js +0 -162
- package/docs/manager.js.map +0 -1
- package/docs/reranker.d.ts +0 -7
- package/docs/reranker.js +0 -26
- package/docs/reranker.js.map +0 -1
- package/docs/rewriter.d.ts +0 -4
- package/docs/rewriter.js +0 -9
- package/docs/rewriter.js.map +0 -1
- package/docs/tika.d.ts +0 -18
- package/docs/tika.js +0 -46
- package/docs/tika.js.map +0 -1
- package/dsp/asserts.d.ts +0 -32
- package/dsp/asserts.js +0 -91
- package/dsp/asserts.js.map +0 -1
- package/dsp/datetime.d.ts +0 -4
- package/dsp/datetime.js +0 -63
- package/dsp/datetime.js.map +0 -1
- package/dsp/eval.d.ts +0 -43
- package/dsp/eval.js +0 -125
- package/dsp/eval.js.map +0 -1
- package/dsp/evaluate.d.ts +0 -15
- package/dsp/evaluate.js +0 -34
- package/dsp/evaluate.js.map +0 -1
- package/dsp/extract.d.ts +0 -9
- package/dsp/extract.js +0 -159
- package/dsp/extract.js.map +0 -1
- package/dsp/functions.d.ts +0 -23
- package/dsp/functions.js +0 -111
- package/dsp/functions.js.map +0 -1
- package/dsp/generate.d.ts +0 -58
- package/dsp/generate.js +0 -251
- package/dsp/generate.js.map +0 -1
- package/dsp/index.d.ts +0 -15
- package/dsp/index.js +0 -11
- package/dsp/index.js.map +0 -1
- package/dsp/jsonschema.d.ts +0 -2
- package/dsp/jsonschema.js +0 -97
- package/dsp/jsonschema.js.map +0 -1
- package/dsp/loader.d.ts +0 -30
- package/dsp/loader.js +0 -81
- package/dsp/loader.js.map +0 -1
- package/dsp/modelinfo.d.ts +0 -8
- package/dsp/modelinfo.js +0 -32
- package/dsp/modelinfo.js.map +0 -1
- package/dsp/optimize.d.ts +0 -30
- package/dsp/optimize.js +0 -97
- package/dsp/optimize.js.map +0 -1
- package/dsp/parser.d.ts +0 -40
- package/dsp/parser.js +0 -166
- package/dsp/parser.js.map +0 -1
- package/dsp/program.d.ts +0 -104
- package/dsp/program.js +0 -193
- package/dsp/program.js.map +0 -1
- package/dsp/prompt.d.ts +0 -48
- package/dsp/prompt.js +0 -376
- package/dsp/prompt.js.map +0 -1
- package/dsp/registry.d.ts +0 -6
- package/dsp/registry.js +0 -15
- package/dsp/registry.js.map +0 -1
- package/dsp/router.d.ts +0 -25
- package/dsp/router.js +0 -70
- package/dsp/router.js.map +0 -1
- package/dsp/sig.d.ts +0 -38
- package/dsp/sig.js +0 -201
- package/dsp/sig.js.map +0 -1
- package/dsp/stopwords.d.ts +0 -1
- package/dsp/stopwords.js +0 -1164
- package/dsp/stopwords.js.map +0 -1
- package/dsp/strutil.d.ts +0 -11
- package/dsp/strutil.js +0 -60
- package/dsp/strutil.js.map +0 -1
- package/dsp/util.d.ts +0 -10
- package/dsp/util.js +0 -162
- package/dsp/util.js.map +0 -1
- package/dsp/validate.d.ts +0 -17
- package/dsp/validate.js +0 -26
- package/dsp/validate.js.map +0 -1
- package/funcs/code.d.ts +0 -16
- package/funcs/code.js +0 -59
- package/funcs/code.js.map +0 -1
- package/funcs/docker.d.ts +0 -101
- package/funcs/docker.js +0 -213
- package/funcs/docker.js.map +0 -1
- package/funcs/embed.d.ts +0 -17
- package/funcs/embed.js +0 -38
- package/funcs/embed.js.map +0 -1
- package/funcs/index.d.ts +0 -3
- package/funcs/index.js +0 -4
- package/funcs/index.js.map +0 -1
- package/index.d.ts +0 -9
- package/index.js +0 -16
- package/index.js.map +0 -1
- package/mem/index.d.ts +0 -2
- package/mem/index.js +0 -3
- package/mem/index.js.map +0 -1
- package/mem/memory.d.ts +0 -15
- package/mem/memory.js +0 -74
- package/mem/memory.js.map +0 -1
- package/mem/types.d.ts +0 -14
- package/mem/types.js +0 -2
- package/mem/types.js.map +0 -1
- package/prompts/agent.d.ts +0 -37
- package/prompts/agent.js +0 -125
- package/prompts/agent.js.map +0 -1
- package/prompts/cot.d.ts +0 -8
- package/prompts/cot.js +0 -17
- package/prompts/cot.js.map +0 -1
- package/prompts/index.d.ts +0 -3
- package/prompts/index.js +0 -4
- package/prompts/index.js.map +0 -1
- package/prompts/rag.d.ts +0 -23
- package/prompts/rag.js +0 -30
- package/prompts/rag.js.map +0 -1
- package/trace/index.d.ts +0 -171
- package/trace/index.js +0 -67
- package/trace/index.js.map +0 -1
- package/util/apicall.d.ts +0 -18
- package/util/apicall.js +0 -51
- package/util/apicall.js.map +0 -1
- package/util/log.d.ts +0 -14
- package/util/log.js +0 -31
- package/util/log.js.map +0 -1
- package/util/other.d.ts +0 -1
- package/util/other.js +0 -5
- package/util/other.js.map +0 -1
- package/util/rate-limit.d.ts +0 -24
- package/util/rate-limit.js +0 -49
- package/util/rate-limit.js.map +0 -1
- package/util/sse.d.ts +0 -12
- package/util/sse.js +0 -93
- package/util/sse.js.map +0 -1
- package/util/stream.d.ts +0 -9
- package/util/stream.js +0 -29
- package/util/stream.js.map +0 -1
- package/util/transform.d.ts +0 -4
- package/util/transform.js +0 -29
- package/util/transform.js.map +0 -1
package/docs/manager.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {} from '../index.js';
|
|
2
|
-
const table = '_internal';
|
|
3
|
-
export class AxDBManager {
|
|
4
|
-
ai;
|
|
5
|
-
db;
|
|
6
|
-
chunker;
|
|
7
|
-
rewriter;
|
|
8
|
-
reranker;
|
|
9
|
-
constructor({ ai, db, config }) {
|
|
10
|
-
this.ai = ai;
|
|
11
|
-
this.db = db;
|
|
12
|
-
this.chunker = config?.chunker ?? this.defaultChunker;
|
|
13
|
-
this.reranker = config?.reranker;
|
|
14
|
-
this.rewriter = config?.rewriter;
|
|
15
|
-
}
|
|
16
|
-
defaultChunker = (text) => {
|
|
17
|
-
// Default chunking by paragraphs
|
|
18
|
-
return text.split(/\n\n+/);
|
|
19
|
-
};
|
|
20
|
-
insert = async (text, options) => {
|
|
21
|
-
try {
|
|
22
|
-
const chunkerInput = Array.isArray(text)
|
|
23
|
-
? text.join('\n\n')
|
|
24
|
-
: text;
|
|
25
|
-
// Chunk the text using the specified or default chunking function
|
|
26
|
-
const initialChunks = this.chunker(chunkerInput).filter((chunk) => chunk.length > 0);
|
|
27
|
-
const maxWordsPerChunk = options?.maxWordsPerChunk;
|
|
28
|
-
const minWordsPerChunk = options?.minWordsPerChunk;
|
|
29
|
-
const chunks = processChunks({
|
|
30
|
-
initialChunks,
|
|
31
|
-
minWordsPerChunk,
|
|
32
|
-
maxWordsPerChunk
|
|
33
|
-
});
|
|
34
|
-
const bs = options?.batchSize ?? 10;
|
|
35
|
-
// Process chunks in batches of 10
|
|
36
|
-
for (let i = 0; i < chunks.length; i += bs) {
|
|
37
|
-
const batch = chunks.slice(i, i + bs);
|
|
38
|
-
// Get embeddings for the whole batch from the AI service in one call
|
|
39
|
-
const ret = await this.ai.embed({ texts: batch });
|
|
40
|
-
// Prepare batch for bulk upsert
|
|
41
|
-
const embeddings = ret.embeddings
|
|
42
|
-
.map((embedding, index) => ({
|
|
43
|
-
id: `chunk_${Date.now() + index}`, // Unique ID for each chunk, adjusted by index
|
|
44
|
-
table,
|
|
45
|
-
values: embedding,
|
|
46
|
-
metadata: { text: batch[index] ?? '' }
|
|
47
|
-
}))
|
|
48
|
-
.filter((v) => v.metadata?.['text'] && v.metadata?.['text'].length > 0);
|
|
49
|
-
// Batch upsert embeddings
|
|
50
|
-
await this.db.batchUpsert(embeddings);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
throw new Error(`Error processing text: ${error}`);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
query = async (query, { topPercent } = {}) => {
|
|
58
|
-
const texts = Array.isArray(query) ? query : [query];
|
|
59
|
-
if (typeof texts[0] === 'string' && this.rewriter) {
|
|
60
|
-
for (const [i, text] of texts.entries()) {
|
|
61
|
-
const { rewrittenQuery } = await this.rewriter.forward(this.ai, {
|
|
62
|
-
query: text
|
|
63
|
-
});
|
|
64
|
-
texts[i] = rewrittenQuery;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
let queries;
|
|
68
|
-
if (typeof texts[0] === 'string') {
|
|
69
|
-
const embedResults = await this.ai.embed({ texts });
|
|
70
|
-
queries = embedResults.embeddings.map((values) => this.db.query({ table, values }));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
queries = texts.map((values) => this.db.query({ table, values }));
|
|
74
|
-
}
|
|
75
|
-
const queryResults = await Promise.all(queries);
|
|
76
|
-
const res = [];
|
|
77
|
-
for (const { matches } of queryResults) {
|
|
78
|
-
const m = matches
|
|
79
|
-
.filter((v) => v.metadata?.['text'] && v.metadata?.['text'].length > 0)
|
|
80
|
-
.map(({ score, metadata }) => ({
|
|
81
|
-
score,
|
|
82
|
-
text: metadata?.['text'] ?? ''
|
|
83
|
-
}));
|
|
84
|
-
const tp = topPercent && topPercent > 1 ? topPercent / 100 : topPercent;
|
|
85
|
-
const resultItems = tp ? getTopInPercent(m, tp) : m;
|
|
86
|
-
if (this.reranker) {
|
|
87
|
-
const { rankedItems } = await this.reranker.forward(this.ai, {
|
|
88
|
-
query: texts[0],
|
|
89
|
-
items: resultItems.map((item) => item.text)
|
|
90
|
-
});
|
|
91
|
-
const items = rankedItems
|
|
92
|
-
.map((item) => resultItems.find((r) => r.text === item))
|
|
93
|
-
.filter((v) => v !== undefined);
|
|
94
|
-
res.push(items);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
res.push(resultItems);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return res;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const processChunks = ({ initialChunks, maxWordsPerChunk = 350, minWordsPerChunk = 250 }) => {
|
|
104
|
-
const chunks = [];
|
|
105
|
-
let currentChunk = '';
|
|
106
|
-
let currentWordCount = 0;
|
|
107
|
-
initialChunks.forEach((chunk) => {
|
|
108
|
-
const words = chunk.split(/\s+/); // Split the chunk into words
|
|
109
|
-
const wordCount = words.length; // Count words in the current chunk
|
|
110
|
-
if (currentWordCount + wordCount <= maxWordsPerChunk) {
|
|
111
|
-
// Add to the current chunk if within the max size limit
|
|
112
|
-
currentChunk += chunk + '\n\n';
|
|
113
|
-
currentWordCount += wordCount;
|
|
114
|
-
}
|
|
115
|
-
else if (currentWordCount > 0 &&
|
|
116
|
-
currentWordCount + wordCount <= maxWordsPerChunk * 1.5) {
|
|
117
|
-
// If the total word count exceeds the limit but is less than 150% of the maxWordsPerChunk
|
|
118
|
-
currentChunk += chunk + '\n\n';
|
|
119
|
-
currentWordCount += wordCount;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// If the current chunk is not empty and adding the new chunk exceeds the adjusted limit
|
|
123
|
-
if (currentWordCount > minWordsPerChunk) {
|
|
124
|
-
chunks.push(currentChunk.trim());
|
|
125
|
-
currentChunk = '';
|
|
126
|
-
currentWordCount = 0;
|
|
127
|
-
}
|
|
128
|
-
// Handle the case where the chunk itself is larger than the limit
|
|
129
|
-
if (wordCount > maxWordsPerChunk) {
|
|
130
|
-
const remainingWords = words;
|
|
131
|
-
while (remainingWords.length > maxWordsPerChunk * 1.5) {
|
|
132
|
-
const slice = remainingWords.splice(0, maxWordsPerChunk);
|
|
133
|
-
chunks.push(slice.join(' '));
|
|
134
|
-
}
|
|
135
|
-
// Add the last portion if it fits the condition of being within 150% of maxWordsPerChunk
|
|
136
|
-
if (remainingWords.length > 0) {
|
|
137
|
-
currentChunk += remainingWords.join(' ') + '\n\n';
|
|
138
|
-
currentWordCount += remainingWords.length;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
// If the new chunk is smaller than the maximum words per chunk
|
|
143
|
-
currentChunk = chunk + '\n\n';
|
|
144
|
-
currentWordCount = wordCount;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
// Push the last chunk if it exists and meets the minimum words condition
|
|
149
|
-
if (currentWordCount > minWordsPerChunk || chunks.length === 0) {
|
|
150
|
-
chunks.push(currentChunk.trim());
|
|
151
|
-
}
|
|
152
|
-
return chunks;
|
|
153
|
-
};
|
|
154
|
-
const getTopInPercent = (entries, percent = 0.1) => {
|
|
155
|
-
// Sort entries by score in ascending order
|
|
156
|
-
const sortedEntries = [...entries].sort((a, b) => a.score - b.score);
|
|
157
|
-
// Calculate the number of entries to take (top 10%)
|
|
158
|
-
const topTenPercentCount = Math.ceil(sortedEntries.length * percent);
|
|
159
|
-
// Return the top 10% of entries
|
|
160
|
-
return sortedEntries.slice(0, topTenPercentCount);
|
|
161
|
-
};
|
|
162
|
-
//# sourceMappingURL=manager.js.map
|
package/docs/manager.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../docs/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,aAAa,CAAC;AAyBrB,MAAM,KAAK,GAAG,WAAW,CAAC;AAE1B,MAAM,OAAO,WAAW;IACd,EAAE,CAAc;IAChB,EAAE,CA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reranker.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AxAIService } from '../ai/types.js';
|
|
2
|
-
import { AxGen, type AxGenOptions, type AxProgramForwardOptions } from '../dsp/index.js';
|
|
3
|
-
import type { AxRerankerIn, AxRerankerOut } from './manager.js';
|
|
4
|
-
export declare class AxDefaultResultReranker extends AxGen<AxRerankerIn, AxRerankerOut> {
|
|
5
|
-
constructor(options?: Readonly<AxGenOptions>);
|
|
6
|
-
forward: (ai: Readonly<AxAIService>, input: Readonly<AxRerankerIn>, options?: Readonly<AxProgramForwardOptions>) => Promise<AxRerankerOut>;
|
|
7
|
-
}
|
package/docs/reranker.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AxGen, axStringUtil } from '../dsp/index.js';
|
|
2
|
-
export class AxDefaultResultReranker extends AxGen {
|
|
3
|
-
constructor(options) {
|
|
4
|
-
const signature = `"You are a re-ranker assistant tasked with evaluating a set of content items in relation to a specific question. Your role involves critically analyzing each content item to determine its relevance to the question and re-ranking them accordingly. This process includes assigning a relevance score from 0 to 10 to each content item based on how well it answers the question, its coverage of the topic, and the reliability of its information. This re-ranked list should start with the content item that is most relevant to the question and end with the least relevant. Output only the list."
|
|
5
|
-
query: string, items: string[] -> rankedItems: string[] "list of id, 5-words Rationale, relevance score"`;
|
|
6
|
-
super(signature, options);
|
|
7
|
-
}
|
|
8
|
-
forward = async (ai, input, options) => {
|
|
9
|
-
const { rankedItems } = await super.forward(ai, input, options);
|
|
10
|
-
const sortedIndexes = rankedItems.map((item) => {
|
|
11
|
-
const { id: index } = axStringUtil.extractIdAndText(item);
|
|
12
|
-
return index;
|
|
13
|
-
});
|
|
14
|
-
// Ensure all elements are strings and filter out null or undefined
|
|
15
|
-
const sortedItems = input.items
|
|
16
|
-
.map((_, index) => {
|
|
17
|
-
const originalIndex = sortedIndexes[index];
|
|
18
|
-
return originalIndex !== undefined
|
|
19
|
-
? input.items[originalIndex]
|
|
20
|
-
: undefined;
|
|
21
|
-
})
|
|
22
|
-
.filter((item) => item !== undefined);
|
|
23
|
-
return { rankedItems: sortedItems };
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=reranker.js.map
|
package/docs/reranker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reranker.js","sourceRoot":"","sources":["../../docs/reranker.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAGL,YAAY,EACb,MAAM,iBAAiB,CAAC;AAIzB,MAAM,OAAO,uBAAwB,SAAQ,KAG5C;IACC,YAAY,OAAgC;QAC1C,MAAM,SAAS,GAAG;6GACuF,CAAC;QAE1G,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IAEe,OAAO,GAAG,KAAK,EAC7B,EAAyB,EACzB,KAA6B,EAC7B,OAA2C,EACnB,EAAE;QAC1B,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAEhE,MAAM,aAAa,GAAa,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACvD,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,mEAAmE;QACnE,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK;aAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAChB,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,aAAa,KAAK,SAAS;gBAChC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC;gBAC5B,CAAC,CAAC,SAAS,CAAC;QAChB,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAExD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;IACtC,CAAC,CAAC;CACH"}
|
package/docs/rewriter.d.ts
DELETED
package/docs/rewriter.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxGen } from '../index.js';
|
|
2
|
-
export class AxDefaultQueryRewriter extends AxGen {
|
|
3
|
-
constructor(options) {
|
|
4
|
-
const signature = `"You are a query rewriter assistant tasked with rewriting a given query to improve its clarity, specificity, and relevance. Your role involves analyzing the query to identify any ambiguities, generalizations, or irrelevant information and then rephrasing it to make it more focused and precise. The rewritten query should be concise, easy to understand, and directly related to the original query. Output only the rewritten query."
|
|
5
|
-
query: string -> rewrittenQuery: string`;
|
|
6
|
-
super(signature, options);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=rewriter.js.map
|
package/docs/rewriter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rewriter.js","sourceRoot":"","sources":["../../docs/rewriter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAIN,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,sBAAuB,SAAQ,KAAgC;IAC1E,YAAY,OAAgC;QAC1C,MAAM,SAAS,GAAG;4CACsB,CAAC;QAEzC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
package/docs/tika.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface AxApacheTikaArgs {
|
|
2
|
-
url?: string | URL;
|
|
3
|
-
fetch?: typeof fetch;
|
|
4
|
-
}
|
|
5
|
-
export interface AxApacheTikaConvertOptions {
|
|
6
|
-
format?: 'text' | 'html';
|
|
7
|
-
}
|
|
8
|
-
export declare class AxApacheTika {
|
|
9
|
-
private tikaUrl;
|
|
10
|
-
private fetch?;
|
|
11
|
-
constructor(args?: Readonly<AxApacheTikaArgs>);
|
|
12
|
-
private _convert;
|
|
13
|
-
convert(files: Readonly<string[] | Blob[]>, options?: Readonly<{
|
|
14
|
-
batchSize?: number;
|
|
15
|
-
format?: 'html' | 'text';
|
|
16
|
-
}>): Promise<string[]>;
|
|
17
|
-
}
|
|
18
|
-
export default AxApacheTika;
|
package/docs/tika.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from 'node:fs';
|
|
2
|
-
export class AxApacheTika {
|
|
3
|
-
tikaUrl;
|
|
4
|
-
fetch;
|
|
5
|
-
constructor(args) {
|
|
6
|
-
const _args = args ?? { url: 'http://localhost:9998/' };
|
|
7
|
-
this.tikaUrl = new URL('/tika', _args.url);
|
|
8
|
-
this.fetch = _args.fetch;
|
|
9
|
-
}
|
|
10
|
-
async _convert(file, options) {
|
|
11
|
-
const fileData = typeof file === 'string' ? createReadStream(file) : file.stream();
|
|
12
|
-
if (!fileData) {
|
|
13
|
-
throw new Error('Failed to read file data');
|
|
14
|
-
}
|
|
15
|
-
const acceptValue = options?.format === 'html' ? 'text/html' : 'text/plain';
|
|
16
|
-
try {
|
|
17
|
-
const res = await (this.fetch ?? fetch)(this.tikaUrl, {
|
|
18
|
-
body: fileData,
|
|
19
|
-
headers: { Accept: acceptValue },
|
|
20
|
-
duplex: 'half',
|
|
21
|
-
method: 'PUT'
|
|
22
|
-
});
|
|
23
|
-
if (!res.ok) {
|
|
24
|
-
throw new Error(`Failed to upload file: ${res.statusText}`);
|
|
25
|
-
}
|
|
26
|
-
const text = await res.text();
|
|
27
|
-
return text;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
throw new Error(`Error converting file: ${error}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async convert(files, options) {
|
|
34
|
-
const results = [];
|
|
35
|
-
const bs = options?.batchSize ?? 10;
|
|
36
|
-
for (let i = 0; i < files.length; i += bs) {
|
|
37
|
-
const batch = files.slice(i, i + bs);
|
|
38
|
-
const uploadPromises = batch.map((files) => this._convert(files, { format: options?.format }));
|
|
39
|
-
const batchResults = await Promise.all(uploadPromises);
|
|
40
|
-
results.push(...batchResults);
|
|
41
|
-
}
|
|
42
|
-
return results;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export default AxApacheTika;
|
|
46
|
-
//# sourceMappingURL=tika.js.map
|
package/docs/tika.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tika.js","sourceRoot":"","sources":["../../docs/tika.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAW3C,MAAM,OAAO,YAAY;IACf,OAAO,CAAM;IACb,KAAK,CAAgB;IAE7B,YAAY,IAAiC;QAC3C,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,GAAG,EAAE,wBAAwB,EAAE,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,QAAQ,CACpB,IAAmB,EACnB,OAA8C;QAE9C,MAAM,QAAQ,GACZ,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAEpE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;QAE5E,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpD,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ED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { extractionState } from './extract.js';
|
|
2
|
-
import type { AxSignature } from './sig.js';
|
|
3
|
-
export interface AxAssertion {
|
|
4
|
-
fn(values: Record<string, unknown>): boolean | undefined;
|
|
5
|
-
message?: string;
|
|
6
|
-
optional?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface AxStreamingAssertion {
|
|
9
|
-
fieldName: string;
|
|
10
|
-
fn(content: string, done?: boolean): boolean | undefined;
|
|
11
|
-
message?: string;
|
|
12
|
-
optional?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class AxAssertionError extends Error {
|
|
15
|
-
private values;
|
|
16
|
-
private optional?;
|
|
17
|
-
constructor({ message, values, optional }: Readonly<{
|
|
18
|
-
message: string;
|
|
19
|
-
values: Record<string, unknown>;
|
|
20
|
-
optional?: boolean;
|
|
21
|
-
}>);
|
|
22
|
-
getValue: () => Record<string, unknown>;
|
|
23
|
-
getOptional: () => boolean | undefined;
|
|
24
|
-
getFixingInstructions: (_sig: Readonly<AxSignature>) => {
|
|
25
|
-
name: string;
|
|
26
|
-
title: string;
|
|
27
|
-
description: string;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
export declare const assertAssertions: (asserts: readonly AxAssertion[], values: Record<string, unknown>) => void;
|
|
31
|
-
export declare const assertStreamingAssertions: (asserts: readonly AxStreamingAssertion[], values: Record<string, unknown>, xstate: Readonly<extractionState>, content: string, final: boolean) => void;
|
|
32
|
-
export declare const assertRequiredFields: (sig: Readonly<AxSignature>, values: Record<string, unknown>) => void;
|
package/dsp/asserts.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
export class AxAssertionError extends Error {
|
|
2
|
-
values;
|
|
3
|
-
optional;
|
|
4
|
-
constructor({ message, values, optional }) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.values = values;
|
|
7
|
-
this.optional = optional;
|
|
8
|
-
this.name = this.constructor.name;
|
|
9
|
-
this.stack = new Error().stack;
|
|
10
|
-
}
|
|
11
|
-
getValue = () => this.values;
|
|
12
|
-
getOptional = () => this.optional;
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
-
getFixingInstructions = (_sig) => {
|
|
15
|
-
const extraFields = [];
|
|
16
|
-
// for (const f of sig.getOutputFields()) {
|
|
17
|
-
// extraFields.push({
|
|
18
|
-
// name: `past_${f.name}`,
|
|
19
|
-
// title: `Past ${f.title}`,
|
|
20
|
-
// description: JSON.stringify(this.values[f.name])
|
|
21
|
-
// });
|
|
22
|
-
// }
|
|
23
|
-
extraFields.push({
|
|
24
|
-
name: 'instructions',
|
|
25
|
-
title: 'Instructions',
|
|
26
|
-
description: this.message
|
|
27
|
-
});
|
|
28
|
-
return extraFields;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
32
|
-
export const assertAssertions = (asserts, values) => {
|
|
33
|
-
for (const assert of asserts) {
|
|
34
|
-
const { fn, message, optional } = assert;
|
|
35
|
-
try {
|
|
36
|
-
const res = fn(values);
|
|
37
|
-
if (res === undefined) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (!res && message) {
|
|
41
|
-
throw new AxAssertionError({ message, values, optional });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
const message = e.message;
|
|
46
|
-
throw new AxAssertionError({ message, values, optional });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
51
|
-
export const assertStreamingAssertions = (asserts, values, xstate, content, final) => {
|
|
52
|
-
if (!xstate.currField ||
|
|
53
|
-
xstate.s === -1 ||
|
|
54
|
-
!asserts ||
|
|
55
|
-
asserts.length === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const fieldAsserts = asserts.filter((a) => a.fieldName === xstate.currField?.name);
|
|
59
|
-
if (fieldAsserts.length === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const currValue = content.substring(xstate.s);
|
|
63
|
-
for (const assert of fieldAsserts) {
|
|
64
|
-
const { message, optional, fn } = assert;
|
|
65
|
-
try {
|
|
66
|
-
const res = fn(currValue, final);
|
|
67
|
-
if (res === undefined) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (!res && message) {
|
|
71
|
-
throw new AxAssertionError({ message, values, optional });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
const message = e.message;
|
|
76
|
-
throw new AxAssertionError({ message, values, optional });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
81
|
-
export const assertRequiredFields = (sig, values) => {
|
|
82
|
-
const fields = sig.getOutputFields();
|
|
83
|
-
const missingFields = fields.filter((f) => !(f.name in values));
|
|
84
|
-
if (missingFields.length > 0) {
|
|
85
|
-
throw new AxAssertionError({
|
|
86
|
-
message: `Output must include: ${missingFields.map((f) => `\`${f.title}:\``).join(', ')}`,
|
|
87
|
-
values
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=asserts.js.map
|
package/dsp/asserts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../dsp/asserts.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,MAAM,CAA0B;IAChC,QAAQ,CAAW;IAE3B,YAAY,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EAKR;QACA,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CA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OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,gEAAgE;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAA0B,EAC1B,MAA+B,EAC/B,EAAE;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;IACrC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC;IAChE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,gBAAgB,CAAC;YACzB,OAAO,EAAE,wBAAwB,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACzF,MAAM;SACP,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
package/dsp/datetime.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AxField } from './sig.js';
|
|
2
|
-
export declare function parseLLMFriendlyDate(field: Readonly<AxField>, dateStr: string): Date;
|
|
3
|
-
export declare function parseLLMFriendlyDateTime(field: Readonly<AxField>, dateStr: string): Date;
|
|
4
|
-
export declare const formatDateWithTimezone: (date: Readonly<Date>) => string;
|
package/dsp/datetime.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import moment from 'moment-timezone';
|
|
2
|
-
import { AxValidationError } from './validate.js';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4
|
-
export function parseLLMFriendlyDate(field, dateStr) {
|
|
5
|
-
try {
|
|
6
|
-
return _parseLLMFriendlyDate(dateStr);
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
const message = err.message;
|
|
10
|
-
throw new AxValidationError({ field, message, value: dateStr });
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function _parseLLMFriendlyDate(dateStr) {
|
|
14
|
-
// Validate the date string format
|
|
15
|
-
if (!moment(dateStr, 'YYYY-MM-DD', true).isValid()) {
|
|
16
|
-
throw new Error('Invalid date format. Please provide the date in "YYYY-MM-DD" format.');
|
|
17
|
-
}
|
|
18
|
-
// Parse the date and create a UTC moment object at midnight
|
|
19
|
-
const date = moment.utc(dateStr, 'YYYY-MM-DD').startOf('day');
|
|
20
|
-
return date.toDate();
|
|
21
|
-
}
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
23
|
-
export function parseLLMFriendlyDateTime(field, dateStr) {
|
|
24
|
-
try {
|
|
25
|
-
return _parseLLMFriendlyDateTime(dateStr);
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
const message = err.message;
|
|
29
|
-
throw new AxValidationError({ field, message, value: dateStr });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function _parseLLMFriendlyDateTime(dateTimeStr) {
|
|
33
|
-
// Validate the date and time string format
|
|
34
|
-
const dateTimeRegex = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?) (.+)$/;
|
|
35
|
-
const match = dateTimeStr.match(dateTimeRegex);
|
|
36
|
-
if (!match) {
|
|
37
|
-
throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');
|
|
38
|
-
}
|
|
39
|
-
const [, dateTime, timeZone] = match;
|
|
40
|
-
if (!dateTime || !timeZone) {
|
|
41
|
-
throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');
|
|
42
|
-
}
|
|
43
|
-
// Try to parse the timezone
|
|
44
|
-
const zone = moment.tz.zone(timeZone);
|
|
45
|
-
// If still not found, throw an error
|
|
46
|
-
if (!zone) {
|
|
47
|
-
throw new Error(`Unrecognized time zone ${timeZone}. Please provide a valid time zone name, abbreviation, or offset. For example, "America/New_York", or "EST".`);
|
|
48
|
-
}
|
|
49
|
-
// Parse the date and time in the specified time zone
|
|
50
|
-
const date = moment.tz(dateTime, ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD HH:mm:ss'], zone.name);
|
|
51
|
-
// Check if the date and time are valid
|
|
52
|
-
if (!date.isValid()) {
|
|
53
|
-
throw new Error('Invalid date and time values. Please ensure all components are correct.');
|
|
54
|
-
}
|
|
55
|
-
// Convert to UTC
|
|
56
|
-
return date.utc().toDate();
|
|
57
|
-
}
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
59
|
-
export const formatDateWithTimezone = (date) => {
|
|
60
|
-
const momentDate = moment(date).utc();
|
|
61
|
-
return momentDate.format(`YYYY-MM-DD HH:mm:ss UTC`);
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=datetime.js.map
|
package/dsp/datetime.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","sourceRoot":"","sources":["../../dsp/datetime.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAClC,KAAwB,EACxB,OAAe;IAEf,IAAI,CAAC;QACH,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAI,GAAa,CAAC,OAAO,CAAC;QACvC,MAAM,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAe;IAC5C,kCAAkC;IAClC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,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,0BAA0B,QAAQ,8GAA8G,CACjJ,CAAC;IACJ,CAAC;IAED,qDAAqD;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CACpB,QAAQ,EACR,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,EAC3C,IAAI,CAAC,IAAI,CACV,CAAC;IAEF,uCAAuC;IACvC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;IACJ,CAAC;IAED,iBAAiB;IACjB,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAoB,EAAE,EAAE;IAC7D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IACtC,OAAO,UAAU,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AACtD,CAAC,CAAC"}
|
package/dsp/eval.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculates the Exact Match (EM) score between a prediction and ground truth.
|
|
3
|
-
*
|
|
4
|
-
* The EM score is a strict metric used in machine learning to assess if the predicted
|
|
5
|
-
* answer matches the ground truth exactly, commonly used in tasks like question answering.
|
|
6
|
-
*
|
|
7
|
-
* @param prediction The predicted text.
|
|
8
|
-
* @param groundTruth The actual correct text.
|
|
9
|
-
* @returns A boolean indicating if the prediction exactly matches the ground truth.
|
|
10
|
-
*/
|
|
11
|
-
declare function emScore(prediction: string, groundTruth: string): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Calculates the F1 score between a prediction and ground truth.
|
|
14
|
-
*
|
|
15
|
-
* The F1 score is a harmonic mean of precision and recall, widely used in NLP to measure
|
|
16
|
-
* a model's accuracy in considering both false positives and false negatives, offering a
|
|
17
|
-
* balance for evaluating classification models.
|
|
18
|
-
*
|
|
19
|
-
* @param prediction The predicted text.
|
|
20
|
-
* @param groundTruth The actual correct text.
|
|
21
|
-
* @returns The F1 score as a number.
|
|
22
|
-
*/
|
|
23
|
-
declare function f1Score(prediction: string, groundTruth: string): number;
|
|
24
|
-
/**
|
|
25
|
-
* Calculates a novel F1 score, taking into account a history of interaction and excluding stopwords.
|
|
26
|
-
*
|
|
27
|
-
* This metric extends the F1 score by considering contextual relevance and filtering out common words
|
|
28
|
-
* that might skew the assessment of the prediction's quality, especially in conversational models or
|
|
29
|
-
* when historical context is relevant.
|
|
30
|
-
*
|
|
31
|
-
* @param history The historical context or preceding interactions.
|
|
32
|
-
* @param prediction The predicted text.
|
|
33
|
-
* @param groundTruth The actual correct text.
|
|
34
|
-
* @param returnRecall Optionally return the recall score instead of F1.
|
|
35
|
-
* @returns The novel F1 or recall score as a number.
|
|
36
|
-
*/
|
|
37
|
-
declare function novelF1ScoreOptimized(history: string, prediction: string, groundTruth: string, returnRecall?: boolean): number;
|
|
38
|
-
export declare const axEvalUtil: {
|
|
39
|
-
emScore: typeof emScore;
|
|
40
|
-
f1Score: typeof f1Score;
|
|
41
|
-
novelF1ScoreOptimized: typeof novelF1ScoreOptimized;
|
|
42
|
-
};
|
|
43
|
-
export {};
|