@ax-llm/ax 9.0.19 → 9.0.20
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 +33 -85
- package/CHANGELOG.md +0 -184
- package/LICENSE +0 -201
- package/README.md +0 -569
- package/build/module/docs/assets/icons.d.ts +0 -1
- package/build/module/docs/assets/icons.js +0 -19
- package/build/module/docs/assets/icons.js.map +0 -1
- package/build/module/docs/assets/main.d.ts +0 -1
- package/build/module/docs/assets/main.js +0 -629
- package/build/module/docs/assets/main.js.map +0 -1
- package/build/module/docs/assets/navigation.d.ts +0 -1
- package/build/module/docs/assets/navigation.js +0 -3
- package/build/module/docs/assets/navigation.js.map +0 -1
- package/build/module/docs/assets/search.d.ts +0 -1
- package/build/module/docs/assets/search.js +0 -3
- package/build/module/docs/assets/search.js.map +0 -1
- package/build/module/src/ai/anthropic/api.d.ts +0 -19
- package/build/module/src/ai/anthropic/api.js +0 -326
- package/build/module/src/ai/anthropic/api.js.map +0 -1
- package/build/module/src/ai/anthropic/index.d.ts +0 -2
- package/build/module/src/ai/anthropic/index.js +0 -3
- package/build/module/src/ai/anthropic/index.js.map +0 -1
- package/build/module/src/ai/anthropic/info.d.ts +0 -2
- package/build/module/src/ai/anthropic/info.js +0 -40
- package/build/module/src/ai/anthropic/info.js.map +0 -1
- package/build/module/src/ai/anthropic/types.d.ts +0 -171
- package/build/module/src/ai/anthropic/types.js +0 -10
- package/build/module/src/ai/anthropic/types.js.map +0 -1
- package/build/module/src/ai/azure-openai/api.d.ts +0 -19
- package/build/module/src/ai/azure-openai/api.js +0 -30
- package/build/module/src/ai/azure-openai/api.js.map +0 -1
- package/build/module/src/ai/azure-openai/index.d.ts +0 -1
- package/build/module/src/ai/azure-openai/index.js +0 -2
- package/build/module/src/ai/azure-openai/index.js.map +0 -1
- package/build/module/src/ai/balance.d.ts +0 -23
- package/build/module/src/ai/balance.js +0 -87
- package/build/module/src/ai/balance.js.map +0 -1
- package/build/module/src/ai/base.d.ts +0 -55
- package/build/module/src/ai/base.js +0 -343
- package/build/module/src/ai/base.js.map +0 -1
- package/build/module/src/ai/cohere/api.d.ts +0 -22
- package/build/module/src/ai/cohere/api.js +0 -264
- package/build/module/src/ai/cohere/api.js.map +0 -1
- package/build/module/src/ai/cohere/index.d.ts +0 -2
- package/build/module/src/ai/cohere/index.js +0 -3
- package/build/module/src/ai/cohere/index.js.map +0 -1
- package/build/module/src/ai/cohere/info.d.ts +0 -2
- package/build/module/src/ai/cohere/info.js +0 -52
- package/build/module/src/ai/cohere/info.js.map +0 -1
- package/build/module/src/ai/cohere/types.d.ts +0 -102
- package/build/module/src/ai/cohere/types.js +0 -23
- package/build/module/src/ai/cohere/types.js.map +0 -1
- package/build/module/src/ai/deepseek/api.d.ts +0 -16
- package/build/module/src/ai/deepseek/api.js +0 -32
- package/build/module/src/ai/deepseek/api.js.map +0 -1
- package/build/module/src/ai/deepseek/index.d.ts +0 -2
- package/build/module/src/ai/deepseek/index.js +0 -3
- package/build/module/src/ai/deepseek/index.js.map +0 -1
- package/build/module/src/ai/deepseek/info.d.ts +0 -2
- package/build/module/src/ai/deepseek/info.js +0 -16
- package/build/module/src/ai/deepseek/info.js.map +0 -1
- package/build/module/src/ai/deepseek/types.d.ts +0 -8
- package/build/module/src/ai/deepseek/types.js +0 -10
- package/build/module/src/ai/deepseek/types.js.map +0 -1
- package/build/module/src/ai/google-gemini/api.d.ts +0 -36
- package/build/module/src/ai/google-gemini/api.js +0 -299
- package/build/module/src/ai/google-gemini/api.js.map +0 -1
- package/build/module/src/ai/google-gemini/index.d.ts +0 -2
- package/build/module/src/ai/google-gemini/index.js +0 -3
- package/build/module/src/ai/google-gemini/index.js.map +0 -1
- package/build/module/src/ai/google-gemini/info.d.ts +0 -6
- package/build/module/src/ai/google-gemini/info.js +0 -29
- package/build/module/src/ai/google-gemini/info.js.map +0 -1
- package/build/module/src/ai/google-gemini/types.d.ts +0 -146
- package/build/module/src/ai/google-gemini/types.js +0 -27
- package/build/module/src/ai/google-gemini/types.js.map +0 -1
- package/build/module/src/ai/groq/api.d.ts +0 -18
- package/build/module/src/ai/groq/api.js +0 -52
- package/build/module/src/ai/groq/api.js.map +0 -1
- package/build/module/src/ai/groq/index.d.ts +0 -1
- package/build/module/src/ai/groq/index.js +0 -2
- package/build/module/src/ai/groq/index.js.map +0 -1
- package/build/module/src/ai/groq/types.d.ts +0 -6
- package/build/module/src/ai/groq/types.js +0 -8
- package/build/module/src/ai/groq/types.js.map +0 -1
- package/build/module/src/ai/huggingface/api.d.ts +0 -19
- package/build/module/src/ai/huggingface/api.js +0 -115
- package/build/module/src/ai/huggingface/api.js.map +0 -1
- package/build/module/src/ai/huggingface/index.d.ts +0 -2
- package/build/module/src/ai/huggingface/index.js +0 -3
- package/build/module/src/ai/huggingface/index.js.map +0 -1
- package/build/module/src/ai/huggingface/info.d.ts +0 -6
- package/build/module/src/ai/huggingface/info.js +0 -6
- package/build/module/src/ai/huggingface/info.js.map +0 -1
- package/build/module/src/ai/huggingface/types.d.ts +0 -34
- package/build/module/src/ai/huggingface/types.js +0 -5
- package/build/module/src/ai/huggingface/types.js.map +0 -1
- package/build/module/src/ai/index.d.ts +0 -16
- package/build/module/src/ai/index.js +0 -16
- package/build/module/src/ai/index.js.map +0 -1
- package/build/module/src/ai/mistral/api.d.ts +0 -16
- package/build/module/src/ai/mistral/api.js +0 -32
- package/build/module/src/ai/mistral/api.js.map +0 -1
- package/build/module/src/ai/mistral/index.d.ts +0 -2
- package/build/module/src/ai/mistral/index.js +0 -3
- package/build/module/src/ai/mistral/index.js.map +0 -1
- package/build/module/src/ai/mistral/info.d.ts +0 -2
- package/build/module/src/ai/mistral/info.js +0 -34
- package/build/module/src/ai/mistral/info.js.map +0 -1
- package/build/module/src/ai/mistral/types.d.ts +0 -10
- package/build/module/src/ai/mistral/types.js +0 -13
- package/build/module/src/ai/mistral/types.js.map +0 -1
- package/build/module/src/ai/ollama/api.d.ts +0 -22
- package/build/module/src/ai/ollama/api.js +0 -32
- package/build/module/src/ai/ollama/api.js.map +0 -1
- package/build/module/src/ai/ollama/index.d.ts +0 -1
- package/build/module/src/ai/ollama/index.js +0 -2
- package/build/module/src/ai/ollama/index.js.map +0 -1
- package/build/module/src/ai/openai/api.d.ts +0 -29
- package/build/module/src/ai/openai/api.js +0 -283
- package/build/module/src/ai/openai/api.js.map +0 -1
- package/build/module/src/ai/openai/index.d.ts +0 -2
- package/build/module/src/ai/openai/index.js +0 -3
- package/build/module/src/ai/openai/index.js.map +0 -1
- package/build/module/src/ai/openai/info.d.ts +0 -6
- package/build/module/src/ai/openai/info.js +0 -50
- package/build/module/src/ai/openai/info.js.map +0 -1
- package/build/module/src/ai/openai/types.d.ts +0 -165
- package/build/module/src/ai/openai/types.js +0 -18
- package/build/module/src/ai/openai/types.js.map +0 -1
- package/build/module/src/ai/together/api.d.ts +0 -15
- package/build/module/src/ai/together/api.js +0 -28
- package/build/module/src/ai/together/api.js.map +0 -1
- package/build/module/src/ai/together/index.d.ts +0 -1
- package/build/module/src/ai/together/index.js +0 -2
- package/build/module/src/ai/together/index.js.map +0 -1
- package/build/module/src/ai/together/info.d.ts +0 -2
- package/build/module/src/ai/together/info.js +0 -2
- package/build/module/src/ai/together/info.js.map +0 -1
- package/build/module/src/ai/types.d.ts +0 -159
- package/build/module/src/ai/types.js +0 -2
- package/build/module/src/ai/types.js.map +0 -1
- package/build/module/src/ai/util.d.ts +0 -12
- package/build/module/src/ai/util.js +0 -63
- package/build/module/src/ai/util.js.map +0 -1
- package/build/module/src/ai/wrap.d.ts +0 -47
- package/build/module/src/ai/wrap.js +0 -95
- package/build/module/src/ai/wrap.js.map +0 -1
- package/build/module/src/db/base.d.ts +0 -23
- package/build/module/src/db/base.js +0 -87
- package/build/module/src/db/base.js.map +0 -1
- package/build/module/src/db/cloudflare.d.ts +0 -21
- package/build/module/src/db/cloudflare.js +0 -98
- package/build/module/src/db/cloudflare.js.map +0 -1
- package/build/module/src/db/index.d.ts +0 -6
- package/build/module/src/db/index.js +0 -7
- package/build/module/src/db/index.js.map +0 -1
- package/build/module/src/db/memory.d.ts +0 -21
- package/build/module/src/db/memory.js +0 -99
- package/build/module/src/db/memory.js.map +0 -1
- package/build/module/src/db/pinecone.d.ts +0 -21
- package/build/module/src/db/pinecone.js +0 -71
- package/build/module/src/db/pinecone.js.map +0 -1
- package/build/module/src/db/types.d.ts +0 -35
- package/build/module/src/db/types.js +0 -3
- package/build/module/src/db/types.js.map +0 -1
- package/build/module/src/db/weaviate.d.ts +0 -21
- package/build/module/src/db/weaviate.js +0 -127
- package/build/module/src/db/weaviate.js.map +0 -1
- package/build/module/src/db/wrap.d.ts +0 -13
- package/build/module/src/db/wrap.js +0 -35
- package/build/module/src/db/wrap.js.map +0 -1
- package/build/module/src/docs/index.d.ts +0 -4
- package/build/module/src/docs/index.js +0 -5
- package/build/module/src/docs/index.js.map +0 -1
- package/build/module/src/docs/manager.d.ts +0 -45
- package/build/module/src/docs/manager.js +0 -159
- package/build/module/src/docs/manager.js.map +0 -1
- package/build/module/src/docs/reranker.d.ts +0 -7
- package/build/module/src/docs/reranker.js +0 -26
- package/build/module/src/docs/reranker.js.map +0 -1
- package/build/module/src/docs/rewriter.d.ts +0 -4
- package/build/module/src/docs/rewriter.js +0 -9
- package/build/module/src/docs/rewriter.js.map +0 -1
- package/build/module/src/docs/tika.d.ts +0 -18
- package/build/module/src/docs/tika.js +0 -46
- package/build/module/src/docs/tika.js.map +0 -1
- package/build/module/src/dsp/asserts.d.ts +0 -32
- package/build/module/src/dsp/asserts.js +0 -91
- package/build/module/src/dsp/asserts.js.map +0 -1
- package/build/module/src/dsp/eval.d.ts +0 -43
- package/build/module/src/dsp/eval.js +0 -125
- package/build/module/src/dsp/eval.js.map +0 -1
- package/build/module/src/dsp/evaluate.d.ts +0 -12
- package/build/module/src/dsp/evaluate.js +0 -32
- package/build/module/src/dsp/evaluate.js.map +0 -1
- package/build/module/src/dsp/extract.d.ts +0 -25
- package/build/module/src/dsp/extract.js +0 -153
- package/build/module/src/dsp/extract.js.map +0 -1
- package/build/module/src/dsp/generate.d.ts +0 -55
- package/build/module/src/dsp/generate.js +0 -314
- package/build/module/src/dsp/generate.js.map +0 -1
- package/build/module/src/dsp/generate.test.d.ts +0 -1
- package/build/module/src/dsp/generate.test.js +0 -41
- package/build/module/src/dsp/generate.test.js.map +0 -1
- package/build/module/src/dsp/index.d.ts +0 -15
- package/build/module/src/dsp/index.js +0 -11
- package/build/module/src/dsp/index.js.map +0 -1
- package/build/module/src/dsp/loader.d.ts +0 -30
- package/build/module/src/dsp/loader.js +0 -81
- package/build/module/src/dsp/loader.js.map +0 -1
- package/build/module/src/dsp/optimize.d.ts +0 -27
- package/build/module/src/dsp/optimize.js +0 -95
- package/build/module/src/dsp/optimize.js.map +0 -1
- package/build/module/src/dsp/parser.d.ts +0 -87
- package/build/module/src/dsp/parser.js +0 -1542
- package/build/module/src/dsp/parser.js.map +0 -1
- package/build/module/src/dsp/program.d.ts +0 -73
- package/build/module/src/dsp/program.js +0 -116
- package/build/module/src/dsp/program.js.map +0 -1
- package/build/module/src/dsp/prompt.d.ts +0 -48
- package/build/module/src/dsp/prompt.js +0 -260
- package/build/module/src/dsp/prompt.js.map +0 -1
- package/build/module/src/dsp/registry.d.ts +0 -6
- package/build/module/src/dsp/registry.js +0 -15
- package/build/module/src/dsp/registry.js.map +0 -1
- package/build/module/src/dsp/router.d.ts +0 -26
- package/build/module/src/dsp/router.js +0 -71
- package/build/module/src/dsp/router.js.map +0 -1
- package/build/module/src/dsp/sig.d.ts +0 -37
- package/build/module/src/dsp/sig.js +0 -194
- package/build/module/src/dsp/sig.js.map +0 -1
- package/build/module/src/dsp/sig.test.d.ts +0 -1
- package/build/module/src/dsp/sig.test.js +0 -28
- package/build/module/src/dsp/sig.test.js.map +0 -1
- package/build/module/src/dsp/stopwords.d.ts +0 -1
- package/build/module/src/dsp/stopwords.js +0 -1164
- package/build/module/src/dsp/stopwords.js.map +0 -1
- package/build/module/src/dsp/strutil.d.ts +0 -11
- package/build/module/src/dsp/strutil.js +0 -60
- package/build/module/src/dsp/strutil.js.map +0 -1
- package/build/module/src/dsp/util.d.ts +0 -5
- package/build/module/src/dsp/util.js +0 -76
- package/build/module/src/dsp/util.js.map +0 -1
- package/build/module/src/funcs/code.d.ts +0 -9
- package/build/module/src/funcs/code.js +0 -63
- package/build/module/src/funcs/code.js.map +0 -1
- package/build/module/src/funcs/embed.d.ts +0 -6
- package/build/module/src/funcs/embed.js +0 -29
- package/build/module/src/funcs/embed.js.map +0 -1
- package/build/module/src/funcs/functions.d.ts +0 -16
- package/build/module/src/funcs/functions.js +0 -55
- package/build/module/src/funcs/functions.js.map +0 -1
- package/build/module/src/funcs/index.d.ts +0 -3
- package/build/module/src/funcs/index.js +0 -4
- package/build/module/src/funcs/index.js.map +0 -1
- package/build/module/src/funcs/jsonschema.d.ts +0 -2
- package/build/module/src/funcs/jsonschema.js +0 -97
- package/build/module/src/funcs/jsonschema.js.map +0 -1
- package/build/module/src/index.d.ts +0 -9
- package/build/module/src/index.js.map +0 -1
- package/build/module/src/mem/index.d.ts +0 -2
- package/build/module/src/mem/index.js +0 -3
- package/build/module/src/mem/index.js.map +0 -1
- package/build/module/src/mem/memory.d.ts +0 -16
- package/build/module/src/mem/memory.js +0 -77
- package/build/module/src/mem/memory.js.map +0 -1
- package/build/module/src/mem/types.d.ts +0 -10
- package/build/module/src/mem/types.js +0 -2
- package/build/module/src/mem/types.js.map +0 -1
- package/build/module/src/prompts/agent.d.ts +0 -34
- package/build/module/src/prompts/agent.js +0 -108
- package/build/module/src/prompts/agent.js.map +0 -1
- package/build/module/src/prompts/cot.d.ts +0 -9
- package/build/module/src/prompts/cot.js +0 -17
- package/build/module/src/prompts/cot.js.map +0 -1
- package/build/module/src/prompts/index.d.ts +0 -4
- package/build/module/src/prompts/index.js +0 -5
- package/build/module/src/prompts/index.js.map +0 -1
- package/build/module/src/prompts/prompts.test.d.ts +0 -1
- package/build/module/src/prompts/prompts.test.js +0 -54
- package/build/module/src/prompts/prompts.test.js.map +0 -1
- package/build/module/src/prompts/rag.d.ts +0 -23
- package/build/module/src/prompts/rag.js +0 -30
- package/build/module/src/prompts/rag.js.map +0 -1
- package/build/module/src/prompts/react.d.ts +0 -8
- package/build/module/src/prompts/react.js +0 -22
- package/build/module/src/prompts/react.js.map +0 -1
- package/build/module/src/trace/index.d.ts +0 -171
- package/build/module/src/trace/index.js +0 -67
- package/build/module/src/trace/index.js.map +0 -1
- package/build/module/src/util/apicall.d.ts +0 -18
- package/build/module/src/util/apicall.js +0 -50
- package/build/module/src/util/apicall.js.map +0 -1
- package/build/module/src/util/log.d.ts +0 -14
- package/build/module/src/util/log.js +0 -31
- package/build/module/src/util/log.js.map +0 -1
- package/build/module/src/util/other.d.ts +0 -1
- package/build/module/src/util/other.js +0 -5
- package/build/module/src/util/other.js.map +0 -1
- package/build/module/src/util/rate-limit.d.ts +0 -24
- package/build/module/src/util/rate-limit.js +0 -49
- package/build/module/src/util/rate-limit.js.map +0 -1
- package/build/module/src/util/stream.d.ts +0 -9
- package/build/module/src/util/stream.js +0 -29
- package/build/module/src/util/stream.js.map +0 -1
- package/build/module/src/util/transform.d.ts +0 -7
- package/build/module/src/util/transform.js +0 -59
- package/build/module/src/util/transform.js.map +0 -1
- /package/{build/module/src/index.js → index.js} +0 -0
package/README.md
DELETED
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
# Ax - Build LLMs Powered Agents (Typescript)
|
|
2
|
-
|
|
3
|
-
Build intelligent agents with ease, inspired by the power of "Agentic workflows" and the Stanford DSP paper. Seamlessly integrates with multiple LLMs and VectorDBs to build RAG pipelines or collaborative agents that can solve complex problems. Advanced features streaming validation, multi-modal DSP, etc.
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@ax-llm/ax)
|
|
6
|
-
[](https://discord.gg/DSHg3dU7dW)
|
|
7
|
-
[](https://twitter.com/dosco)
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-
|
|
11
|
-
## Our focus on agents
|
|
12
|
-
|
|
13
|
-
We've renamed from "llmclient" to "ax" to highlight our focus on powering agentic workflows. We agree with many experts like "Andrew Ng" that agentic workflows are the key to unlocking the true power of large language models and what can be achieved with in-context learning. Also we are big fans of the Stanford DSP paper and this library is the result of all of this coming together to build a powerful framework for you to build with.
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-
|
|
17
|
-
## Why use Ax?
|
|
18
|
-
|
|
19
|
-
- Support for various LLMs and Vector DBs
|
|
20
|
-
- Prompts auto-generated from simple signatures
|
|
21
|
-
- Build Agents that can call other agents
|
|
22
|
-
- Convert docs of any format to text
|
|
23
|
-
- RAG, smart chunking, embedding, querying
|
|
24
|
-
- Output validation while streaming
|
|
25
|
-
- Multi-modal DSP supported
|
|
26
|
-
- Automatic prompt tuning using optimizers
|
|
27
|
-
- OpenTelemetry tracing / observability
|
|
28
|
-
- Production ready Typescript code
|
|
29
|
-
- Lite weight, zero-dependencies
|
|
30
|
-
|
|
31
|
-
## Whats a prompt signature?
|
|
32
|
-
|
|
33
|
-
<img width="860" alt="shapes at 24-03-31 00 05 55" src="https://github.com/dosco/llm-client/assets/832235/0f0306ea-1812-4a0a-9ed5-76cd908cd26b">
|
|
34
|
-
|
|
35
|
-
Efficient type-safe prompts are auto-generated from a simple signature. A prompt signature is made up of a `"task description" inputField:type "field description" -> outputField:type"`. The idea behind prompt signatures is based off work done in the "Demonstrate-Search-Predict" paper.
|
|
36
|
-
|
|
37
|
-
You can have multiple input and output fields and each field has one of these types `string`, `number`, `boolean`, `json` or a array of any of these eg. `string[]`. When a type is not defined it defaults to `string`. When the `json` type if used the underlying AI is encouraged to generate correct JSON.
|
|
38
|
-
|
|
39
|
-
## LLMs Supported
|
|
40
|
-
|
|
41
|
-
| Provider | Best Models | Tested |
|
|
42
|
-
| ------------- | ----------------------- | ------- |
|
|
43
|
-
| OpenAI | GPT: 4o, 4T, 4, 3.5 | 🟢 100% |
|
|
44
|
-
| Azure OpenAI | GPT: 4, 4T, 3.5 | 🟢 100% |
|
|
45
|
-
| Together | Several OSS Models | 🟢 100% |
|
|
46
|
-
| Cohere | CommandR, Command | 🟢 100% |
|
|
47
|
-
| Anthropic | Claude 2, Claude 3 | 🟢 100% |
|
|
48
|
-
| Mistral | 7B, 8x7B, S, M & L | 🟢 100% |
|
|
49
|
-
| Groq | Lama2-70B, Mixtral-8x7b | 🟢 100% |
|
|
50
|
-
| DeepSeek | Chat and Code | 🟢 100% |
|
|
51
|
-
| Ollama | All models | 🟢 100% |
|
|
52
|
-
| Google Gemini | Gemini: Flash, Pro | 🟢 100% |
|
|
53
|
-
| Hugging Face | OSS Model | 🟡 50% |
|
|
54
|
-
|
|
55
|
-
## Install
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npm install @ax-llm/ax
|
|
59
|
-
# or
|
|
60
|
-
yarn add @ax-llm/ax
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Example: Using chain-of-thought to summarize text
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import { AxAI, AxChainOfThought } from '@ax-llm/ax';
|
|
67
|
-
|
|
68
|
-
const textToSummarize = `
|
|
69
|
-
The technological singularity—or simply the singularity[1]—is a hypothetical future point in time at which technological growth becomes uncontrollable and irreversible, resulting in unforeseeable changes to human civilization.[2][3] ...`;
|
|
70
|
-
|
|
71
|
-
const ai = new AxAI({
|
|
72
|
-
name: 'openai',
|
|
73
|
-
apiKey: process.env.OPENAI_APIKEY as string
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const gen = new AxChainOfThought(
|
|
77
|
-
ai,
|
|
78
|
-
`textToSummarize -> shortSummary "summarize in 5 to 10 words"`
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const res = await gen.forward({ textToSummarize });
|
|
82
|
-
|
|
83
|
-
console.log('>', res);
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Example: Building an agent
|
|
87
|
-
|
|
88
|
-
Use the agent prompt (framework) to build agents that work with other agents to complete tasks. Agents are easy to build with prompt signatures. Try out the agent example.
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
# npm run tsx ./src/examples/agent.ts
|
|
92
|
-
|
|
93
|
-
const researcher = new AxAgent(ai, {
|
|
94
|
-
name: 'researcher',
|
|
95
|
-
description: 'Researcher agent',
|
|
96
|
-
signature: `physicsQuestion "physics questions" -> answer "reply in bullet points"`
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const summarizer = new AxAgent(ai, {
|
|
100
|
-
name: 'summarizer',
|
|
101
|
-
description: 'Summarizer agent',
|
|
102
|
-
signature: `text "text so summarize" -> shortSummary "summarize in 5 to 10 words"`
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const agent = new AxAgent(ai, {
|
|
106
|
-
name: 'agent',
|
|
107
|
-
description: 'A an agent to research complex topics',
|
|
108
|
-
signature: `question -> answer`,
|
|
109
|
-
agents: [researcher, summarizer]
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
agent.forward({ questions: "How many atoms are there in the universe" })
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Vector DBs Supported
|
|
116
|
-
|
|
117
|
-
Vector databases are critical to building LLM workflows. We have clean abstractions over popular vector db's as well as our own quick in memory vector database.
|
|
118
|
-
|
|
119
|
-
| Provider | Tested |
|
|
120
|
-
| ---------- | ------- |
|
|
121
|
-
| In Memory | 🟢 100% |
|
|
122
|
-
| Weaviate | 🟢 100% |
|
|
123
|
-
| Cloudflare | 🟡 50% |
|
|
124
|
-
| Pinecone | 🟡 50% |
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// Create embeddings from text using an LLM
|
|
128
|
-
const ret = await this.ai.embed({ texts: 'hello world' });
|
|
129
|
-
|
|
130
|
-
// Create an in memory vector db
|
|
131
|
-
const db = new axDB('memory');
|
|
132
|
-
|
|
133
|
-
// Insert into vector db
|
|
134
|
-
await this.db.upsert({
|
|
135
|
-
id: 'abc',
|
|
136
|
-
table: 'products',
|
|
137
|
-
values: ret.embeddings[0]
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Query for similar entries using embeddings
|
|
141
|
-
const matches = await this.db.query({
|
|
142
|
-
table: 'products',
|
|
143
|
-
values: embeddings[0]
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Alternatively you can use the `AxDBManager` which handles smart chunking, embedding and querying everything
|
|
148
|
-
for you, it makes things almost too easy.
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
const manager = new AxDBManager({ ai, db });
|
|
152
|
-
await manager.insert(text);
|
|
153
|
-
|
|
154
|
-
const matches = await manager.query(
|
|
155
|
-
'John von Neumann on human intelligence and singularity.'
|
|
156
|
-
);
|
|
157
|
-
console.log(matches);
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## RAG Documents
|
|
161
|
-
|
|
162
|
-
Using documents like PDF, DOCX, PPT, XLS, etc with LLMs is a huge pain. We make it easy with the help of Apache Tika an open source document processing engine.
|
|
163
|
-
|
|
164
|
-
Launch Apache Tika
|
|
165
|
-
|
|
166
|
-
```shell
|
|
167
|
-
docker run -p 9998:9998 apache/tika
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Convert documents to text and embed them for retrieval using the `AxDBManager` it also supports a reranker and query rewriter. Two default implementations `AxDefaultResultReranker` and `AxDefaultQueryRewriter` are available to use.
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
const tika = new AxApacheTika();
|
|
174
|
-
const text = await tika.convert('/path/to/document.pdf');
|
|
175
|
-
|
|
176
|
-
const manager = new AxDBManager({ ai, db });
|
|
177
|
-
await manager.insert(text);
|
|
178
|
-
|
|
179
|
-
const matches = await manager.query('Find some text');
|
|
180
|
-
console.log(matches);
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Multi-modal DSP
|
|
184
|
-
|
|
185
|
-
When using models like `gpt-4o` and `gemini` that support multi-modal prompts we support using image fields and this works with the whole dsp pipeline.
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
const image = fs
|
|
189
|
-
.readFileSync('./src/examples/assets/kitten.jpeg')
|
|
190
|
-
.toString('base64');
|
|
191
|
-
|
|
192
|
-
const gen = new AxChainOfThought(ai, `question, animalImage:image -> answer`);
|
|
193
|
-
|
|
194
|
-
const res = await gen.forward({
|
|
195
|
-
question: 'What family does this animal belong to?',
|
|
196
|
-
animalImage: { mimeType: 'image/jpeg', data: image }
|
|
197
|
-
});
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Streaming
|
|
201
|
-
|
|
202
|
-
We support parsing output fields and function execution while streaming. This allows for fail-fast and error correction without having to wait for the whole output saving tokens, cost and reducing latency. Assertions are a powerful way to ensure the output matches your requirements these work with streaming as well.
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
// setup the prompt program
|
|
206
|
-
const gen = new AxChainOfThought(
|
|
207
|
-
ai,
|
|
208
|
-
`startNumber:number -> next10Numbers:number[]`
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
// add a assertion to ensure that the number 5 is not in an output field
|
|
212
|
-
gen.addAssert(({ next10Numbers }: Readonly<{ next10Numbers: number[] }>) => {
|
|
213
|
-
return next10Numbers ? !next10Numbers.includes(5) : undefined;
|
|
214
|
-
}, 'Numbers 5 is not allowed');
|
|
215
|
-
|
|
216
|
-
// run the program with streaming enabled
|
|
217
|
-
const res = await gen.forward({ startNumber: 1 }, { stream: true });
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
The above example will allow you to validate entire output fields as they are streamed in. This validation works with streaming and when not streaming and is triggered when the entire field value is available. For true validation while streaming checkout the below example. This will massively improve performance and save tokens at scale in production
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
// add a assertion to ensure all lines start with a number and a dot.
|
|
224
|
-
gen.addStreamingAssert(
|
|
225
|
-
'answerInPoints',
|
|
226
|
-
(value: string) => {
|
|
227
|
-
const re = /^\d+\./;
|
|
228
|
-
|
|
229
|
-
// split the value by lines, trim each line,
|
|
230
|
-
// filter out empty lines and check if all lines match the regex
|
|
231
|
-
return value
|
|
232
|
-
.split('\n')
|
|
233
|
-
.map((x) => x.trim())
|
|
234
|
-
.filter((x) => x.length > 0)
|
|
235
|
-
.every((x) => re.test(x));
|
|
236
|
-
},
|
|
237
|
-
'Lines must start with a number and a dot. Eg: 1. This is a line.'
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
// run the program with streaming enabled
|
|
241
|
-
const res = await gen.forward(
|
|
242
|
-
{
|
|
243
|
-
question: 'Provide a list of optimizations to speedup LLM inference.'
|
|
244
|
-
},
|
|
245
|
-
{ stream: true, debug: true }
|
|
246
|
-
);
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## Fast LLM Router
|
|
250
|
-
|
|
251
|
-
A special router that uses no LLM calls only embeddings to route user requests smartly.
|
|
252
|
-
|
|
253
|
-
Use the Router to efficiently route user queries to specific routes designed to handle certain types of questions or tasks. Each route is tailored to a particular domain or service area. Instead of using a slow or expensive LLM to decide how input from the user should be handled use our fast "Semantic Router" that uses inexpensive and fast embedding queries.
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
# npm run tsx ./src/examples/routing.ts
|
|
257
|
-
|
|
258
|
-
const customerSupport = new AxRoute('customerSupport', [
|
|
259
|
-
'how can I return a product?',
|
|
260
|
-
'where is my order?',
|
|
261
|
-
'can you help me with a refund?',
|
|
262
|
-
'I need to update my shipping address',
|
|
263
|
-
'my product arrived damaged, what should I do?'
|
|
264
|
-
]);
|
|
265
|
-
|
|
266
|
-
const technicalSupport = new AxRoute('technicalSupport', [
|
|
267
|
-
'how do I install your software?',
|
|
268
|
-
'I’m having trouble logging in',
|
|
269
|
-
'can you help me configure my settings?',
|
|
270
|
-
'my application keeps crashing',
|
|
271
|
-
'how do I update to the latest version?'
|
|
272
|
-
]);
|
|
273
|
-
|
|
274
|
-
const ai = new AxAI({ name: 'openai', apiKey: process.env.OPENAI_APIKEY as string });
|
|
275
|
-
|
|
276
|
-
const router = new AxRouter(ai);
|
|
277
|
-
await router.setRoutes(
|
|
278
|
-
[customerSupport, technicalSupport],
|
|
279
|
-
{ filename: 'router.json' }
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
const tag = await router.forward('I need help with my order');
|
|
283
|
-
|
|
284
|
-
if (tag === "customerSupport") {
|
|
285
|
-
...
|
|
286
|
-
}
|
|
287
|
-
if (tag === "technicalSupport") {
|
|
288
|
-
...
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
## OpenTelemetry support
|
|
293
|
-
|
|
294
|
-
Ability to trace and observe your llm workflow is critical to building production workflows. OpenTelemetry is an industry standard and we support the new `gen_ai` attribute namespace.
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
import { trace } from '@opentelemetry/api';
|
|
298
|
-
import {
|
|
299
|
-
BasicTracerProvider,
|
|
300
|
-
ConsoleSpanExporter,
|
|
301
|
-
SimpleSpanProcessor
|
|
302
|
-
} from '@opentelemetry/sdk-trace-base';
|
|
303
|
-
|
|
304
|
-
const provider = new BasicTracerProvider();
|
|
305
|
-
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
|
306
|
-
trace.setGlobalTracerProvider(provider);
|
|
307
|
-
|
|
308
|
-
const tracer = trace.getTracer('test');
|
|
309
|
-
|
|
310
|
-
const ai = new AxAI({
|
|
311
|
-
name: 'ollama',
|
|
312
|
-
config: { model: 'nous-hermes2' },
|
|
313
|
-
options: { tracer }
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
const gen = new AxChainOfThought(
|
|
317
|
-
ai,
|
|
318
|
-
`text -> shortSummary "summarize in 5 to 10 words"`
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
const res = await gen.forward({ text });
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
```json
|
|
325
|
-
{
|
|
326
|
-
"traceId": "ddc7405e9848c8c884e53b823e120845",
|
|
327
|
-
"name": "Chat Request",
|
|
328
|
-
"id": "d376daad21da7a3c",
|
|
329
|
-
"kind": "SERVER",
|
|
330
|
-
"timestamp": 1716622997025000,
|
|
331
|
-
"duration": 14190456.542,
|
|
332
|
-
"attributes": {
|
|
333
|
-
"gen_ai.system": "Ollama",
|
|
334
|
-
"gen_ai.request.model": "nous-hermes2",
|
|
335
|
-
"gen_ai.request.max_tokens": 500,
|
|
336
|
-
"gen_ai.request.temperature": 0.1,
|
|
337
|
-
"gen_ai.request.top_p": 0.9,
|
|
338
|
-
"gen_ai.request.frequency_penalty": 0.5,
|
|
339
|
-
"gen_ai.request.llm_is_streaming": false,
|
|
340
|
-
"http.request.method": "POST",
|
|
341
|
-
"url.full": "http://localhost:11434/v1/chat/completions",
|
|
342
|
-
"gen_ai.usage.completion_tokens": 160,
|
|
343
|
-
"gen_ai.usage.prompt_tokens": 290
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
## Tuning the prompts (programs)
|
|
349
|
-
|
|
350
|
-
You can tune your prompts using a larger model to help them run more efficiently and give you better results. This is done by using an optimizer like `AxBootstrapFewShot` with and examples from the popular `HotPotQA` dataset. The optimizer generates demonstrations `demos` which when used with the prompt help improve its efficiency.
|
|
351
|
-
|
|
352
|
-
```typescript
|
|
353
|
-
// Download the HotPotQA dataset from huggingface
|
|
354
|
-
const hf = new AxHFDataLoader({
|
|
355
|
-
dataset: 'hotpot_qa',
|
|
356
|
-
split: 'train'
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const examples = await hf.getData<{ question: string; answer: string }>({
|
|
360
|
-
count: 100,
|
|
361
|
-
fields: ['question', 'answer']
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
const ai = new AxAI({
|
|
365
|
-
name: 'openai',
|
|
366
|
-
apiKey: process.env.OPENAI_APIKEY as string
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// Setup the program to tune
|
|
370
|
-
const program = new AxChainOfThought<{ question: string }, { answer: string }>(
|
|
371
|
-
ai,
|
|
372
|
-
`question -> answer "in short 2 or 3 words"`
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
// Setup a Bootstrap Few Shot optimizer to tune the above program
|
|
376
|
-
const optimize = new AxBootstrapFewShot<
|
|
377
|
-
{ question: string },
|
|
378
|
-
{ answer: string }
|
|
379
|
-
>({
|
|
380
|
-
program,
|
|
381
|
-
examples
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// Setup a evaluation metric em, f1 scores are a popular way measure retrieval performance.
|
|
385
|
-
const metricFn: AxMetricFn = ({ prediction, example }) =>
|
|
386
|
-
emScore(prediction.answer as string, example.answer as string);
|
|
387
|
-
|
|
388
|
-
// Run the optimizer and remember to save the result to use later
|
|
389
|
-
const result = await optimize.compile(metricFn);
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
<img width="853" alt="tune-prompt" src="https://github.com/dosco/llm-client/assets/832235/f924baa7-8922-424c-9c2c-f8b2018d8d74">
|
|
393
|
-
|
|
394
|
-
And to use the generated demos with the above `ChainOfThought` program
|
|
395
|
-
|
|
396
|
-
```typescript
|
|
397
|
-
const ai = new AxAI({
|
|
398
|
-
name: 'openai',
|
|
399
|
-
apiKey: process.env.OPENAI_APIKEY as string
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
// Setup the program to use the tuned data
|
|
403
|
-
const program = new AxChainOfThought<{ question: string }, { answer: string }>(
|
|
404
|
-
ai,
|
|
405
|
-
`question -> answer "in short 2 or 3 words"`
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
// load tuning data
|
|
409
|
-
program.loadDemos('demos.json');
|
|
410
|
-
|
|
411
|
-
const res = await program.forward({
|
|
412
|
-
question: 'What castle did David Gregory inherit?'
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
console.log(res);
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
## Checkout all the examples
|
|
419
|
-
|
|
420
|
-
Use the `tsx` command to run the examples it makes node run typescript code. It also support using a `.env` file to pass the AI API Keys as opposed to putting them in the commandline.
|
|
421
|
-
|
|
422
|
-
```shell
|
|
423
|
-
OPENAI_APIKEY=openai_key npm run tsx ./src/examples/marketing.ts
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
| Example | Description |
|
|
427
|
-
| ------------------- | ------------------------------------------------------- |
|
|
428
|
-
| customer-support.ts | Extract valuable details from customer communications |
|
|
429
|
-
| food-search.ts | Use multiple APIs are used to find dinning options |
|
|
430
|
-
| marketing.ts | Generate short effective marketing sms messages |
|
|
431
|
-
| vectordb.ts | Chunk, embed and search text |
|
|
432
|
-
| fibonacci.ts | Use the JS code interpreter to compute fibonacci |
|
|
433
|
-
| summarize.ts | Generate a short summary of a large block of text |
|
|
434
|
-
| chain-of-thought.ts | Use chain-of-thought prompting to answer questions |
|
|
435
|
-
| rag.ts | Use multi-hop retrieval to answer questions |
|
|
436
|
-
| rag-docs.ts | Convert PDF to text and embed for rag search |
|
|
437
|
-
| react.ts | Use function calling and reasoning to answer questions |
|
|
438
|
-
| agent.ts | Agent framework, agents can use other agents, tools etc |
|
|
439
|
-
| qna-tune.ts | Use an optimizer to improve prompt efficiency |
|
|
440
|
-
| qna-use-tuned.ts | Use the optimized tuned prompts |
|
|
441
|
-
| streaming1.ts | Output fields validation while streaming |
|
|
442
|
-
| streaming2.ts | Per output field validation while streaming |
|
|
443
|
-
| smart-hone.ts | Agent looks for dog in smart home |
|
|
444
|
-
| multi-modal.ts | Use an image input along with other text inputs |
|
|
445
|
-
| balancer.ts | Balance between various llm's based on cost, etc |
|
|
446
|
-
|
|
447
|
-
## Built-in Functions
|
|
448
|
-
|
|
449
|
-
| Function | Description |
|
|
450
|
-
| ------------------ | ------------------------------------------------------ |
|
|
451
|
-
| Code Interpreter | Used by the LLM to execute JS code in a sandboxed env. |
|
|
452
|
-
| Embeddings Adapter | Wrapper to fetch and pass embedding to your function |
|
|
453
|
-
|
|
454
|
-
## Our Goal
|
|
455
|
-
|
|
456
|
-
Large language models (LLMs) are getting really powerful and have reached a point where they can work as the backend for your entire product. However there's still a lot of complexity to manage from using the right prompts, models, streaming, function calling, error-correction, and much more. Our goal is to package all this complexity into a well maintained easy to use library that can work with all the LLMs out there. Additionally we are using the latest research to add useful new capabilities like DSP to the library.
|
|
457
|
-
|
|
458
|
-
## How to use this library?
|
|
459
|
-
|
|
460
|
-
### 1. Pick an AI to work with
|
|
461
|
-
|
|
462
|
-
```ts
|
|
463
|
-
// Pick a LLM
|
|
464
|
-
const ai = new AxOpenAI({ apiKey: process.env.OPENAI_APIKEY } as AxOpenAIArgs);
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
### 2. Create a prompt signature based on your usecase
|
|
468
|
-
|
|
469
|
-
```ts
|
|
470
|
-
// Signature defines the inputs and outputs of your prompt program
|
|
471
|
-
const cot = new ChainOfThought(ai, `question:string -> answer:string`, { mem });
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
### 3. Execute this new prompt program
|
|
475
|
-
|
|
476
|
-
```ts
|
|
477
|
-
// Pass in the input fields defined in the above signature
|
|
478
|
-
const res = await cot.forward({ question: 'Are we in a simulation?' });
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
### 4. Or if you just want to directly use the LLM
|
|
482
|
-
|
|
483
|
-
```ts
|
|
484
|
-
const res = await ai.chat([
|
|
485
|
-
{ role: "system", content: "Help the customer with his questions" }
|
|
486
|
-
{ role: "user", content: "I'm looking for a Macbook Pro M2 With 96GB RAM?" }
|
|
487
|
-
]);
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
## How do you use function calling
|
|
491
|
-
|
|
492
|
-
### 1. Define the functions
|
|
493
|
-
|
|
494
|
-
```ts
|
|
495
|
-
// define one or more functions and a function handler
|
|
496
|
-
const functions = [
|
|
497
|
-
{
|
|
498
|
-
name: 'getCurrentWeather',
|
|
499
|
-
description: 'get the current weather for a location',
|
|
500
|
-
parameters: {
|
|
501
|
-
type: 'object',
|
|
502
|
-
properties: {
|
|
503
|
-
location: {
|
|
504
|
-
type: 'string',
|
|
505
|
-
description: 'location to get weather for'
|
|
506
|
-
},
|
|
507
|
-
units: {
|
|
508
|
-
type: 'string',
|
|
509
|
-
enum: ['imperial', 'metric'],
|
|
510
|
-
default: 'imperial',
|
|
511
|
-
description: 'units to use'
|
|
512
|
-
}
|
|
513
|
-
},
|
|
514
|
-
required: ['location']
|
|
515
|
-
},
|
|
516
|
-
func: async (args: Readonly<{ location: string; units: string }>) => {
|
|
517
|
-
return `The weather in ${args.location} is 72 degrees`;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
];
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
### 2. Pass the functions to a prompt
|
|
524
|
-
|
|
525
|
-
```ts
|
|
526
|
-
const cot = new AxReAct(ai, `question:string -> answer:string`, { functions });
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
## Enable debug logs
|
|
530
|
-
|
|
531
|
-
```ts
|
|
532
|
-
const ai = new AxOpenAI({ apiKey: process.env.OPENAI_APIKEY } as AxOpenAIArgs);
|
|
533
|
-
ai.setOptions({ debug: true });
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
## Reach out
|
|
537
|
-
|
|
538
|
-
We're happy to help reach out if you have questions or join the Discord
|
|
539
|
-
[twitter/dosco](https://twitter.com/dosco)
|
|
540
|
-
|
|
541
|
-
## FAQ
|
|
542
|
-
|
|
543
|
-
### 1. The LLM can't find the right function to use
|
|
544
|
-
|
|
545
|
-
Improve the function naming and description be very clear on what the function does. Also ensure the function parameter's also have good descriptions. The descriptions don't have to be very long but need to be clear.
|
|
546
|
-
|
|
547
|
-
### 2. How do I change the configuration of the LLM used
|
|
548
|
-
|
|
549
|
-
You can pass a configuration object as the second parameter when creating a new LLM object
|
|
550
|
-
|
|
551
|
-
```ts
|
|
552
|
-
const apiKey = process.env.OPENAI_APIKEY;
|
|
553
|
-
const conf = AxOpenAIBestConfig();
|
|
554
|
-
const ai = new AxOpenAI({ apiKey, conf } as AxOpenAIArgs);
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
## 3. My prompt is too long and can I change the max tokens
|
|
558
|
-
|
|
559
|
-
```ts
|
|
560
|
-
const conf = axOpenAIDefaultConfig(); // or OpenAIBestOptions()
|
|
561
|
-
conf.maxTokens = 2000;
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
## 4. How do I change the model say I want to use GPT4
|
|
565
|
-
|
|
566
|
-
```ts
|
|
567
|
-
const conf = axOpenAIDefaultConfig(); // or OpenAIBestOptions()
|
|
568
|
-
conf.model = OpenAIModel.GPT4Turbo;
|
|
569
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
(function (svg) {
|
|
2
|
-
svg.innerHTML = `<g id="icon-1"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-2"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-module)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g><g id="icon-8"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)"></path></g><g id="icon-16"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-32"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)"></path></g><g id="icon-64"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-128"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g><g id="icon-512"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-1024"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-2048"><rect fill="var(--color-icon-background)" stroke="#FF4DB8" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.162 16V7.24H10.578L11.514 10.072C11.602 10.328 11.674 10.584 11.73 10.84C11.794 11.088 11.842 11.28 11.874 11.416C11.906 11.28 11.954 11.088 12.018 10.84C12.082 10.584 12.154 10.324 12.234 10.06L13.122 7.24H14.538V16H13.482V12.82C13.482 12.468 13.49 12.068 13.506 11.62C13.53 11.172 13.558 10.716 13.59 10.252C13.622 9.78 13.654 9.332 13.686 8.908C13.726 8.476 13.762 8.1 13.794 7.78L12.366 12.16H11.334L9.894 7.78C9.934 8.092 9.97 8.456 10.002 8.872C10.042 9.28 10.078 9.716 10.11 10.18C10.142 10.636 10.166 11.092 10.182 11.548C10.206 12.004 10.218 12.428 10.218 12.82V16H9.162Z" fill="var(--color-text)"></path></g><g id="icon-4096"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)"></path></g><g id="icon-8192"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-16384"><rect fill="var(--color-icon-background)" stroke="#4D7FFF" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g><g id="icon-32768"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)"></path></g><g id="icon-65536"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-131072"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-262144"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-524288"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-1048576"><rect fill="var(--color-icon-background)" stroke="#FF4D4D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M8.85 16L11.13 7.24H12.582L14.85 16H13.758L13.182 13.672H10.53L9.954 16H8.85ZM10.746 12.76H12.954L12.282 10.06C12.154 9.548 12.054 9.12 11.982 8.776C11.91 8.432 11.866 8.208 11.85 8.104C11.834 8.208 11.79 8.432 11.718 8.776C11.646 9.12 11.546 9.544 11.418 10.048L10.746 12.76Z" fill="var(--color-text)"></path></g><g id="icon-2097152"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g><g id="icon-4194304"><rect fill="var(--color-icon-background)" stroke="#FF4D82" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12"></rect><path d="M10.354 17V8.24H13.066C13.586 8.24 14.042 8.348 14.434 8.564C14.826 8.772 15.13 9.064 15.346 9.44C15.562 9.816 15.67 10.256 15.67 10.76C15.67 11.352 15.514 11.86 15.202 12.284C14.898 12.708 14.482 13 13.954 13.16L15.79 17H14.518L12.838 13.28H11.434V17H10.354ZM11.434 12.308H13.066C13.514 12.308 13.874 12.168 14.146 11.888C14.418 11.6 14.554 11.224 14.554 10.76C14.554 10.288 14.418 9.912 14.146 9.632C13.874 9.352 13.514 9.212 13.066 9.212H11.434V12.308Z" fill="var(--color-text)"></path></g><g id="icon-chevronDown"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></g><g id="icon-chevronSmall"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></g><g id="icon-checkbox"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></g><g id="icon-menu"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></g><g id="icon-search"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></g><g id="icon-anchor"><g stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5"></path></g></g>`;
|
|
3
|
-
svg.style.display = 'none';
|
|
4
|
-
if (location.protocol === 'file:') {
|
|
5
|
-
if (document.readyState === 'loading')
|
|
6
|
-
document.addEventListener('DOMContentLoaded', updateUseElements);
|
|
7
|
-
else
|
|
8
|
-
updateUseElements();
|
|
9
|
-
function updateUseElements() {
|
|
10
|
-
document.querySelectorAll('use').forEach(el => {
|
|
11
|
-
if (el.getAttribute('href').includes('#icon-')) {
|
|
12
|
-
el.setAttribute('href', el.getAttribute('href').replace(/.*#/, '#'));
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
})(document.body.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'svg')));
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=icons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../../docs/assets/icons.js"],"names":[],"mappings":"AAAA,CAAC,UAAS,GAAG;IACT,GAAG,CAAC,SAAS,GAAG,wkcAAwkc,CAAC;IACzlc,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IAC3B,IAAI,QAAQ,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS;YAAE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;;YACnG,iBAAiB,EAAE,CAAA;QACxB,SAAS,iBAAiB;YACtB,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;gBAC1C,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7C,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;gBACzE,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|