API Reference
vectara_agentic package.
Agent
Agent class for handling different types of agents and their interactions.
Source code in vectara_agentic/agent.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
|
__init__(tools, topic='general', custom_instructions='', verbose=True, use_structured_planning=False, update_func=None, agent_progress_callback=None, query_logging_callback=None, agent_config=None, fallback_agent_config=None, chat_history=None, validate_tools=False, workflow_cls=None, workflow_timeout=120)
Initialize the agent with the specified type, tools, topic, and system message.
Args:
tools (list[FunctionTool]): A list of tools to be used by the agent.
topic (str, optional): The topic for the agent. Defaults to 'general'.
custom_instructions (str, optional): Custom instructions for the agent. Defaults to ''.
verbose (bool, optional): Whether the agent should print its steps. Defaults to True.
use_structured_planning (bool, optional)
Whether or not we want to wrap the agent with LlamaIndex StructuredPlannerAgent.
agent_progress_callback (Callable): A callback function the code calls on any agent updates.
update_func (Callable): old name for agent_progress_callback. Will be deprecated in future.
query_logging_callback (Callable): A callback function the code calls upon completion of a query
agent_config (AgentConfig, optional): The configuration of the agent.
Defaults to AgentConfig(), which reads from environment variables.
fallback_agent_config (AgentConfig, optional): The fallback configuration of the agent.
This config is used when the main agent config fails multiple times.
chat_history (Tuple[str, str], optional): A list of user/agent chat pairs to initialize the agent memory.
validate_tools (bool, optional): Whether to validate tool inconsistency with instructions.
Defaults to False.
workflow_cls (Workflow, optional): The workflow class to be used with run(). Defaults to None.
workflow_timeout (int, optional): The timeout for the workflow in seconds. Defaults to 120.
Source code in vectara_agentic/agent.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
achat(prompt)
async
Interact with the agent using a chat prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
str
|
The chat prompt. |
required |
Returns:
Name | Type | Description |
---|---|---|
AgentResponse |
AgentResponse
|
The response from the agent. |
Source code in vectara_agentic/agent.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
|
astream_chat(prompt)
async
Interact with the agent using a chat prompt asynchronously with streaming. Args: prompt (str): The chat prompt. Returns: AgentStreamingResponse: The streaming response from the agent.
Source code in vectara_agentic/agent.py
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
|
chat(prompt)
Interact with the agent using a chat prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
str
|
The chat prompt. |
required |
Returns:
Name | Type | Description |
---|---|---|
AgentResponse |
AgentResponse
|
The response from the agent. |
Source code in vectara_agentic/agent.py
706 707 708 709 710 711 712 713 714 715 716 |
|
clear_memory()
Clear the agent's memory.
Source code in vectara_agentic/agent.py
367 368 369 370 371 372 373 374 375 376 |
|
dumps()
Serialize the Agent instance to a JSON string.
Source code in vectara_agentic/agent.py
865 866 867 |
|
from_corpus(tool_name, data_description, assistant_specialty, vectara_corpus_key=str(os.environ.get('VECTARA_CORPUS_KEY', '')), vectara_api_key=str(os.environ.get('VECTARA_API_KEY', '')), agent_progress_callback=None, query_logging_callback=None, agent_config=AgentConfig(), fallback_agent_config=None, chat_history=None, verbose=False, vectara_filter_fields=[], vectara_offset=0, vectara_lambda_val=0.005, vectara_semantics='default', vectara_custom_dimensions={}, vectara_reranker='slingshot', vectara_rerank_k=50, vectara_rerank_limit=None, vectara_rerank_cutoff=None, vectara_diversity_bias=0.2, vectara_udf_expression=None, vectara_rerank_chain=None, vectara_n_sentences_before=2, vectara_n_sentences_after=2, vectara_summary_num_results=10, vectara_summarizer='vectara-summary-ext-24-05-med-omni', vectara_summary_response_language='eng', vectara_summary_prompt_text=None, vectara_max_response_chars=None, vectara_max_tokens=None, vectara_temperature=None, vectara_frequency_penalty=None, vectara_presence_penalty=None, vectara_save_history=True)
classmethod
Create an agent from a single Vectara corpus
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name
|
str
|
The name of Vectara tool used by the agent |
required |
vectara_corpus_key
|
str
|
The Vectara corpus key (or comma separated list of keys). |
str(get('VECTARA_CORPUS_KEY', ''))
|
vectara_api_key
|
str
|
The Vectara API key. |
str(get('VECTARA_API_KEY', ''))
|
agent_progress_callback
|
Callable
|
A callback function the code calls on any agent updates. |
None
|
query_logging_callback
|
Callable
|
A callback function the code calls upon completion of a query |
None
|
agent_config
|
AgentConfig
|
The configuration of the agent. |
AgentConfig()
|
fallback_agent_config
|
AgentConfig
|
The fallback configuration of the agent. |
None
|
chat_history
|
Tuple[str, str]
|
A list of user/agent chat pairs to initialize the agent memory. |
None
|
data_description
|
str
|
The description of the data. |
required |
assistant_specialty
|
str
|
The specialty of the assistant. |
required |
verbose
|
bool
|
Whether to print verbose output. |
False
|
vectara_filter_fields
|
List[dict]
|
The filterable attributes (each dict maps field name to Tuple[type, description]). |
[]
|
vectara_offset
|
int
|
Number of results to skip. |
0
|
vectara_lambda_val
|
float
|
Lambda value for Vectara hybrid search. |
0.005
|
vectara_semantics
|
str
|
(str, optional): Indicates whether the query is intended as a query or response. |
'default'
|
vectara_custom_dimensions
|
Dict
|
(Dict, optional): Custom dimensions for the query. |
{}
|
vectara_reranker
|
str
|
The Vectara reranker name (default "slingshot") |
'slingshot'
|
vectara_rerank_k
|
int
|
The number of results to use with reranking. |
50
|
vectara_rerank_limit
|
Optional[int]
|
(int, optional): The maximum number of results to return after reranking. |
None
|
vectara_rerank_cutoff
|
Optional[float]
|
(float, optional): The minimum score threshold for results to include after reranking. |
None
|
vectara_diversity_bias
|
float
|
The MMR diversity bias. |
0.2
|
vectara_udf_expression
|
str
|
The user defined expression for reranking results. |
None
|
vectara_rerank_chain
|
List[Dict]
|
A list of Vectara rerankers to be applied sequentially. |
None
|
vectara_n_sentences_before
|
int
|
The number of sentences before the matching text |
2
|
vectara_n_sentences_after
|
int
|
The number of sentences after the matching text. |
2
|
vectara_summary_num_results
|
int
|
The number of results to use in summarization. |
10
|
vectara_summarizer
|
str
|
The Vectara summarizer name. |
'vectara-summary-ext-24-05-med-omni'
|
vectara_summary_response_language
|
str
|
The response language for the Vectara summary. |
'eng'
|
vectara_summary_prompt_text
|
str
|
The custom prompt, using appropriate prompt variables and functions. |
None
|
vectara_max_response_chars
|
int
|
The desired maximum number of characters for the generated summary. |
None
|
vectara_max_tokens
|
int
|
The maximum number of tokens to be returned by the LLM. |
None
|
vectara_temperature
|
float
|
The sampling temperature; higher values lead to more randomness. |
None
|
vectara_frequency_penalty
|
float
|
How much to penalize repeating tokens in the response, higher values reducing likelihood of repeating the same line. |
None
|
vectara_presence_penalty
|
float
|
How much to penalize repeating tokens in the response, higher values increasing the diversity of topics. |
None
|
vectara_save_history
|
bool
|
Whether to save the query in history. |
True
|
Returns:
Name | Type | Description |
---|---|---|
Agent |
Agent
|
An instance of the Agent class. |
Source code in vectara_agentic/agent.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
|
from_dict(data)
classmethod
Create an Agent instance from a dictionary.
Source code in vectara_agentic/agent.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
|
from_tools(tools, topic='general', custom_instructions='', verbose=True, update_func=None, agent_progress_callback=None, query_logging_callback=None, agent_config=AgentConfig(), validate_tools=False, fallback_agent_config=None, chat_history=None, workflow_cls=None, workflow_timeout=120)
classmethod
Create an agent from tools, agent type, and language model.
Args:
tools (list[FunctionTool]): A list of tools to be used by the agent.
topic (str, optional): The topic for the agent. Defaults to 'general'.
custom_instructions (str, optional): custom instructions for the agent. Defaults to ''.
verbose (bool, optional): Whether the agent should print its steps. Defaults to True.
agent_progress_callback (Callable): A callback function the code calls on any agent updates.
update_func (Callable): old name for agent_progress_callback. Will be deprecated in future.
query_logging_callback (Callable): A callback function the code calls upon completion of a query
agent_config (AgentConfig, optional): The configuration of the agent.
fallback_agent_config (AgentConfig, optional): The fallback configuration of the agent.
chat_history (Tuple[str, str], optional): A list of user/agent chat pairs to initialize the agent memory.
validate_tools (bool, optional): Whether to validate tool inconsistency with instructions.
Defaults to False.
workflow_cls (Workflow, optional): The workflow class to be used with run(). Defaults to None.
workflow_timeout (int, optional): The timeout for the workflow in seconds. Defaults to 120.
Returns:
Name | Type | Description |
---|---|---|
Agent |
Agent
|
An instance of the Agent class. |
Source code in vectara_agentic/agent.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
loads(data)
classmethod
Create an Agent instance from a JSON string.
Source code in vectara_agentic/agent.py
869 870 871 872 |
|
report(detailed=False)
Get a report from the agent.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detailed
|
bool
|
Whether to include detailed information. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
None
|
The report from the agent. |
Source code in vectara_agentic/agent.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
|
run(inputs, verbose=False)
async
Run a workflow using the agent. workflow class must be provided in the agent constructor. Args: inputs (Any): The inputs to the workflow. verbose (bool, optional): Whether to print verbose output. Defaults to False. Returns: Any: The output of the workflow.
Source code in vectara_agentic/agent.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
|
stream_chat(prompt)
Interact with the agent using a chat prompt with streaming. Args: prompt (str): The chat prompt. Returns: AgentStreamingResponse: The streaming response from the agent.
Source code in vectara_agentic/agent.py
759 760 761 762 763 764 765 766 767 |
|
to_dict()
Serialize the Agent instance to a dictionary.
Source code in vectara_agentic/agent.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
|
token_counts()
Get the token counts for the agent and tools.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The token counts for the agent and tools. |
Source code in vectara_agentic/agent.py
672 673 674 675 676 677 678 679 680 681 682 |
|
AgentConfig
dataclass
Centralized configuration for the Vectara Agentic utilities.
Each field can default to either a hard-coded value or an environment variable. For example, if you have environment variables you want to fall back on, you can default to them here.
Source code in vectara_agentic/agent_config.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
from_dict(config_dict)
classmethod
Create an AgentConfig from a dictionary.
Source code in vectara_agentic/agent_config.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
to_dict()
Convert the AgentConfig to a dictionary.
Source code in vectara_agentic/agent_config.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
AgentStatusType
Bases: Enum
Enumeration for different types of agent statuses.
Source code in vectara_agentic/types.py
40 41 42 43 44 45 46 |
|
AgentType
Bases: Enum
Enumeration for different types of agents.
Source code in vectara_agentic/types.py
10 11 12 13 14 15 16 17 |
|
LLMRole
Bases: Enum
Enumeration for different types of LLM roles.
Source code in vectara_agentic/types.py
49 50 51 52 53 |
|
ModelProvider
Bases: Enum
Enumeration for different types of model providers.
Source code in vectara_agentic/types.py
26 27 28 29 30 31 32 33 34 35 36 37 |
|
ObserverType
Bases: Enum
Enumeration for different types of observability integrations.
Source code in vectara_agentic/types.py
19 20 21 22 23 |
|
ToolType
Bases: Enum
Enumeration for different types of tools.
Source code in vectara_agentic/types.py
56 57 58 59 |
|
ToolsCatalog
A curated set of tools for vectara-agentic
Source code in vectara_agentic/tools_catalog.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
critique_text(text=Field(description='the original text.'), role=Field(default=None, description='the role of the person providing critique.'), point_of_view=Field(default=None, description='the point of view with which to provide critique.'))
This is a helper tool. Critique the text from the specified point of view.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The original text. |
Field(description='the original text.')
|
role
|
str
|
The role of the person providing critique. |
Field(default=None, description='the role of the person providing critique.')
|
point_of_view
|
str
|
The point of view with which to provide critique. |
Field(default=None, description='the point of view with which to provide critique.')
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The critique of the text. |
Source code in vectara_agentic/tools_catalog.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
rephrase_text(text=Field(description='the original text.'), instructions=Field(description='the specific instructions for how to rephrase the text.'))
This is a helper tool. Use this tool to rephrase the text according to the provided instructions. For example, instructions could be "as a 5 year old would say it."
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The original text. |
Field(description='the original text.')
|
instructions
|
str
|
The specific instructions for how to rephrase the text. |
Field(description='the specific instructions for how to rephrase the text.')
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The rephrased text. |
Source code in vectara_agentic/tools_catalog.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
summarize_text(text=Field(description='the original text.'), expertise=Field(description='the expertise to apply to the summarization.'))
This is a helper tool. Use this tool to summarize text using a given expertise with no more than summary_max_length characters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The original text. |
Field(description='the original text.')
|
expertise
|
str
|
The expertise to apply to the summarization. |
Field(description='the expertise to apply to the summarization.')
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The summarized text. |
Source code in vectara_agentic/tools_catalog.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
ToolsFactory
A factory class for creating agent tools.
Source code in vectara_agentic/tools.py
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
|
create_tool(function, tool_type=ToolType.QUERY)
Create a tool from a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function
|
Callable
|
a function to convert into a tool. |
required |
tool_type
|
ToolType
|
the type of tool. |
QUERY
|
Returns:
Name | Type | Description |
---|---|---|
VectaraTool |
VectaraTool
|
A VectaraTool object. |
Source code in vectara_agentic/tools.py
946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
|
database_tools(tool_name_prefix='', content_description=None, sql_database=None, scheme=None, host='localhost', port='5432', user='postgres', password='Password', dbname='postgres', max_rows=1000)
Returns a list of database tools.
Args:
tool_name_prefix (str, optional): The prefix to add to the tool names. Defaults to "".
content_description (str, optional): The content description for the database. Defaults to None.
sql_database (SQLDatabase, optional): The SQLDatabase object. Defaults to None.
scheme (str, optional): The database scheme. Defaults to None.
host (str, optional): The database host. Defaults to "localhost".
port (str, optional): The database port. Defaults to "5432".
user (str, optional): The database user. Defaults to "postgres".
password (str, optional): The database password. Defaults to "Password".
dbname (str, optional): The database name. Defaults to "postgres".
You must specify either the sql_database object or the scheme, host, port, user, password, and dbname.
max_rows (int, optional): if specified, instructs the load_data tool to never return more than max_rows
rows. Defaults to 1000.
Returns:
Type | Description |
---|---|
List[VectaraTool]
|
List[VectaraTool]: A list of VectaraTool objects. |
Source code in vectara_agentic/tools.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
|
financial_tools()
Create a list of financial tools.
Source code in vectara_agentic/tools.py
1030 1031 1032 1033 1034 1035 1036 |
|
get_llama_index_tools(tool_package_name, tool_spec_name, tool_name_prefix='', **kwargs)
Get a tool from the llama_index hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_package_name
|
str
|
The name of the tool package. |
required |
tool_spec_name
|
str
|
The name of the tool spec. |
required |
tool_name_prefix
|
str
|
The prefix to add to the tool names (added to every tool in the spec). |
''
|
kwargs
|
dict
|
The keyword arguments to pass to the tool constructor (see Hub for tool specific details). |
{}
|
Returns:
Type | Description |
---|---|
List[VectaraTool]
|
List[VectaraTool]: A list of VectaraTool objects. |
Source code in vectara_agentic/tools.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
|
guardrail_tools()
Create a list of guardrail tools to avoid controversial topics.
Source code in vectara_agentic/tools.py
1024 1025 1026 1027 1028 |
|
legal_tools()
Create a list of legal tools.
Source code in vectara_agentic/tools.py
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
|
standard_tools()
Create a list of standard tools.
Source code in vectara_agentic/tools.py
1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
VectaraTool
Bases: FunctionTool
A subclass of FunctionTool adding the tool_type attribute.
Source code in vectara_agentic/tools.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
VectaraToolFactory
A factory class for creating Vectara RAG tools.
Source code in vectara_agentic/tools.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
|
__init__(vectara_corpus_key=str(os.environ.get('VECTARA_CORPUS_KEY', '')), vectara_api_key=str(os.environ.get('VECTARA_API_KEY', '')))
Initialize the VectaraToolFactory Args: vectara_corpus_key (str): The Vectara corpus key (or comma separated list of keys). vectara_api_key (str): The Vectara API key.
Source code in vectara_agentic/tools.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
|
create_rag_tool(tool_name, tool_description, tool_args_schema, tool_args_type={}, fixed_filter='', vectara_summarizer='vectara-summary-ext-24-05-med-omni', vectara_prompt_text=None, summary_num_results=5, summary_response_lang='eng', n_sentences_before=2, n_sentences_after=2, offset=0, lambda_val=0.005, semantics='default', custom_dimensions={}, reranker='slingshot', rerank_k=50, rerank_limit=None, rerank_cutoff=None, mmr_diversity_bias=0.2, udf_expression=None, rerank_chain=None, max_response_chars=None, max_tokens=None, temperature=None, frequency_penalty=None, presence_penalty=None, include_citations=True, save_history=False, fcs_threshold=0.0, verbose=False, vectara_base_url='https://api.vectara.io', vectara_verify_ssl=True)
Creates a RAG (Retrieve and Generate) tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name
|
str
|
The name of the tool. |
required |
tool_description
|
str
|
The description of the tool. |
required |
tool_args_schema
|
BaseModel
|
The schema for the tool arguments. |
required |
tool_args_type
|
Dict[str, dict]
|
attributes for each argument where they key is the field name and the value is a dictionary with the following keys: - 'type': the type of each filter attribute in Vectara (doc or part). - 'is_list': whether the filterable attribute is a list. |
{}
|
fixed_filter
|
str
|
A fixed Vectara filter condition to apply to all queries. |
''
|
vectara_summarizer
|
str
|
The Vectara summarizer to use. |
'vectara-summary-ext-24-05-med-omni'
|
vectara_prompt_text
|
str
|
The prompt text for the Vectara summarizer. |
None
|
summary_num_results
|
int
|
The number of summary results. |
5
|
summary_response_lang
|
str
|
The response language for the summary. |
'eng'
|
n_sentences_before
|
int
|
Number of sentences before the summary. |
2
|
n_sentences_after
|
int
|
Number of sentences after the summary. |
2
|
offset
|
int
|
Number of results to skip. |
0
|
lambda_val
|
Union[List[float] | float]
|
Lambda value (or list of values for each corpora) for the Vectara query, when using hybrid search. |
0.005
|
semantics
|
Union[List[str], str]
|
Indicates whether the query is intended as a query or response. Include list if using multiple corpora specifying the query type for each corpus. |
'default'
|
custom_dimensions
|
Union[List[Dict] | Dict]
|
Custom dimensions for the query (for each corpora). |
{}
|
reranker
|
str
|
The reranker mode. |
'slingshot'
|
rerank_k
|
int
|
Number of top-k documents for reranking. |
50
|
rerank_limit
|
int
|
Maximum number of results to return after reranking. |
None
|
rerank_cutoff
|
float
|
Minimum score threshold for results to include after reranking. |
None
|
mmr_diversity_bias
|
float
|
MMR diversity bias. |
0.2
|
udf_expression
|
str
|
The user defined expression for reranking results. |
None
|
rerank_chain
|
List[Dict]
|
A list of rerankers to be applied sequentially. Each dictionary should specify the "type" of reranker (mmr, slingshot, udf) and any other parameters (e.g. "limit" or "cutoff" for any type, "diversity_bias" for mmr, and "user_function" for udf). If using slingshot/multilingual_reranker_v1, it must be first in the list. |
None
|
max_response_chars
|
int
|
The desired maximum number of characters for the generated summary. |
None
|
max_tokens
|
int
|
The maximum number of tokens to be returned by the LLM. |
None
|
temperature
|
float
|
The sampling temperature; higher values lead to more randomness. |
None
|
frequency_penalty
|
float
|
How much to penalize repeating tokens in the response, higher values reducing likelihood of repeating the same line. |
None
|
presence_penalty
|
float
|
How much to penalize repeating tokens in the response, higher values increasing the diversity of topics. |
None
|
include_citations
|
bool
|
Whether to include citations in the response. If True, uses markdown vectara citations that requires the Vectara scale plan. |
True
|
save_history
|
bool
|
Whether to save the query in history. |
False
|
fcs_threshold
|
float
|
A threshold for factual consistency. If set above 0, the tool notifies the calling agent that it "cannot respond" if FCS is too low. |
0.0
|
verbose
|
bool
|
Whether to print verbose output. |
False
|
vectara_base_url
|
str
|
The base URL for the Vectara API. |
'https://api.vectara.io'
|
vectara_verify_ssl
|
bool
|
Whether to verify SSL certificates for the Vectara API. |
True
|
Returns:
Name | Type | Description |
---|---|---|
VectaraTool |
VectaraTool
|
A VectaraTool object. |
Source code in vectara_agentic/tools.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 |
|
create_search_tool(tool_name, tool_description, tool_args_schema, tool_args_type={}, fixed_filter='', lambda_val=0.005, semantics='default', custom_dimensions={}, offset=0, n_sentences_before=2, n_sentences_after=2, reranker='slingshot', rerank_k=50, rerank_limit=None, rerank_cutoff=None, mmr_diversity_bias=0.2, udf_expression=None, rerank_chain=None, save_history=True, verbose=False, vectara_base_url='https://api.vectara.io', vectara_verify_ssl=True)
Creates a Vectara search/retrieval tool
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name
|
str
|
The name of the tool. |
required |
tool_description
|
str
|
The description of the tool. |
required |
tool_args_schema
|
BaseModel
|
The schema for the tool arguments. |
required |
tool_args_type
|
Dict[str, str]
|
The type of each argument (doc or part). |
{}
|
fixed_filter
|
str
|
A fixed Vectara filter condition to apply to all queries. |
''
|
lambda_val
|
Union[List[float] | float]
|
Lambda value (or list of values for each corpora) for the Vectara query, when using hybrid search. |
0.005
|
semantics
|
Union[List[str], str]
|
Indicates whether the query is intended as a query or response. Include list if using multiple corpora specifying the query type for each corpus. |
'default'
|
custom_dimensions
|
Union[List[Dict] | Dict]
|
Custom dimensions for the query (for each corpora). |
{}
|
offset
|
int
|
Number of results to skip. |
0
|
n_sentences_before
|
int
|
Number of sentences before the matching document part. |
2
|
n_sentences_after
|
int
|
Number of sentences after the matching document part. |
2
|
reranker
|
str
|
The reranker mode. |
'slingshot'
|
rerank_k
|
int
|
Number of top-k documents for reranking. |
50
|
rerank_limit
|
int
|
Maximum number of results to return after reranking. |
None
|
rerank_cutoff
|
float
|
Minimum score threshold for results to include after reranking. |
None
|
mmr_diversity_bias
|
float
|
MMR diversity bias. |
0.2
|
udf_expression
|
str
|
the user defined expression for reranking results. |
None
|
rerank_chain
|
List[Dict]
|
A list of rerankers to be applied sequentially. Each dictionary should specify the "type" of reranker (mmr, slingshot, udf) and any other parameters (e.g. "limit" or "cutoff" for any type, "diversity_bias" for mmr, and "user_function" for udf). If using slingshot/multilingual_reranker_v1, it must be first in the list. |
None
|
save_history
|
bool
|
Whether to save the query in history. |
True
|
verbose
|
bool
|
Whether to print verbose output. |
False
|
vectara_base_url
|
str
|
The base URL for the Vectara API. |
'https://api.vectara.io'
|
vectara_verify_ssl
|
bool
|
Whether to verify SSL certificates for the Vectara API. |
True
|
Returns:
Name | Type | Description |
---|---|---|
VectaraTool |
VectaraTool
|
A VectaraTool object. |
Source code in vectara_agentic/tools.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
|
create_app(agent, config)
Create a FastAPI application with a chat endpoint.
Source code in vectara_agentic/agent_endpoint.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
start_app(agent, host='0.0.0.0', port=8000)
Start the FastAPI server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
The host address for the API. Defaults to '127.0.0.1'. |
'0.0.0.0'
|
port
|
int
|
The port for the API. Defaults to 8000. |
8000
|
Source code in vectara_agentic/agent_endpoint.py
53 54 55 56 57 58 59 60 61 62 |
|