@ax-llm/ax 9.0.20 → 9.0.22
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/ai/anthropic/api.d.ts +19 -0
- package/ai/anthropic/api.js +326 -0
- package/ai/anthropic/api.js.map +1 -0
- package/ai/anthropic/index.d.ts +2 -0
- package/ai/anthropic/index.js +3 -0
- package/ai/anthropic/index.js.map +1 -0
- package/ai/anthropic/info.d.ts +2 -0
- package/ai/anthropic/info.js +40 -0
- package/ai/anthropic/info.js.map +1 -0
- package/ai/anthropic/types.d.ts +171 -0
- package/ai/anthropic/types.js +10 -0
- package/ai/anthropic/types.js.map +1 -0
- package/ai/azure-openai/api.d.ts +19 -0
- package/ai/azure-openai/api.js +30 -0
- package/ai/azure-openai/api.js.map +1 -0
- package/ai/azure-openai/index.d.ts +1 -0
- package/ai/azure-openai/index.js +2 -0
- package/ai/azure-openai/index.js.map +1 -0
- package/ai/balance.d.ts +23 -0
- package/ai/balance.js +87 -0
- package/ai/balance.js.map +1 -0
- package/ai/base.d.ts +55 -0
- package/ai/base.js +343 -0
- package/ai/base.js.map +1 -0
- package/ai/cohere/api.d.ts +22 -0
- package/ai/cohere/api.js +264 -0
- package/ai/cohere/api.js.map +1 -0
- package/ai/cohere/index.d.ts +2 -0
- package/ai/cohere/index.js +3 -0
- package/ai/cohere/index.js.map +1 -0
- package/ai/cohere/info.d.ts +2 -0
- package/ai/cohere/info.js +52 -0
- package/ai/cohere/info.js.map +1 -0
- package/ai/cohere/types.d.ts +102 -0
- package/ai/cohere/types.js +23 -0
- package/ai/cohere/types.js.map +1 -0
- package/ai/deepseek/api.d.ts +16 -0
- package/ai/deepseek/api.js +32 -0
- package/ai/deepseek/api.js.map +1 -0
- package/ai/deepseek/index.d.ts +2 -0
- package/ai/deepseek/index.js +3 -0
- package/ai/deepseek/index.js.map +1 -0
- package/ai/deepseek/info.d.ts +2 -0
- package/ai/deepseek/info.js +16 -0
- package/ai/deepseek/info.js.map +1 -0
- package/ai/deepseek/types.d.ts +8 -0
- package/ai/deepseek/types.js +10 -0
- package/ai/deepseek/types.js.map +1 -0
- package/ai/google-gemini/api.d.ts +36 -0
- package/ai/google-gemini/api.js +299 -0
- package/ai/google-gemini/api.js.map +1 -0
- package/ai/google-gemini/index.d.ts +2 -0
- package/ai/google-gemini/index.js +3 -0
- package/ai/google-gemini/index.js.map +1 -0
- package/ai/google-gemini/info.d.ts +6 -0
- package/ai/google-gemini/info.js +29 -0
- package/ai/google-gemini/info.js.map +1 -0
- package/ai/google-gemini/types.d.ts +146 -0
- package/ai/google-gemini/types.js +27 -0
- package/ai/google-gemini/types.js.map +1 -0
- package/ai/groq/api.d.ts +18 -0
- package/ai/groq/api.js +52 -0
- package/ai/groq/api.js.map +1 -0
- package/ai/groq/index.d.ts +1 -0
- package/ai/groq/index.js +2 -0
- package/ai/groq/index.js.map +1 -0
- package/ai/groq/types.d.ts +6 -0
- package/ai/groq/types.js +8 -0
- package/ai/groq/types.js.map +1 -0
- package/ai/huggingface/api.d.ts +19 -0
- package/ai/huggingface/api.js +115 -0
- package/ai/huggingface/api.js.map +1 -0
- package/ai/huggingface/index.d.ts +2 -0
- package/ai/huggingface/index.js +3 -0
- package/ai/huggingface/index.js.map +1 -0
- package/ai/huggingface/info.d.ts +6 -0
- package/ai/huggingface/info.js +6 -0
- package/ai/huggingface/info.js.map +1 -0
- package/ai/huggingface/types.d.ts +34 -0
- package/ai/huggingface/types.js +5 -0
- package/ai/huggingface/types.js.map +1 -0
- package/ai/index.d.ts +16 -0
- package/ai/index.js +16 -0
- package/ai/index.js.map +1 -0
- package/ai/mistral/api.d.ts +16 -0
- package/ai/mistral/api.js +32 -0
- package/ai/mistral/api.js.map +1 -0
- package/ai/mistral/index.d.ts +2 -0
- package/ai/mistral/index.js +3 -0
- package/ai/mistral/index.js.map +1 -0
- package/ai/mistral/info.d.ts +2 -0
- package/ai/mistral/info.js +34 -0
- package/ai/mistral/info.js.map +1 -0
- package/ai/mistral/types.d.ts +10 -0
- package/ai/mistral/types.js +13 -0
- package/ai/mistral/types.js.map +1 -0
- package/ai/ollama/api.d.ts +22 -0
- package/ai/ollama/api.js +32 -0
- package/ai/ollama/api.js.map +1 -0
- package/ai/ollama/index.d.ts +1 -0
- package/ai/ollama/index.js +2 -0
- package/ai/ollama/index.js.map +1 -0
- package/ai/openai/api.d.ts +29 -0
- package/ai/openai/api.js +283 -0
- package/ai/openai/api.js.map +1 -0
- package/ai/openai/index.d.ts +2 -0
- package/ai/openai/index.js +3 -0
- package/ai/openai/index.js.map +1 -0
- package/ai/openai/info.d.ts +6 -0
- package/ai/openai/info.js +50 -0
- package/ai/openai/info.js.map +1 -0
- package/ai/openai/types.d.ts +165 -0
- package/ai/openai/types.js +18 -0
- package/ai/openai/types.js.map +1 -0
- package/ai/together/api.d.ts +15 -0
- package/ai/together/api.js +28 -0
- package/ai/together/api.js.map +1 -0
- package/ai/together/index.d.ts +1 -0
- package/ai/together/index.js +2 -0
- package/ai/together/index.js.map +1 -0
- package/ai/together/info.d.ts +2 -0
- package/ai/together/info.js +2 -0
- package/ai/together/info.js.map +1 -0
- package/ai/types.d.ts +159 -0
- package/ai/types.js +2 -0
- package/ai/types.js.map +1 -0
- package/ai/util.d.ts +12 -0
- package/ai/util.js +63 -0
- package/ai/util.js.map +1 -0
- package/ai/wrap.d.ts +47 -0
- package/ai/wrap.js +95 -0
- package/ai/wrap.js.map +1 -0
- package/cjs/ai/anthropic/api.d.ts +19 -0
- package/cjs/ai/anthropic/api.js +331 -0
- package/cjs/ai/anthropic/api.js.map +1 -0
- package/cjs/ai/anthropic/index.d.ts +2 -0
- package/cjs/ai/anthropic/index.js +19 -0
- package/cjs/ai/anthropic/index.js.map +1 -0
- package/cjs/ai/anthropic/info.d.ts +2 -0
- package/cjs/ai/anthropic/info.js +43 -0
- package/cjs/ai/anthropic/info.js.map +1 -0
- package/cjs/ai/anthropic/types.d.ts +171 -0
- package/cjs/ai/anthropic/types.js +13 -0
- package/cjs/ai/anthropic/types.js.map +1 -0
- package/cjs/ai/azure-openai/api.d.ts +19 -0
- package/cjs/ai/azure-openai/api.js +34 -0
- package/cjs/ai/azure-openai/api.js.map +1 -0
- package/cjs/ai/azure-openai/index.d.ts +1 -0
- package/cjs/ai/azure-openai/index.js +18 -0
- package/cjs/ai/azure-openai/index.js.map +1 -0
- package/cjs/ai/balance.d.ts +23 -0
- package/cjs/ai/balance.js +91 -0
- package/cjs/ai/balance.js.map +1 -0
- package/cjs/ai/base.d.ts +55 -0
- package/cjs/ai/base.js +349 -0
- package/cjs/ai/base.js.map +1 -0
- package/cjs/ai/cohere/api.d.ts +22 -0
- package/cjs/ai/cohere/api.js +270 -0
- package/cjs/ai/cohere/api.js.map +1 -0
- package/cjs/ai/cohere/index.d.ts +2 -0
- package/cjs/ai/cohere/index.js +19 -0
- package/cjs/ai/cohere/index.js.map +1 -0
- package/cjs/ai/cohere/info.d.ts +2 -0
- package/cjs/ai/cohere/info.js +55 -0
- package/cjs/ai/cohere/info.js.map +1 -0
- package/cjs/ai/cohere/types.d.ts +102 -0
- package/cjs/ai/cohere/types.js +26 -0
- package/cjs/ai/cohere/types.js.map +1 -0
- package/cjs/ai/deepseek/api.d.ts +16 -0
- package/cjs/ai/deepseek/api.js +38 -0
- package/cjs/ai/deepseek/api.js.map +1 -0
- package/cjs/ai/deepseek/index.d.ts +2 -0
- package/cjs/ai/deepseek/index.js +19 -0
- package/cjs/ai/deepseek/index.js.map +1 -0
- package/cjs/ai/deepseek/info.d.ts +2 -0
- package/cjs/ai/deepseek/info.js +19 -0
- package/cjs/ai/deepseek/info.js.map +1 -0
- package/cjs/ai/deepseek/types.d.ts +8 -0
- package/cjs/ai/deepseek/types.js +13 -0
- package/cjs/ai/deepseek/types.js.map +1 -0
- package/cjs/ai/google-gemini/api.d.ts +36 -0
- package/cjs/ai/google-gemini/api.js +305 -0
- package/cjs/ai/google-gemini/api.js.map +1 -0
- package/cjs/ai/google-gemini/index.d.ts +2 -0
- package/cjs/ai/google-gemini/index.js +19 -0
- package/cjs/ai/google-gemini/index.js.map +1 -0
- package/cjs/ai/google-gemini/info.d.ts +6 -0
- package/cjs/ai/google-gemini/info.js +32 -0
- package/cjs/ai/google-gemini/info.js.map +1 -0
- package/cjs/ai/google-gemini/types.d.ts +146 -0
- package/cjs/ai/google-gemini/types.js +30 -0
- package/cjs/ai/google-gemini/types.js.map +1 -0
- package/cjs/ai/groq/api.d.ts +18 -0
- package/cjs/ai/groq/api.js +56 -0
- package/cjs/ai/groq/api.js.map +1 -0
- package/cjs/ai/groq/index.d.ts +1 -0
- package/cjs/ai/groq/index.js +18 -0
- package/cjs/ai/groq/index.js.map +1 -0
- package/cjs/ai/groq/types.d.ts +6 -0
- package/cjs/ai/groq/types.js +11 -0
- package/cjs/ai/groq/types.js.map +1 -0
- package/cjs/ai/huggingface/api.d.ts +19 -0
- package/cjs/ai/huggingface/api.js +121 -0
- package/cjs/ai/huggingface/api.js.map +1 -0
- package/cjs/ai/huggingface/index.d.ts +2 -0
- package/cjs/ai/huggingface/index.js +19 -0
- package/cjs/ai/huggingface/index.js.map +1 -0
- package/cjs/ai/huggingface/info.d.ts +6 -0
- package/cjs/ai/huggingface/info.js +9 -0
- package/cjs/ai/huggingface/info.js.map +1 -0
- package/cjs/ai/huggingface/types.d.ts +34 -0
- package/cjs/ai/huggingface/types.js +8 -0
- package/cjs/ai/huggingface/types.js.map +1 -0
- package/cjs/ai/index.d.ts +16 -0
- package/cjs/ai/index.js +32 -0
- package/cjs/ai/index.js.map +1 -0
- package/cjs/ai/mistral/api.d.ts +16 -0
- package/cjs/ai/mistral/api.js +38 -0
- package/cjs/ai/mistral/api.js.map +1 -0
- package/cjs/ai/mistral/index.d.ts +2 -0
- package/cjs/ai/mistral/index.js +19 -0
- package/cjs/ai/mistral/index.js.map +1 -0
- package/cjs/ai/mistral/info.d.ts +2 -0
- package/cjs/ai/mistral/info.js +37 -0
- package/cjs/ai/mistral/info.js.map +1 -0
- package/cjs/ai/mistral/types.d.ts +10 -0
- package/cjs/ai/mistral/types.js +16 -0
- package/cjs/ai/mistral/types.js.map +1 -0
- package/cjs/ai/ollama/api.d.ts +22 -0
- package/cjs/ai/ollama/api.js +38 -0
- package/cjs/ai/ollama/api.js.map +1 -0
- package/cjs/ai/ollama/index.d.ts +1 -0
- package/cjs/ai/ollama/index.js +18 -0
- package/cjs/ai/ollama/index.js.map +1 -0
- package/cjs/ai/openai/api.d.ts +29 -0
- package/cjs/ai/openai/api.js +291 -0
- package/cjs/ai/openai/api.js.map +1 -0
- package/cjs/ai/openai/index.d.ts +2 -0
- package/cjs/ai/openai/index.js +19 -0
- package/cjs/ai/openai/index.js.map +1 -0
- package/cjs/ai/openai/info.d.ts +6 -0
- package/cjs/ai/openai/info.js +53 -0
- package/cjs/ai/openai/info.js.map +1 -0
- package/cjs/ai/openai/types.d.ts +165 -0
- package/cjs/ai/openai/types.js +21 -0
- package/cjs/ai/openai/types.js.map +1 -0
- package/cjs/ai/together/api.d.ts +15 -0
- package/cjs/ai/together/api.js +33 -0
- package/cjs/ai/together/api.js.map +1 -0
- package/cjs/ai/together/index.d.ts +1 -0
- package/cjs/ai/together/index.js +18 -0
- package/cjs/ai/together/index.js.map +1 -0
- package/cjs/ai/together/info.d.ts +2 -0
- package/cjs/ai/together/info.js +5 -0
- package/cjs/ai/together/info.js.map +1 -0
- package/cjs/ai/types.d.ts +159 -0
- package/cjs/ai/types.js +3 -0
- package/cjs/ai/types.js.map +1 -0
- package/cjs/ai/util.d.ts +12 -0
- package/cjs/ai/util.js +71 -0
- package/cjs/ai/util.js.map +1 -0
- package/cjs/ai/wrap.d.ts +47 -0
- package/cjs/ai/wrap.js +99 -0
- package/cjs/ai/wrap.js.map +1 -0
- package/cjs/db/base.d.ts +23 -0
- package/cjs/db/base.js +91 -0
- package/cjs/db/base.js.map +1 -0
- package/cjs/db/cloudflare.d.ts +21 -0
- package/cjs/db/cloudflare.js +102 -0
- package/cjs/db/cloudflare.js.map +1 -0
- package/cjs/db/index.d.ts +6 -0
- package/cjs/db/index.js +23 -0
- package/cjs/db/index.js.map +1 -0
- package/cjs/db/memory.d.ts +21 -0
- package/cjs/db/memory.js +103 -0
- package/cjs/db/memory.js.map +1 -0
- package/cjs/db/pinecone.d.ts +21 -0
- package/cjs/db/pinecone.js +75 -0
- package/cjs/db/pinecone.js.map +1 -0
- package/cjs/db/types.d.ts +35 -0
- package/cjs/db/types.js +4 -0
- package/cjs/db/types.js.map +1 -0
- package/cjs/db/weaviate.d.ts +21 -0
- package/cjs/db/weaviate.js +131 -0
- package/cjs/db/weaviate.js.map +1 -0
- package/cjs/db/wrap.d.ts +13 -0
- package/cjs/db/wrap.js +39 -0
- package/cjs/db/wrap.js.map +1 -0
- package/cjs/docs/index.d.ts +4 -0
- package/cjs/docs/index.js +21 -0
- package/cjs/docs/index.js.map +1 -0
- package/cjs/docs/manager.d.ts +45 -0
- package/cjs/docs/manager.js +162 -0
- package/cjs/docs/manager.js.map +1 -0
- package/cjs/docs/reranker.d.ts +7 -0
- package/cjs/docs/reranker.js +30 -0
- package/cjs/docs/reranker.js.map +1 -0
- package/cjs/docs/rewriter.d.ts +4 -0
- package/cjs/docs/rewriter.js +13 -0
- package/cjs/docs/rewriter.js.map +1 -0
- package/cjs/docs/tika.d.ts +18 -0
- package/cjs/docs/tika.js +50 -0
- package/cjs/docs/tika.js.map +1 -0
- package/cjs/dsp/asserts.d.ts +32 -0
- package/cjs/dsp/asserts.js +98 -0
- package/cjs/dsp/asserts.js.map +1 -0
- package/cjs/dsp/eval.d.ts +43 -0
- package/cjs/dsp/eval.js +128 -0
- package/cjs/dsp/eval.js.map +1 -0
- package/cjs/dsp/evaluate.d.ts +12 -0
- package/cjs/dsp/evaluate.js +36 -0
- package/cjs/dsp/evaluate.js.map +1 -0
- package/cjs/dsp/extract.d.ts +25 -0
- package/cjs/dsp/extract.js +164 -0
- package/cjs/dsp/extract.js.map +1 -0
- package/cjs/dsp/generate.d.ts +55 -0
- package/cjs/dsp/generate.js +314 -0
- package/cjs/dsp/generate.js.map +1 -0
- package/cjs/dsp/index.d.ts +15 -0
- package/cjs/dsp/index.js +27 -0
- package/cjs/dsp/index.js.map +1 -0
- package/cjs/dsp/loader.d.ts +30 -0
- package/cjs/dsp/loader.js +85 -0
- package/cjs/dsp/loader.js.map +1 -0
- package/cjs/dsp/optimize.d.ts +27 -0
- package/cjs/dsp/optimize.js +99 -0
- package/cjs/dsp/optimize.js.map +1 -0
- package/cjs/dsp/parser.d.ts +87 -0
- package/cjs/dsp/parser.js +1545 -0
- package/cjs/dsp/parser.js.map +1 -0
- package/cjs/dsp/program.d.ts +73 -0
- package/cjs/dsp/program.js +120 -0
- package/cjs/dsp/program.js.map +1 -0
- package/cjs/dsp/prompt.d.ts +48 -0
- package/cjs/dsp/prompt.js +263 -0
- package/cjs/dsp/prompt.js.map +1 -0
- package/cjs/dsp/registry.d.ts +6 -0
- package/cjs/dsp/registry.js +19 -0
- package/cjs/dsp/registry.js.map +1 -0
- package/cjs/dsp/router.d.ts +26 -0
- package/cjs/dsp/router.js +76 -0
- package/cjs/dsp/router.js.map +1 -0
- package/cjs/dsp/sig.d.ts +37 -0
- package/cjs/dsp/sig.js +197 -0
- package/cjs/dsp/sig.js.map +1 -0
- package/cjs/dsp/stopwords.d.ts +1 -0
- package/cjs/dsp/stopwords.js +1167 -0
- package/cjs/dsp/stopwords.js.map +1 -0
- package/cjs/dsp/strutil.d.ts +11 -0
- package/cjs/dsp/strutil.js +63 -0
- package/cjs/dsp/strutil.js.map +1 -0
- package/cjs/dsp/util.d.ts +5 -0
- package/cjs/dsp/util.js +82 -0
- package/cjs/dsp/util.js.map +1 -0
- package/cjs/funcs/code.d.ts +9 -0
- package/cjs/funcs/code.js +90 -0
- package/cjs/funcs/code.js.map +1 -0
- package/cjs/funcs/embed.d.ts +6 -0
- package/cjs/funcs/embed.js +33 -0
- package/cjs/funcs/embed.js.map +1 -0
- package/cjs/funcs/functions.d.ts +16 -0
- package/cjs/funcs/functions.js +62 -0
- package/cjs/funcs/functions.js.map +1 -0
- package/cjs/funcs/index.d.ts +3 -0
- package/cjs/funcs/index.js +20 -0
- package/cjs/funcs/index.js.map +1 -0
- package/cjs/funcs/jsonschema.d.ts +2 -0
- package/cjs/funcs/jsonschema.js +101 -0
- package/cjs/funcs/jsonschema.js.map +1 -0
- package/cjs/index.d.ts +9 -0
- package/cjs/index.js +34 -0
- package/cjs/index.js.map +1 -0
- package/cjs/mem/index.d.ts +2 -0
- package/cjs/mem/index.js +19 -0
- package/cjs/mem/index.js.map +1 -0
- package/cjs/mem/memory.d.ts +16 -0
- package/cjs/mem/memory.js +81 -0
- package/cjs/mem/memory.js.map +1 -0
- package/cjs/mem/types.d.ts +10 -0
- package/cjs/mem/types.js +3 -0
- package/cjs/mem/types.js.map +1 -0
- package/cjs/prompts/agent.d.ts +34 -0
- package/cjs/prompts/agent.js +110 -0
- package/cjs/prompts/agent.js.map +1 -0
- package/cjs/prompts/cot.d.ts +9 -0
- package/cjs/prompts/cot.js +21 -0
- package/cjs/prompts/cot.js.map +1 -0
- package/cjs/prompts/index.d.ts +4 -0
- package/cjs/prompts/index.js +21 -0
- package/cjs/prompts/index.js.map +1 -0
- package/cjs/prompts/rag.d.ts +23 -0
- package/cjs/prompts/rag.js +33 -0
- package/cjs/prompts/rag.js.map +1 -0
- package/cjs/prompts/react.d.ts +8 -0
- package/cjs/prompts/react.js +26 -0
- package/cjs/prompts/react.js.map +1 -0
- package/cjs/trace/index.d.ts +171 -0
- package/cjs/trace/index.js +70 -0
- package/cjs/trace/index.js.map +1 -0
- package/cjs/util/apicall.d.ts +18 -0
- package/cjs/util/apicall.js +57 -0
- package/cjs/util/apicall.js.map +1 -0
- package/cjs/util/log.d.ts +14 -0
- package/cjs/util/log.js +35 -0
- package/cjs/util/log.js.map +1 -0
- package/cjs/util/other.d.ts +1 -0
- package/cjs/util/other.js +8 -0
- package/cjs/util/other.js.map +1 -0
- package/cjs/util/rate-limit.d.ts +24 -0
- package/cjs/util/rate-limit.js +53 -0
- package/cjs/util/rate-limit.js.map +1 -0
- package/cjs/util/stream.d.ts +9 -0
- package/cjs/util/stream.js +33 -0
- package/cjs/util/stream.js.map +1 -0
- package/cjs/util/transform.d.ts +7 -0
- package/cjs/util/transform.js +64 -0
- package/cjs/util/transform.js.map +1 -0
- package/db/base.d.ts +23 -0
- package/db/base.js +87 -0
- package/db/base.js.map +1 -0
- package/db/cloudflare.d.ts +21 -0
- package/db/cloudflare.js +98 -0
- package/db/cloudflare.js.map +1 -0
- package/db/index.d.ts +6 -0
- package/db/index.js +7 -0
- package/db/index.js.map +1 -0
- package/db/memory.d.ts +21 -0
- package/db/memory.js +99 -0
- package/db/memory.js.map +1 -0
- package/db/pinecone.d.ts +21 -0
- package/db/pinecone.js +71 -0
- package/db/pinecone.js.map +1 -0
- package/db/types.d.ts +35 -0
- package/db/types.js +3 -0
- package/db/types.js.map +1 -0
- package/db/weaviate.d.ts +21 -0
- package/db/weaviate.js +127 -0
- package/db/weaviate.js.map +1 -0
- package/db/wrap.d.ts +13 -0
- package/db/wrap.js +35 -0
- package/db/wrap.js.map +1 -0
- package/docs/index.d.ts +4 -0
- package/docs/index.js +5 -0
- package/docs/index.js.map +1 -0
- package/docs/manager.d.ts +45 -0
- package/docs/manager.js +159 -0
- package/docs/manager.js.map +1 -0
- package/docs/reranker.d.ts +7 -0
- package/docs/reranker.js +26 -0
- package/docs/reranker.js.map +1 -0
- package/docs/rewriter.d.ts +4 -0
- package/docs/rewriter.js +9 -0
- package/docs/rewriter.js.map +1 -0
- package/docs/tika.d.ts +18 -0
- package/docs/tika.js +46 -0
- package/docs/tika.js.map +1 -0
- package/dsp/asserts.d.ts +32 -0
- package/dsp/asserts.js +91 -0
- package/dsp/asserts.js.map +1 -0
- package/dsp/eval.d.ts +43 -0
- package/dsp/eval.js +125 -0
- package/dsp/eval.js.map +1 -0
- package/dsp/evaluate.d.ts +12 -0
- package/dsp/evaluate.js +32 -0
- package/dsp/evaluate.js.map +1 -0
- package/dsp/extract.d.ts +25 -0
- package/dsp/extract.js +153 -0
- package/dsp/extract.js.map +1 -0
- package/dsp/generate.d.ts +55 -0
- package/dsp/generate.js +311 -0
- package/dsp/generate.js.map +1 -0
- package/dsp/index.d.ts +15 -0
- package/dsp/index.js +11 -0
- package/dsp/index.js.map +1 -0
- package/dsp/loader.d.ts +30 -0
- package/dsp/loader.js +81 -0
- package/dsp/loader.js.map +1 -0
- package/dsp/optimize.d.ts +27 -0
- package/dsp/optimize.js +95 -0
- package/dsp/optimize.js.map +1 -0
- package/dsp/parser.d.ts +87 -0
- package/dsp/parser.js +1542 -0
- package/dsp/parser.js.map +1 -0
- package/dsp/program.d.ts +73 -0
- package/dsp/program.js +116 -0
- package/dsp/program.js.map +1 -0
- package/dsp/prompt.d.ts +48 -0
- package/dsp/prompt.js +260 -0
- package/dsp/prompt.js.map +1 -0
- package/dsp/registry.d.ts +6 -0
- package/dsp/registry.js +15 -0
- package/dsp/registry.js.map +1 -0
- package/dsp/router.d.ts +26 -0
- package/dsp/router.js +71 -0
- package/dsp/router.js.map +1 -0
- package/dsp/sig.d.ts +37 -0
- package/dsp/sig.js +193 -0
- package/dsp/sig.js.map +1 -0
- package/dsp/stopwords.d.ts +1 -0
- package/dsp/stopwords.js +1164 -0
- package/dsp/stopwords.js.map +1 -0
- package/dsp/strutil.d.ts +11 -0
- package/dsp/strutil.js +60 -0
- package/dsp/strutil.js.map +1 -0
- package/dsp/util.d.ts +5 -0
- package/dsp/util.js +76 -0
- package/dsp/util.js.map +1 -0
- package/funcs/code.d.ts +9 -0
- package/funcs/code.js +63 -0
- package/funcs/code.js.map +1 -0
- package/funcs/embed.d.ts +6 -0
- package/funcs/embed.js +29 -0
- package/funcs/embed.js.map +1 -0
- package/funcs/functions.d.ts +16 -0
- package/funcs/functions.js +55 -0
- package/funcs/functions.js.map +1 -0
- package/funcs/index.d.ts +3 -0
- package/funcs/index.js +4 -0
- package/funcs/index.js.map +1 -0
- package/funcs/jsonschema.d.ts +2 -0
- package/funcs/jsonschema.js +97 -0
- package/funcs/jsonschema.js.map +1 -0
- package/index.d.ts +9 -0
- package/index.js.map +1 -0
- package/mem/index.d.ts +2 -0
- package/mem/index.js +3 -0
- package/mem/index.js.map +1 -0
- package/mem/memory.d.ts +16 -0
- package/mem/memory.js +77 -0
- package/mem/memory.js.map +1 -0
- package/mem/types.d.ts +10 -0
- package/mem/types.js +2 -0
- package/mem/types.js.map +1 -0
- package/package.json +4 -7
- package/prompts/agent.d.ts +34 -0
- package/prompts/agent.js +108 -0
- package/prompts/agent.js.map +1 -0
- package/prompts/cot.d.ts +9 -0
- package/prompts/cot.js +17 -0
- package/prompts/cot.js.map +1 -0
- package/prompts/index.d.ts +4 -0
- package/prompts/index.js +5 -0
- package/prompts/index.js.map +1 -0
- package/prompts/rag.d.ts +23 -0
- package/prompts/rag.js +30 -0
- package/prompts/rag.js.map +1 -0
- package/prompts/react.d.ts +8 -0
- package/prompts/react.js +22 -0
- package/prompts/react.js.map +1 -0
- package/trace/index.d.ts +171 -0
- package/trace/index.js +67 -0
- package/trace/index.js.map +1 -0
- package/util/apicall.d.ts +18 -0
- package/util/apicall.js +50 -0
- package/util/apicall.js.map +1 -0
- package/util/log.d.ts +14 -0
- package/util/log.js +31 -0
- package/util/log.js.map +1 -0
- package/util/other.d.ts +1 -0
- package/util/other.js +5 -0
- package/util/other.js.map +1 -0
- package/util/rate-limit.d.ts +24 -0
- package/util/rate-limit.js +49 -0
- package/util/rate-limit.js.map +1 -0
- package/util/stream.d.ts +9 -0
- package/util/stream.js +29 -0
- package/util/stream.js.map +1 -0
- package/util/transform.d.ts +7 -0
- package/util/transform.js +59 -0
- package/util/transform.js.map +1 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { AxBaseAI, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig } from '../base.js';
|
|
2
|
+
import { axModelInfoGoogleGemini } from './info.js';
|
|
3
|
+
import { AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiModel, AxAIGoogleGeminiSafetyCategory, AxAIGoogleGeminiSafetyThreshold } from './types.js';
|
|
4
|
+
const safetySettings = [
|
|
5
|
+
{
|
|
6
|
+
category: AxAIGoogleGeminiSafetyCategory.HarmCategoryHarassment,
|
|
7
|
+
threshold: AxAIGoogleGeminiSafetyThreshold.BlockNone
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
category: AxAIGoogleGeminiSafetyCategory.HarmCategoryHateSpeech,
|
|
11
|
+
threshold: AxAIGoogleGeminiSafetyThreshold.BlockNone
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
category: AxAIGoogleGeminiSafetyCategory.HarmCategorySexuallyExplicit,
|
|
15
|
+
threshold: AxAIGoogleGeminiSafetyThreshold.BlockNone
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
category: AxAIGoogleGeminiSafetyCategory.HarmCategoryDangerousContent,
|
|
19
|
+
threshold: AxAIGoogleGeminiSafetyThreshold.BlockNone
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* AxAIGoogleGemini: Default Model options for text generation
|
|
24
|
+
* @export
|
|
25
|
+
*/
|
|
26
|
+
export const axAIGoogleGeminiDefaultConfig = () => structuredClone({
|
|
27
|
+
model: AxAIGoogleGeminiModel.Gemini15Pro,
|
|
28
|
+
embedModel: AxAIGoogleGeminiEmbedModel.Embedding001,
|
|
29
|
+
safetySettings,
|
|
30
|
+
...axBaseAIDefaultConfig()
|
|
31
|
+
});
|
|
32
|
+
export const axAIGoogleGeminiDefaultCreativeConfig = () => structuredClone({
|
|
33
|
+
model: AxAIGoogleGeminiModel.Gemini15Flash,
|
|
34
|
+
embedModel: AxAIGoogleGeminiEmbedModel.Embedding001,
|
|
35
|
+
safetySettings,
|
|
36
|
+
...axBaseAIDefaultCreativeConfig()
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* AxAIGoogleGemini: AI Service
|
|
40
|
+
* @export
|
|
41
|
+
*/
|
|
42
|
+
export class AxAIGoogleGemini extends AxBaseAI {
|
|
43
|
+
options;
|
|
44
|
+
config;
|
|
45
|
+
apiKey;
|
|
46
|
+
constructor({ apiKey, projectId, region, config, options }) {
|
|
47
|
+
if (!apiKey || apiKey === '') {
|
|
48
|
+
throw new Error('GoogleGemini AI API key not set');
|
|
49
|
+
}
|
|
50
|
+
let apiURL = 'https://generativelanguage.googleapis.com/v1beta';
|
|
51
|
+
if (projectId && region) {
|
|
52
|
+
apiURL = `POST https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/{REGION}/publishers/google/`;
|
|
53
|
+
}
|
|
54
|
+
const _config = {
|
|
55
|
+
...axAIGoogleGeminiDefaultConfig(),
|
|
56
|
+
...config
|
|
57
|
+
};
|
|
58
|
+
super({
|
|
59
|
+
name: 'GoogleGeminiAI',
|
|
60
|
+
apiURL,
|
|
61
|
+
headers: {},
|
|
62
|
+
modelInfo: axModelInfoGoogleGemini,
|
|
63
|
+
models: { model: _config.model, embedModel: _config.embedModel },
|
|
64
|
+
options,
|
|
65
|
+
supportFor: { functions: true, streaming: true }
|
|
66
|
+
});
|
|
67
|
+
this.options = options;
|
|
68
|
+
this.config = _config;
|
|
69
|
+
this.apiKey = apiKey;
|
|
70
|
+
}
|
|
71
|
+
getModelConfig() {
|
|
72
|
+
const { config } = this;
|
|
73
|
+
return {
|
|
74
|
+
maxTokens: config.maxTokens,
|
|
75
|
+
temperature: config.temperature,
|
|
76
|
+
topP: config.topP,
|
|
77
|
+
topK: config.topK
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
generateChatReq = (req) => {
|
|
81
|
+
const model = req.model ?? this.config.model;
|
|
82
|
+
const stream = req.modelConfig?.stream ?? this.config.stream;
|
|
83
|
+
if (!req.chatPrompt || req.chatPrompt.length === 0) {
|
|
84
|
+
throw new Error('Chat prompt is empty');
|
|
85
|
+
}
|
|
86
|
+
const apiConfig = {
|
|
87
|
+
name: stream
|
|
88
|
+
? `/models/${model}:streamGenerateContent?alt=sse&key=${this.apiKey}`
|
|
89
|
+
: `/models/${model}:generateContent?key=${this.apiKey}`
|
|
90
|
+
};
|
|
91
|
+
const systemPrompts = req.chatPrompt
|
|
92
|
+
.filter((p) => p.role === 'system')
|
|
93
|
+
.map((p) => p.content);
|
|
94
|
+
const systemInstruction = systemPrompts.length > 0
|
|
95
|
+
? {
|
|
96
|
+
role: 'user',
|
|
97
|
+
parts: [{ text: systemPrompts.join(' ') }]
|
|
98
|
+
}
|
|
99
|
+
: undefined;
|
|
100
|
+
const contents = req.chatPrompt
|
|
101
|
+
.filter((p) => p.role !== 'system')
|
|
102
|
+
.map((msg, i) => {
|
|
103
|
+
switch (msg.role) {
|
|
104
|
+
case 'user': {
|
|
105
|
+
const parts = Array.isArray(msg.content)
|
|
106
|
+
? msg.content.map((c, i) => {
|
|
107
|
+
switch (c.type) {
|
|
108
|
+
case 'text':
|
|
109
|
+
return { text: c.text };
|
|
110
|
+
case 'image':
|
|
111
|
+
return {
|
|
112
|
+
inlineData: { mimeType: c.mimeType, data: c.image }
|
|
113
|
+
};
|
|
114
|
+
default:
|
|
115
|
+
throw new Error(`Chat prompt content type not supported (index: ${i})`);
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
: [{ text: msg.content }];
|
|
119
|
+
return {
|
|
120
|
+
role: 'user',
|
|
121
|
+
parts
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
case 'assistant': {
|
|
125
|
+
if ('content' in msg && typeof msg.content === 'string') {
|
|
126
|
+
const parts = [{ text: msg.content }];
|
|
127
|
+
return {
|
|
128
|
+
role: 'model',
|
|
129
|
+
parts
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
let parts = [];
|
|
133
|
+
if ('functionCalls' in msg) {
|
|
134
|
+
parts =
|
|
135
|
+
msg.functionCalls?.map((f) => {
|
|
136
|
+
const args = typeof f.function.params === 'string'
|
|
137
|
+
? JSON.parse(f.function.params)
|
|
138
|
+
: f.function.params;
|
|
139
|
+
return {
|
|
140
|
+
functionCall: {
|
|
141
|
+
name: f.function.name,
|
|
142
|
+
args: args
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}) ?? [];
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
role: 'model',
|
|
149
|
+
parts
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
case 'function': {
|
|
153
|
+
if (!('functionId' in msg)) {
|
|
154
|
+
throw new Error(`Chat prompt functionId is empty (index: ${i})`);
|
|
155
|
+
}
|
|
156
|
+
const parts = [
|
|
157
|
+
{
|
|
158
|
+
functionResponse: {
|
|
159
|
+
name: msg.functionId,
|
|
160
|
+
response: { result: msg.result }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
return {
|
|
165
|
+
role: 'function',
|
|
166
|
+
parts
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
default:
|
|
170
|
+
throw new Error('Invalid role');
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
let tools = [];
|
|
174
|
+
if (req.functions && req.functions.length > 0) {
|
|
175
|
+
tools.push({ functionDeclarations: req.functions });
|
|
176
|
+
}
|
|
177
|
+
if (this.options?.codeExecution) {
|
|
178
|
+
tools.push({ codeExecution: {} });
|
|
179
|
+
}
|
|
180
|
+
if (tools.length === 0) {
|
|
181
|
+
tools = undefined;
|
|
182
|
+
}
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
184
|
+
let tool_config;
|
|
185
|
+
if (req.functionCall) {
|
|
186
|
+
if (req.functionCall === 'none') {
|
|
187
|
+
tool_config = { function_calling_config: { mode: 'NONE' } };
|
|
188
|
+
}
|
|
189
|
+
else if (req.functionCall === 'auto') {
|
|
190
|
+
tool_config = { function_calling_config: { mode: 'AUTO' } };
|
|
191
|
+
}
|
|
192
|
+
else if (req.functionCall === 'required') {
|
|
193
|
+
tool_config = {
|
|
194
|
+
function_calling_config: { mode: 'ANY' }
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
tool_config = {
|
|
199
|
+
function_calling_config: {
|
|
200
|
+
mode: 'ANY',
|
|
201
|
+
allowed_function_names: [req.functionCall.function.name]
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const generationConfig = {
|
|
207
|
+
maxOutputTokens: req.modelConfig?.maxTokens ?? this.config.maxTokens,
|
|
208
|
+
temperature: req.modelConfig?.temperature ?? this.config.temperature,
|
|
209
|
+
topP: req.modelConfig?.topP ?? this.config.topP,
|
|
210
|
+
topK: req.modelConfig?.topK ?? this.config.topK,
|
|
211
|
+
candidateCount: 1,
|
|
212
|
+
stopSequences: req.modelConfig?.stopSequences ?? this.config.stopSequences
|
|
213
|
+
};
|
|
214
|
+
const safetySettings = this.config.safetySettings;
|
|
215
|
+
const reqValue = {
|
|
216
|
+
contents,
|
|
217
|
+
tools,
|
|
218
|
+
tool_config,
|
|
219
|
+
systemInstruction,
|
|
220
|
+
generationConfig,
|
|
221
|
+
safetySettings
|
|
222
|
+
};
|
|
223
|
+
return [apiConfig, reqValue];
|
|
224
|
+
};
|
|
225
|
+
generateEmbedReq = (req) => {
|
|
226
|
+
const model = req.embedModel ?? this.config.embedModel;
|
|
227
|
+
if (!model) {
|
|
228
|
+
throw new Error('Embed model not set');
|
|
229
|
+
}
|
|
230
|
+
if (!req.texts || req.texts.length === 0) {
|
|
231
|
+
throw new Error('Embed texts is empty');
|
|
232
|
+
}
|
|
233
|
+
const apiConfig = {
|
|
234
|
+
name: `/models/${model}:batchEmbedText?key=${this.apiKey}`
|
|
235
|
+
};
|
|
236
|
+
const reqValue = {
|
|
237
|
+
requests: req.texts.map((text) => ({ model, text }))
|
|
238
|
+
};
|
|
239
|
+
return [apiConfig, reqValue];
|
|
240
|
+
};
|
|
241
|
+
generateChatResp = (resp) => {
|
|
242
|
+
const results = resp.candidates?.map((candidate) => {
|
|
243
|
+
const result = {};
|
|
244
|
+
switch (candidate.finishReason) {
|
|
245
|
+
case 'MAX_TOKENS':
|
|
246
|
+
result.finishReason = 'length';
|
|
247
|
+
break;
|
|
248
|
+
case 'STOP':
|
|
249
|
+
result.finishReason = 'stop';
|
|
250
|
+
break;
|
|
251
|
+
case 'SAFETY':
|
|
252
|
+
throw new Error('Finish reason: SAFETY');
|
|
253
|
+
case 'RECITATION':
|
|
254
|
+
throw new Error('Finish reason: RECITATION');
|
|
255
|
+
}
|
|
256
|
+
for (const part of candidate.content.parts) {
|
|
257
|
+
if ('text' in part) {
|
|
258
|
+
result.content = part.text;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if ('functionCall' in part) {
|
|
262
|
+
result.functionCalls = [
|
|
263
|
+
{
|
|
264
|
+
id: part.functionCall.name,
|
|
265
|
+
type: 'function',
|
|
266
|
+
function: {
|
|
267
|
+
name: part.functionCall.name,
|
|
268
|
+
params: part.functionCall.args
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
});
|
|
276
|
+
let modelUsage;
|
|
277
|
+
if (resp.usageMetadata) {
|
|
278
|
+
modelUsage = {
|
|
279
|
+
totalTokens: resp.usageMetadata.totalTokenCount,
|
|
280
|
+
promptTokens: resp.usageMetadata.promptTokenCount,
|
|
281
|
+
completionTokens: resp.usageMetadata.candidatesTokenCount
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
results,
|
|
286
|
+
modelUsage
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
generateChatStreamResp = (resp) => {
|
|
290
|
+
return this.generateChatResp(resp);
|
|
291
|
+
};
|
|
292
|
+
generateEmbedResp = (resp) => {
|
|
293
|
+
const embeddings = resp.embeddings.map((embedding) => embedding.value);
|
|
294
|
+
return {
|
|
295
|
+
embeddings
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../ai/google-gemini/api.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAOL,0BAA0B,EAC1B,qBAAqB,EACrB,8BAA8B,EAE9B,+BAA+B,EAChC,MAAM,YAAY,CAAC;AAEpB,MAAM,cAAc,GAAmC;IACrD;QACE,QAAQ,EAAE,8BAA8B,CAAC,sBAAsB;QAC/D,SAAS,EAAE,+BAA+B,CAAC,SAAS;KACrD;IACD;QACE,QAAQ,EAAE,8BAA8B,CAAC,sBAAsB;QAC/D,SAAS,EAAE,+BAA+B,CAAC,SAAS;KACrD;IACD;QACE,QAAQ,EAAE,8BAA8B,CAAC,4BAA4B;QACrE,SAAS,EAAE,+BAA+B,CAAC,SAAS;KACrD;IACD;QACE,QAAQ,EAAE,8BAA8B,CAAC,4BAA4B;QACrE,SAAS,EAAE,+BAA+B,CAAC,SAAS;KACrD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAA2B,EAAE,CACxE,eAAe,CAAC;IACd,KAAK,EAAE,qBAAqB,CAAC,WAAW;IACxC,UAAU,EAAE,0BAA0B,CAAC,YAAY;IACnD,cAAc;IACd,GAAG,qBAAqB,EAAE;CAC3B,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,qCAAqC,GAChD,GAA2B,EAAE,CAC3B,eAAe,CAAC;IACd,KAAK,EAAE,qBAAqB,CAAC,aAAa;IAC1C,UAAU,EAAE,0BAA0B,CAAC,YAAY;IACnD,cAAc;IACd,GAAG,6BAA6B,EAAE;CACnC,CAAC,CAAC;AAWP;;;GAGG;AACH,MAAM,OAAO,gB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,CAAC,CAAC;IAEO,sBAAsB,GAAG,CAChC,IAAiD,EACjC,EAAE;QAClB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC;IAEO,iBAAiB,GAAG,CAC3B,IAAkD,EACjC,EAAE;QACnB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAEvE,OAAO;YACL,UAAU;SACX,CAAC;IACJ,CAAC,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ai/google-gemini/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxAIGoogleGeminiModel } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* AxAIGoogleGemini: Model information
|
|
4
|
+
* @export
|
|
5
|
+
*/
|
|
6
|
+
export const axModelInfoGoogleGemini = [
|
|
7
|
+
{
|
|
8
|
+
name: AxAIGoogleGeminiModel.Gemini15Flash,
|
|
9
|
+
currency: 'usd',
|
|
10
|
+
characterIsToken: true,
|
|
11
|
+
promptTokenCostPer1M: 0.35,
|
|
12
|
+
completionTokenCostPer1M: 0.7
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: AxAIGoogleGeminiModel.Gemini15Pro,
|
|
16
|
+
currency: 'usd',
|
|
17
|
+
characterIsToken: true,
|
|
18
|
+
promptTokenCostPer1M: 3.5,
|
|
19
|
+
completionTokenCostPer1M: 1.75
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: AxAIGoogleGeminiModel.Gemini1Pro,
|
|
23
|
+
currency: 'usd',
|
|
24
|
+
characterIsToken: true,
|
|
25
|
+
promptTokenCostPer1M: 0.5,
|
|
26
|
+
completionTokenCostPer1M: 1.5
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../ai/google-gemini/info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAkB;IACpD;QACE,IAAI,EAAE,qBAAqB,CAAC,aAAa;QACzC,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,IAAI;QACtB,oBAAoB,EAAE,IAAI;QAC1B,wBAAwB,EAAE,GAAG;KAC9B;IACD;QACE,IAAI,EAAE,qBAAqB,CAAC,WAAW;QACvC,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,IAAI;QACtB,oBAAoB,EAAE,GAAG;QACzB,wBAAwB,EAAE,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,qBAAqB,CAAC,UAAU;QACtC,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,IAAI;QACtB,oBAAoB,EAAE,GAAG;QACzB,wBAAwB,EAAE,GAAG;KAC9B;CACF,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { AxModelConfig } from '../types.js';
|
|
2
|
+
export declare enum AxAIGoogleGeminiModel {
|
|
3
|
+
Gemini1Pro = "gemini-1.0-pro",
|
|
4
|
+
Gemini15Flash = "gemini-1.5-flash",
|
|
5
|
+
Gemini15Pro = "gemini-1.5-pro",
|
|
6
|
+
Gemma2 = "gemma-2-27b-it"
|
|
7
|
+
}
|
|
8
|
+
export declare enum AxAIGoogleGeminiEmbedModel {
|
|
9
|
+
Embedding001 = "embedding-001"
|
|
10
|
+
}
|
|
11
|
+
export declare enum AxAIGoogleGeminiSafetyCategory {
|
|
12
|
+
HarmCategoryHarassment = "HARM_CATEGORY_HARASSMENT",
|
|
13
|
+
HarmCategoryHateSpeech = "HARM_CATEGORY_HATE_SPEECH",
|
|
14
|
+
HarmCategorySexuallyExplicit = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
15
|
+
HarmCategoryDangerousContent = "HARM_CATEGORY_DANGEROUS_CONTENT"
|
|
16
|
+
}
|
|
17
|
+
export declare enum AxAIGoogleGeminiSafetyThreshold {
|
|
18
|
+
BlockNone = "BLOCK_NONE",
|
|
19
|
+
BlockOnlyHigh = "BLOCK_ONLY_HIGH",
|
|
20
|
+
BlockMediumAndAbove = "BLOCK_MEDIUM_AND_ABOVE",
|
|
21
|
+
BlockLowAndAbove = "BLOCK_LOW_AND_ABOVE",
|
|
22
|
+
BlockDefault = "HARM_BLOCK_THRESHOLD_UNSPECIFIED"
|
|
23
|
+
}
|
|
24
|
+
export type AxAIGoogleGeminiContent = {
|
|
25
|
+
role: 'user';
|
|
26
|
+
parts: ({
|
|
27
|
+
text: string;
|
|
28
|
+
} | {
|
|
29
|
+
inlineData: {
|
|
30
|
+
mimeType: string;
|
|
31
|
+
data: string;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
fileData: {
|
|
35
|
+
mimeType: string;
|
|
36
|
+
fileUri: string;
|
|
37
|
+
};
|
|
38
|
+
})[];
|
|
39
|
+
} | {
|
|
40
|
+
role: 'model';
|
|
41
|
+
parts: {
|
|
42
|
+
text: string;
|
|
43
|
+
}[] | {
|
|
44
|
+
functionCall: {
|
|
45
|
+
name: string;
|
|
46
|
+
args: object;
|
|
47
|
+
};
|
|
48
|
+
}[];
|
|
49
|
+
} | {
|
|
50
|
+
role: 'function';
|
|
51
|
+
parts: {
|
|
52
|
+
functionResponse: {
|
|
53
|
+
name: string;
|
|
54
|
+
response: object;
|
|
55
|
+
};
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
export type AxAIGoogleGeminiToolFunctionDeclaration = {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
parameters?: object;
|
|
62
|
+
};
|
|
63
|
+
export type AxAIGoogleGeminiTool = {
|
|
64
|
+
functionDeclarations?: AxAIGoogleGeminiToolFunctionDeclaration[];
|
|
65
|
+
codeExecution?: object;
|
|
66
|
+
};
|
|
67
|
+
export type AxAIGoogleGeminiToolConfig = {
|
|
68
|
+
function_calling_config: {
|
|
69
|
+
mode: 'ANY' | 'NONE' | 'AUTO';
|
|
70
|
+
allowed_function_names?: string[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export type AxAIGoogleGeminiGenerationConfig = {
|
|
74
|
+
temperature?: number;
|
|
75
|
+
topP?: number;
|
|
76
|
+
topK?: number;
|
|
77
|
+
candidateCount?: number;
|
|
78
|
+
maxOutputTokens?: number;
|
|
79
|
+
stopSequences?: readonly string[];
|
|
80
|
+
};
|
|
81
|
+
export type AxAIGoogleGeminiSafetySettings = {
|
|
82
|
+
category: AxAIGoogleGeminiSafetyCategory;
|
|
83
|
+
threshold: AxAIGoogleGeminiSafetyThreshold;
|
|
84
|
+
}[];
|
|
85
|
+
export type AxAIGoogleGeminiChatRequest = {
|
|
86
|
+
contents: AxAIGoogleGeminiContent[];
|
|
87
|
+
tools?: AxAIGoogleGeminiTool[];
|
|
88
|
+
tool_config?: AxAIGoogleGeminiToolConfig;
|
|
89
|
+
systemInstruction?: AxAIGoogleGeminiContent;
|
|
90
|
+
generationConfig: AxAIGoogleGeminiGenerationConfig;
|
|
91
|
+
safetySettings?: AxAIGoogleGeminiSafetySettings;
|
|
92
|
+
};
|
|
93
|
+
export type AxAIGoogleGeminiChatResponse = {
|
|
94
|
+
candidates: {
|
|
95
|
+
content: AxAIGoogleGeminiContent;
|
|
96
|
+
finishReason: 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'OTHER';
|
|
97
|
+
citationMetadata: {
|
|
98
|
+
citations: {
|
|
99
|
+
startIndex: number;
|
|
100
|
+
endIndex: number;
|
|
101
|
+
uri: string;
|
|
102
|
+
title: string;
|
|
103
|
+
license: string;
|
|
104
|
+
publicationDate: {
|
|
105
|
+
year: number;
|
|
106
|
+
month: number;
|
|
107
|
+
day: number;
|
|
108
|
+
};
|
|
109
|
+
}[];
|
|
110
|
+
};
|
|
111
|
+
}[];
|
|
112
|
+
usageMetadata: {
|
|
113
|
+
promptTokenCount: number;
|
|
114
|
+
candidatesTokenCount: number;
|
|
115
|
+
totalTokenCount: number;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export type AxAIGoogleGeminiChatResponseDelta = AxAIGoogleGeminiChatResponse;
|
|
119
|
+
/**
|
|
120
|
+
* AxAIGoogleGeminiConfig: Configuration options for Google Gemini API
|
|
121
|
+
* @export
|
|
122
|
+
*/
|
|
123
|
+
export type AxAIGoogleGeminiConfig = AxModelConfig & {
|
|
124
|
+
model: AxAIGoogleGeminiModel | string;
|
|
125
|
+
embedModel: AxAIGoogleGeminiEmbedModel;
|
|
126
|
+
safetySettings?: AxAIGoogleGeminiSafetySettings;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* AxAIGoogleGeminiEmbedRequest: Structure for making an embedding request to the Google Gemini API.
|
|
130
|
+
* @export
|
|
131
|
+
*/
|
|
132
|
+
export type AxAIGoogleGeminiBatchEmbedRequest = {
|
|
133
|
+
requests: {
|
|
134
|
+
model: string;
|
|
135
|
+
text: string;
|
|
136
|
+
}[];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* AxAIGoogleGeminiEmbedResponse: Structure for handling responses from the Google Gemini API embedding requests.
|
|
140
|
+
* @export
|
|
141
|
+
*/
|
|
142
|
+
export type AxAIGoogleGeminiBatchEmbedResponse = {
|
|
143
|
+
embeddings: {
|
|
144
|
+
value: number[];
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var AxAIGoogleGeminiModel;
|
|
2
|
+
(function (AxAIGoogleGeminiModel) {
|
|
3
|
+
AxAIGoogleGeminiModel["Gemini1Pro"] = "gemini-1.0-pro";
|
|
4
|
+
AxAIGoogleGeminiModel["Gemini15Flash"] = "gemini-1.5-flash";
|
|
5
|
+
AxAIGoogleGeminiModel["Gemini15Pro"] = "gemini-1.5-pro";
|
|
6
|
+
AxAIGoogleGeminiModel["Gemma2"] = "gemma-2-27b-it";
|
|
7
|
+
})(AxAIGoogleGeminiModel || (AxAIGoogleGeminiModel = {}));
|
|
8
|
+
export var AxAIGoogleGeminiEmbedModel;
|
|
9
|
+
(function (AxAIGoogleGeminiEmbedModel) {
|
|
10
|
+
AxAIGoogleGeminiEmbedModel["Embedding001"] = "embedding-001";
|
|
11
|
+
})(AxAIGoogleGeminiEmbedModel || (AxAIGoogleGeminiEmbedModel = {}));
|
|
12
|
+
export var AxAIGoogleGeminiSafetyCategory;
|
|
13
|
+
(function (AxAIGoogleGeminiSafetyCategory) {
|
|
14
|
+
AxAIGoogleGeminiSafetyCategory["HarmCategoryHarassment"] = "HARM_CATEGORY_HARASSMENT";
|
|
15
|
+
AxAIGoogleGeminiSafetyCategory["HarmCategoryHateSpeech"] = "HARM_CATEGORY_HATE_SPEECH";
|
|
16
|
+
AxAIGoogleGeminiSafetyCategory["HarmCategorySexuallyExplicit"] = "HARM_CATEGORY_SEXUALLY_EXPLICIT";
|
|
17
|
+
AxAIGoogleGeminiSafetyCategory["HarmCategoryDangerousContent"] = "HARM_CATEGORY_DANGEROUS_CONTENT";
|
|
18
|
+
})(AxAIGoogleGeminiSafetyCategory || (AxAIGoogleGeminiSafetyCategory = {}));
|
|
19
|
+
export var AxAIGoogleGeminiSafetyThreshold;
|
|
20
|
+
(function (AxAIGoogleGeminiSafetyThreshold) {
|
|
21
|
+
AxAIGoogleGeminiSafetyThreshold["BlockNone"] = "BLOCK_NONE";
|
|
22
|
+
AxAIGoogleGeminiSafetyThreshold["BlockOnlyHigh"] = "BLOCK_ONLY_HIGH";
|
|
23
|
+
AxAIGoogleGeminiSafetyThreshold["BlockMediumAndAbove"] = "BLOCK_MEDIUM_AND_ABOVE";
|
|
24
|
+
AxAIGoogleGeminiSafetyThreshold["BlockLowAndAbove"] = "BLOCK_LOW_AND_ABOVE";
|
|
25
|
+
AxAIGoogleGeminiSafetyThreshold["BlockDefault"] = "HARM_BLOCK_THRESHOLD_UNSPECIFIED";
|
|
26
|
+
})(AxAIGoogleGeminiSafetyThreshold || (AxAIGoogleGeminiSafetyThreshold = {}));
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ai/google-gemini/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC/B,sDAA6B,CAAA;IAC7B,2DAAkC,CAAA;IAClC,uDAA8B,CAAA;IAC9B,kDAAyB,CAAA;AAC3B,CAAC,EALW,qBAAqB,KAArB,qBAAqB,QAKhC;AAED,MAAM,CAAN,IAAY,0BAEX;AAFD,WAAY,0BAA0B;IACpC,4DAA8B,CAAA;AAChC,CAAC,EAFW,0BAA0B,KAA1B,0BAA0B,QAErC;AAED,MAAM,CAAN,IAAY,8BAKX;AALD,WAAY,8BAA8B;IACxC,qFAAmD,CAAA;IACnD,sFAAoD,CAAA;IACpD,kGAAgE,CAAA;IAChE,kGAAgE,CAAA;AAClE,CAAC,EALW,8BAA8B,KAA9B,8BAA8B,QAKzC;AAED,MAAM,CAAN,IAAY,+BAMX;AAND,WAAY,+BAA+B;IACzC,2DAAwB,CAAA;IACxB,oEAAiC,CAAA;IACjC,iFAA8C,CAAA;IAC9C,2EAAwC,CAAA;IACxC,oFAAiD,CAAA;AACnD,CAAC,EANW,+BAA+B,KAA/B,+BAA+B,QAM1C"}
|
package/ai/groq/api.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxAIOpenAI } from '../openai/api.js';
|
|
2
|
+
import type { AxAIOpenAIConfig } from '../openai/types.js';
|
|
3
|
+
import type { AxAIServiceOptions } from '../types.js';
|
|
4
|
+
type AxAIGroqAIConfig = AxAIOpenAIConfig;
|
|
5
|
+
export interface AxAIGroqArgs {
|
|
6
|
+
name: 'groq';
|
|
7
|
+
apiKey: string;
|
|
8
|
+
config?: Readonly<AxAIGroqAIConfig>;
|
|
9
|
+
options?: Readonly<AxAIServiceOptions> & {
|
|
10
|
+
tokensPerMinute?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class AxAIGroq extends AxAIOpenAI {
|
|
14
|
+
constructor({ apiKey, config, options }: Readonly<Omit<AxAIGroqArgs, 'groq'>>);
|
|
15
|
+
setOptions: (options: Readonly<AxAIServiceOptions>) => void;
|
|
16
|
+
private newRateLimiter;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/ai/groq/api.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AxRateLimiterTokenUsage } from '../../util/rate-limit.js';
|
|
2
|
+
import { axBaseAIDefaultConfig } from '../base.js';
|
|
3
|
+
import { AxAIOpenAI } from '../openai/api.js';
|
|
4
|
+
import { AxAIGroqModel } from './types.js';
|
|
5
|
+
const axAIGroqDefaultConfig = () => structuredClone({
|
|
6
|
+
model: AxAIGroqModel.Llama3_70B,
|
|
7
|
+
...axBaseAIDefaultConfig()
|
|
8
|
+
});
|
|
9
|
+
export class AxAIGroq extends AxAIOpenAI {
|
|
10
|
+
constructor({ apiKey, config, options }) {
|
|
11
|
+
if (!apiKey || apiKey === '') {
|
|
12
|
+
throw new Error('Groq API key not set');
|
|
13
|
+
}
|
|
14
|
+
const _config = {
|
|
15
|
+
...axAIGroqDefaultConfig(),
|
|
16
|
+
...config
|
|
17
|
+
};
|
|
18
|
+
const _options = {
|
|
19
|
+
...options,
|
|
20
|
+
streamingUsage: false
|
|
21
|
+
};
|
|
22
|
+
super({
|
|
23
|
+
apiKey,
|
|
24
|
+
config: _config,
|
|
25
|
+
options: _options,
|
|
26
|
+
apiURL: 'https://api.groq.com/openai/v1',
|
|
27
|
+
modelInfo: []
|
|
28
|
+
});
|
|
29
|
+
super.setName('Groq');
|
|
30
|
+
this.setOptions(_options);
|
|
31
|
+
}
|
|
32
|
+
setOptions = (options) => {
|
|
33
|
+
const rateLimiter = this.newRateLimiter(options);
|
|
34
|
+
super.setOptions({ ...options, rateLimiter });
|
|
35
|
+
};
|
|
36
|
+
newRateLimiter = (options) => {
|
|
37
|
+
if (options?.rateLimiter) {
|
|
38
|
+
return options.rateLimiter;
|
|
39
|
+
}
|
|
40
|
+
const tokensPerMin = options?.tokensPerMinute ?? 4800;
|
|
41
|
+
const rt = new AxRateLimiterTokenUsage(tokensPerMin, tokensPerMin / 60, {
|
|
42
|
+
debug: options?.debug
|
|
43
|
+
});
|
|
44
|
+
const rtFunc = async (func, info) => {
|
|
45
|
+
const totalTokens = info.modelUsage?.totalTokens || 0;
|
|
46
|
+
await rt.acquire(totalTokens);
|
|
47
|
+
return await func();
|
|
48
|
+
};
|
|
49
|
+
return rtFunc;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../ai/groq/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,qBAAqB,GAAG,GAAqB,EAAE,CACnD,eAAe,CAAC;IACd,KAAK,EAAE,aAAa,CAAC,UAAU;IAC/B,GAAG,qBAAqB,EAAE;CAC3B,CAAC,CAAC;AASL,MAAM,OAAO,QAAS,SAAQ,UAAU;IACtC,YAAY,EACV,MAAM,EACN,MAAM,EACN,OAAO,EAC8B;QACrC,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YA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E,CAAC;QACtB,CAAC,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api.js';
|
package/ai/groq/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ai/groq/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/ai/groq/types.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var AxAIGroqModel;
|
|
2
|
+
(function (AxAIGroqModel) {
|
|
3
|
+
AxAIGroqModel["Llama3_8B"] = "llama3-8b-8192";
|
|
4
|
+
AxAIGroqModel["Llama3_70B"] = "llama3-70b-8192";
|
|
5
|
+
AxAIGroqModel["Mixtral_8x7B"] = "mixtral-8x7b-32768";
|
|
6
|
+
AxAIGroqModel["Gemma_7B"] = "gemma-7b-it";
|
|
7
|
+
})(AxAIGroqModel || (AxAIGroqModel = {}));
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../ai/groq/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,6CAA4B,CAAA;IAC5B,+CAA8B,CAAA;IAC9B,oDAAmC,CAAA;IACnC,yCAAwB,CAAA;AAC1B,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB"}
|