vectara-agentic 0.1.28__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
Potentially problematic release.
This version of vectara-agentic might be problematic. Click here for more details.
- tests/endpoint.py +42 -0
- tests/test_agent.py +34 -20
- tests/test_private_llm.py +67 -0
- tests/test_tools.py +37 -14
- vectara_agentic/_callback.py +46 -36
- vectara_agentic/_prompts.py +3 -1
- vectara_agentic/_version.py +1 -1
- vectara_agentic/agent.py +152 -42
- vectara_agentic/agent_config.py +9 -0
- vectara_agentic/db_tools.py +2 -2
- vectara_agentic/tools.py +91 -26
- vectara_agentic/tools_catalog.py +1 -1
- vectara_agentic/types.py +3 -2
- vectara_agentic/utils.py +4 -0
- {vectara_agentic-0.1.28.dist-info → vectara_agentic-0.2.1.dist-info}/METADATA +32 -5
- vectara_agentic-0.2.1.dist-info/RECORD +23 -0
- vectara_agentic-0.1.28.dist-info/RECORD +0 -21
- {vectara_agentic-0.1.28.dist-info → vectara_agentic-0.2.1.dist-info}/LICENSE +0 -0
- {vectara_agentic-0.1.28.dist-info → vectara_agentic-0.2.1.dist-info}/WHEEL +0 -0
- {vectara_agentic-0.1.28.dist-info → vectara_agentic-0.2.1.dist-info}/top_level.txt +0 -0
vectara_agentic/tools.py
CHANGED
|
@@ -7,7 +7,7 @@ import re
|
|
|
7
7
|
import importlib
|
|
8
8
|
import os
|
|
9
9
|
|
|
10
|
-
from typing import Callable, List, Dict, Any, Optional, Type
|
|
10
|
+
from typing import Callable, List, Dict, Any, Optional, Union, Type
|
|
11
11
|
from pydantic import BaseModel, Field
|
|
12
12
|
from pydantic_core import PydanticUndefined
|
|
13
13
|
|
|
@@ -110,6 +110,9 @@ class VectaraTool(FunctionTool):
|
|
|
110
110
|
if self.metadata.tool_type != other.metadata.tool_type:
|
|
111
111
|
return False
|
|
112
112
|
|
|
113
|
+
if self.metadata.name != other.metadata.name or self.metadata.description != other.metadata.description:
|
|
114
|
+
return False
|
|
115
|
+
|
|
113
116
|
# Check if fn_schema is an instance of a BaseModel or a class itself (metaclass)
|
|
114
117
|
self_schema_dict = self.metadata.fn_schema.model_fields
|
|
115
118
|
other_schema_dict = other.metadata.fn_schema.model_fields
|
|
@@ -252,7 +255,10 @@ def _build_filter_string(kwargs: Dict[str, Any], tool_args_type: Dict[str, dict]
|
|
|
252
255
|
filter_parts.append(f"{prefix}.{key}='{val_str}'")
|
|
253
256
|
|
|
254
257
|
filter_str = " AND ".join(filter_parts)
|
|
255
|
-
|
|
258
|
+
if fixed_filter and filter_str:
|
|
259
|
+
return f"({fixed_filter}) AND ({filter_str})"
|
|
260
|
+
else:
|
|
261
|
+
return fixed_filter or filter_str
|
|
256
262
|
|
|
257
263
|
class VectaraToolFactory:
|
|
258
264
|
"""
|
|
@@ -261,21 +267,18 @@ class VectaraToolFactory:
|
|
|
261
267
|
|
|
262
268
|
def __init__(
|
|
263
269
|
self,
|
|
264
|
-
|
|
265
|
-
vectara_corpus_id: str = str(os.environ.get("VECTARA_CORPUS_ID", "")),
|
|
270
|
+
vectara_corpus_key: str = str(os.environ.get("VECTARA_CORPUS_KEY", "")),
|
|
266
271
|
vectara_api_key: str = str(os.environ.get("VECTARA_API_KEY", "")),
|
|
267
272
|
) -> None:
|
|
268
273
|
"""
|
|
269
274
|
Initialize the VectaraToolFactory
|
|
270
275
|
Args:
|
|
271
|
-
|
|
272
|
-
vectara_corpus_id (str): The Vectara corpus ID (or comma separated list of IDs).
|
|
276
|
+
vectara_corpus_key (str): The Vectara corpus key (or comma separated list of keys).
|
|
273
277
|
vectara_api_key (str): The Vectara API key.
|
|
274
278
|
"""
|
|
275
|
-
self.
|
|
276
|
-
self.vectara_corpus_id = vectara_corpus_id
|
|
279
|
+
self.vectara_corpus_key = vectara_corpus_key
|
|
277
280
|
self.vectara_api_key = vectara_api_key
|
|
278
|
-
self.num_corpora = len(
|
|
281
|
+
self.num_corpora = len(vectara_corpus_key.split(","))
|
|
279
282
|
|
|
280
283
|
def create_search_tool(
|
|
281
284
|
self,
|
|
@@ -284,12 +287,20 @@ class VectaraToolFactory:
|
|
|
284
287
|
tool_args_schema: type[BaseModel],
|
|
285
288
|
tool_args_type: Dict[str, str] = {},
|
|
286
289
|
fixed_filter: str = "",
|
|
287
|
-
lambda_val: float = 0.005,
|
|
288
|
-
|
|
290
|
+
lambda_val: Union[List[float], float] = 0.005,
|
|
291
|
+
semantics: Union[List[str] | str] = "default",
|
|
292
|
+
custom_dimensions: Union[List[Dict], Dict] = {},
|
|
293
|
+
offset: int = 0,
|
|
294
|
+
n_sentences_before: int = 2,
|
|
295
|
+
n_sentences_after: int = 2,
|
|
296
|
+
reranker: str = "slingshot",
|
|
289
297
|
rerank_k: int = 50,
|
|
298
|
+
rerank_limit: Optional[int] = None,
|
|
299
|
+
rerank_cutoff: Optional[float] = None,
|
|
290
300
|
mmr_diversity_bias: float = 0.2,
|
|
291
301
|
udf_expression: str = None,
|
|
292
302
|
rerank_chain: List[Dict] = None,
|
|
303
|
+
save_history: bool = True,
|
|
293
304
|
verbose: bool = False,
|
|
294
305
|
) -> VectaraTool:
|
|
295
306
|
"""
|
|
@@ -301,9 +312,18 @@ class VectaraToolFactory:
|
|
|
301
312
|
tool_args_schema (BaseModel): The schema for the tool arguments.
|
|
302
313
|
tool_args_type (Dict[str, str], optional): The type of each argument (doc or part).
|
|
303
314
|
fixed_filter (str, optional): A fixed Vectara filter condition to apply to all queries.
|
|
304
|
-
lambda_val (float, optional): Lambda value for
|
|
315
|
+
lambda_val (Union[List[float] | float], optional): Lambda value (or list of values for each corpora)
|
|
316
|
+
for the Vectara query, when using hybrid search.
|
|
317
|
+
semantics (Union[List[str], str], optional): Indicates whether the query is intended as a query or response.
|
|
318
|
+
Include list if using multiple corpora specifying the query type for each corpus.
|
|
319
|
+
custom_dimensions (Union[List[Dict] | Dict], optional): Custom dimensions for the query (for each corpora).
|
|
320
|
+
offset (int, optional): Number of results to skip.
|
|
321
|
+
n_sentences_before (int, optional): Number of sentences before the matching document part.
|
|
322
|
+
n_sentences_after (int, optional): Number of sentences after the matching document part.
|
|
305
323
|
reranker (str, optional): The reranker mode.
|
|
306
324
|
rerank_k (int, optional): Number of top-k documents for reranking.
|
|
325
|
+
rerank_limit (int, optional): Maximum number of results to return after reranking.
|
|
326
|
+
rerank_cutoff (float, optional): Minimum score threshold for results to include after reranking.
|
|
307
327
|
mmr_diversity_bias (float, optional): MMR diversity bias.
|
|
308
328
|
udf_expression (str, optional): the user defined expression for reranking results.
|
|
309
329
|
rerank_chain (List[Dict], optional): A list of rerankers to be applied sequentially.
|
|
@@ -311,6 +331,7 @@ class VectaraToolFactory:
|
|
|
311
331
|
and any other parameters (e.g. "limit" or "cutoff" for any type,
|
|
312
332
|
"diversity_bias" for mmr, and "user_function" for udf).
|
|
313
333
|
If using slingshot/multilingual_reranker_v1, it must be first in the list.
|
|
334
|
+
save_history (bool, optional): Whether to save the query in history.
|
|
314
335
|
verbose (bool, optional): Whether to print verbose output.
|
|
315
336
|
|
|
316
337
|
Returns:
|
|
@@ -319,8 +340,7 @@ class VectaraToolFactory:
|
|
|
319
340
|
|
|
320
341
|
vectara = VectaraIndex(
|
|
321
342
|
vectara_api_key=self.vectara_api_key,
|
|
322
|
-
|
|
323
|
-
vectara_corpus_id=self.vectara_corpus_id,
|
|
343
|
+
vectara_corpus_key=self.vectara_corpus_key,
|
|
324
344
|
x_source_str="vectara-agentic",
|
|
325
345
|
)
|
|
326
346
|
|
|
@@ -352,11 +372,19 @@ class VectaraToolFactory:
|
|
|
352
372
|
similarity_top_k=top_k,
|
|
353
373
|
reranker=reranker,
|
|
354
374
|
rerank_k=rerank_k if rerank_k * self.num_corpora <= 100 else int(100 / self.num_corpora),
|
|
375
|
+
rerank_limit=rerank_limit,
|
|
376
|
+
rerank_cutoff=rerank_cutoff,
|
|
355
377
|
mmr_diversity_bias=mmr_diversity_bias,
|
|
356
378
|
udf_expression=udf_expression,
|
|
357
379
|
rerank_chain=rerank_chain,
|
|
358
380
|
lambda_val=lambda_val,
|
|
381
|
+
semantics=semantics,
|
|
382
|
+
custom_dimensions=custom_dimensions,
|
|
383
|
+
offset=offset,
|
|
359
384
|
filter=filter_string,
|
|
385
|
+
n_sentences_before=n_sentences_before,
|
|
386
|
+
n_sentences_after=n_sentences_after,
|
|
387
|
+
save_history=save_history,
|
|
360
388
|
x_source_str="vectara-agentic",
|
|
361
389
|
verbose=verbose,
|
|
362
390
|
)
|
|
@@ -404,7 +432,7 @@ class VectaraToolFactory:
|
|
|
404
432
|
|
|
405
433
|
# Create the tool function signature string
|
|
406
434
|
fields = []
|
|
407
|
-
for name, field in tool_args_schema.
|
|
435
|
+
for name, field in tool_args_schema.model_fields.items():
|
|
408
436
|
annotation = field.annotation
|
|
409
437
|
type_name = annotation.__name__ if hasattr(annotation, '__name__') else str(annotation)
|
|
410
438
|
fields.append(f"{name}: {type_name}")
|
|
@@ -428,19 +456,30 @@ class VectaraToolFactory:
|
|
|
428
456
|
tool_args_schema: type[BaseModel],
|
|
429
457
|
tool_args_type: Dict[str, dict] = {},
|
|
430
458
|
fixed_filter: str = "",
|
|
431
|
-
vectara_summarizer: str = "vectara-summary-ext-24-05-
|
|
459
|
+
vectara_summarizer: str = "vectara-summary-ext-24-05-med-omni",
|
|
432
460
|
vectara_prompt_text: str = None,
|
|
433
461
|
summary_num_results: int = 5,
|
|
434
462
|
summary_response_lang: str = "eng",
|
|
435
463
|
n_sentences_before: int = 2,
|
|
436
464
|
n_sentences_after: int = 2,
|
|
437
|
-
|
|
438
|
-
|
|
465
|
+
offset: int = 0,
|
|
466
|
+
lambda_val: Union[List[float], float] = 0.005,
|
|
467
|
+
semantics: Union[List[str] | str] = "default",
|
|
468
|
+
custom_dimensions: Union[List[Dict], Dict] = {},
|
|
469
|
+
reranker: str = "slingshot",
|
|
439
470
|
rerank_k: int = 50,
|
|
471
|
+
rerank_limit: Optional[int] = None,
|
|
472
|
+
rerank_cutoff: Optional[float] = None,
|
|
440
473
|
mmr_diversity_bias: float = 0.2,
|
|
441
474
|
udf_expression: str = None,
|
|
442
475
|
rerank_chain: List[Dict] = None,
|
|
476
|
+
max_response_chars: Optional[int] = None,
|
|
477
|
+
max_tokens: Optional[int] = None,
|
|
478
|
+
temperature: Optional[float] = None,
|
|
479
|
+
frequency_penalty: Optional[float] = None,
|
|
480
|
+
presence_penalty: Optional[float] = None,
|
|
443
481
|
include_citations: bool = True,
|
|
482
|
+
save_history: bool = False,
|
|
444
483
|
fcs_threshold: float = 0.0,
|
|
445
484
|
verbose: bool = False,
|
|
446
485
|
) -> VectaraTool:
|
|
@@ -460,21 +499,37 @@ class VectaraToolFactory:
|
|
|
460
499
|
vectara_prompt_text (str, optional): The prompt text for the Vectara summarizer.
|
|
461
500
|
summary_num_results (int, optional): The number of summary results.
|
|
462
501
|
summary_response_lang (str, optional): The response language for the summary.
|
|
502
|
+
summary_prompt_text (str, optional): The custom prompt, using appropriate prompt variables and functions.
|
|
463
503
|
n_sentences_before (int, optional): Number of sentences before the summary.
|
|
464
504
|
n_sentences_after (int, optional): Number of sentences after the summary.
|
|
465
|
-
|
|
505
|
+
offset (int, optional): Number of results to skip.
|
|
506
|
+
lambda_val (Union[List[float] | float], optional): Lambda value (or list of values for each corpora)
|
|
507
|
+
for the Vectara query, when using hybrid search.
|
|
508
|
+
semantics (Union[List[str], str], optional): Indicates whether the query is intended as a query or response.
|
|
509
|
+
Include list if using multiple corpora specifying the query type for each corpus.
|
|
510
|
+
custom_dimensions (Union[List[Dict] | Dict], optional): Custom dimensions for the query (for each corpora).
|
|
466
511
|
reranker (str, optional): The reranker mode.
|
|
467
512
|
rerank_k (int, optional): Number of top-k documents for reranking.
|
|
513
|
+
rerank_limit (int, optional): Maximum number of results to return after reranking.
|
|
514
|
+
rerank_cutoff (float, optional): Minimum score threshold for results to include after reranking.
|
|
468
515
|
mmr_diversity_bias (float, optional): MMR diversity bias.
|
|
469
|
-
udf_expression (str, optional):
|
|
516
|
+
udf_expression (str, optional): The user defined expression for reranking results.
|
|
470
517
|
rerank_chain (List[Dict], optional): A list of rerankers to be applied sequentially.
|
|
471
518
|
Each dictionary should specify the "type" of reranker (mmr, slingshot, udf)
|
|
472
519
|
and any other parameters (e.g. "limit" or "cutoff" for any type,
|
|
473
520
|
"diversity_bias" for mmr, and "user_function" for udf).
|
|
474
521
|
If using slingshot/multilingual_reranker_v1, it must be first in the list.
|
|
522
|
+
max_response_chars (int, optional): The desired maximum number of characters for the generated summary.
|
|
523
|
+
max_tokens (int, optional): The maximum number of tokens to be returned by the LLM.
|
|
524
|
+
temperature (float, optional): The sampling temperature; higher values lead to more randomness.
|
|
525
|
+
frequency_penalty (float, optional): How much to penalize repeating tokens in the response,
|
|
526
|
+
higher values reducing likelihood of repeating the same line.
|
|
527
|
+
presence_penalty (float, optional): How much to penalize repeating tokens in the response,
|
|
528
|
+
higher values increasing the diversity of topics.
|
|
475
529
|
include_citations (bool, optional): Whether to include citations in the response.
|
|
476
530
|
If True, uses markdown vectara citations that requires the Vectara scale plan.
|
|
477
|
-
|
|
531
|
+
save_history (bool, optional): Whether to save the query in history.
|
|
532
|
+
fcs_threshold (float, optional): A threshold for factual consistency.
|
|
478
533
|
If set above 0, the tool notifies the calling agent that it "cannot respond" if FCS is too low.
|
|
479
534
|
verbose (bool, optional): Whether to print verbose output.
|
|
480
535
|
|
|
@@ -484,8 +539,7 @@ class VectaraToolFactory:
|
|
|
484
539
|
|
|
485
540
|
vectara = VectaraIndex(
|
|
486
541
|
vectara_api_key=self.vectara_api_key,
|
|
487
|
-
|
|
488
|
-
vectara_corpus_id=self.vectara_corpus_id,
|
|
542
|
+
vectara_corpus_key=self.vectara_corpus_key,
|
|
489
543
|
x_source_str="vectara-agentic",
|
|
490
544
|
)
|
|
491
545
|
|
|
@@ -520,15 +574,26 @@ class VectaraToolFactory:
|
|
|
520
574
|
prompt_text=vectara_prompt_text,
|
|
521
575
|
reranker=reranker,
|
|
522
576
|
rerank_k=rerank_k if rerank_k * self.num_corpora <= 100 else int(100 / self.num_corpora),
|
|
577
|
+
rerank_limit=rerank_limit,
|
|
578
|
+
rerank_cutoff=rerank_cutoff,
|
|
523
579
|
mmr_diversity_bias=mmr_diversity_bias,
|
|
524
580
|
udf_expression=udf_expression,
|
|
525
581
|
rerank_chain=rerank_chain,
|
|
526
582
|
n_sentence_before=n_sentences_before,
|
|
527
583
|
n_sentence_after=n_sentences_after,
|
|
584
|
+
offset=offset,
|
|
528
585
|
lambda_val=lambda_val,
|
|
586
|
+
semantics=semantics,
|
|
587
|
+
custom_dimensions=custom_dimensions,
|
|
529
588
|
filter=filter_string,
|
|
530
|
-
|
|
589
|
+
max_response_chars=max_response_chars,
|
|
590
|
+
max_tokens=max_tokens,
|
|
591
|
+
temperature=temperature,
|
|
592
|
+
frequency_penalty=frequency_penalty,
|
|
593
|
+
presence_penalty=presence_penalty,
|
|
594
|
+
citations_style="markdown" if include_citations else None,
|
|
531
595
|
citations_url_pattern="{doc.url}" if include_citations else None,
|
|
596
|
+
save_history=save_history,
|
|
532
597
|
x_source_str="vectara-agentic",
|
|
533
598
|
verbose=verbose,
|
|
534
599
|
)
|
|
@@ -571,7 +636,7 @@ class VectaraToolFactory:
|
|
|
571
636
|
+ ".\n"
|
|
572
637
|
)
|
|
573
638
|
fcs = response.metadata["fcs"] if "fcs" in response.metadata else 0.0
|
|
574
|
-
if fcs < fcs_threshold:
|
|
639
|
+
if fcs and fcs < fcs_threshold:
|
|
575
640
|
msg = f"Could not answer the query due to suspected hallucination (fcs={fcs})."
|
|
576
641
|
return ToolOutput(
|
|
577
642
|
tool_name=rag_function.__name__,
|
|
@@ -618,7 +683,7 @@ class VectaraToolFactory:
|
|
|
618
683
|
|
|
619
684
|
# Create the tool function signature string
|
|
620
685
|
fields = []
|
|
621
|
-
for name, field in tool_args_schema.
|
|
686
|
+
for name, field in tool_args_schema.model_fields.items():
|
|
622
687
|
annotation = field.annotation
|
|
623
688
|
type_name = annotation.__name__ if hasattr(annotation, '__name__') else str(annotation)
|
|
624
689
|
fields.append(f"{name}: {type_name}")
|
vectara_agentic/tools_catalog.py
CHANGED
vectara_agentic/types.py
CHANGED
|
@@ -33,6 +33,7 @@ class ModelProvider(Enum):
|
|
|
33
33
|
COHERE = "COHERE"
|
|
34
34
|
GEMINI = "GEMINI"
|
|
35
35
|
BEDROCK = "BEDROCK"
|
|
36
|
+
PRIVATE = "PRIVATE"
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
class AgentStatusType(Enum):
|
|
@@ -47,8 +48,8 @@ class AgentStatusType(Enum):
|
|
|
47
48
|
class LLMRole(Enum):
|
|
48
49
|
"""Enumeration for different types of LLM roles."""
|
|
49
50
|
|
|
50
|
-
MAIN
|
|
51
|
-
TOOL
|
|
51
|
+
MAIN = "MAIN"
|
|
52
|
+
TOOL = "TOOL"
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
class ToolType(Enum):
|
vectara_agentic/utils.py
CHANGED
|
@@ -112,6 +112,10 @@ def get_llm(
|
|
|
112
112
|
elif model_provider == ModelProvider.COHERE:
|
|
113
113
|
from llama_index.llms.cohere import Cohere
|
|
114
114
|
llm = Cohere(model=model_name, temperature=0)
|
|
115
|
+
elif model_provider == ModelProvider.PRIVATE:
|
|
116
|
+
from llama_index.llms.openai_like import OpenAILike
|
|
117
|
+
llm = OpenAILike(model=model_name, temperature=0, is_function_calling_model=True,is_chat_model=True,
|
|
118
|
+
api_base=config.private_llm_api_base, api_key=config.private_llm_api_key)
|
|
115
119
|
else:
|
|
116
120
|
raise ValueError(f"Unknown LLM provider: {model_provider}")
|
|
117
121
|
return llm
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: vectara_agentic
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A Python package for creating AI Assistants and AI Agents with Vectara
|
|
5
5
|
Home-page: https://github.com/vectara/py-vectara-agentic
|
|
6
6
|
Author: Ofer Mendelevitch
|
|
@@ -17,7 +17,7 @@ Requires-Python: >=3.10
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
19
|
Requires-Dist: llama-index==0.12.11
|
|
20
|
-
Requires-Dist: llama-index-indices-managed-vectara==0.
|
|
20
|
+
Requires-Dist: llama-index-indices-managed-vectara==0.4.0
|
|
21
21
|
Requires-Dist: llama-index-agent-llm-compiler==0.3.0
|
|
22
22
|
Requires-Dist: llama-index-agent-lats==0.3.0
|
|
23
23
|
Requires-Dist: llama-index-agent-openai==0.4.3
|
|
@@ -51,7 +51,7 @@ Requires-Dist: pydantic==2.10.3
|
|
|
51
51
|
Requires-Dist: retrying==1.3.4
|
|
52
52
|
Requires-Dist: python-dotenv==1.0.1
|
|
53
53
|
Requires-Dist: tiktoken==0.8.0
|
|
54
|
-
Requires-Dist:
|
|
54
|
+
Requires-Dist: cloudpickle>=3.1.1
|
|
55
55
|
Requires-Dist: httpx==0.27.2
|
|
56
56
|
Dynamic: author
|
|
57
57
|
Dynamic: author-email
|
|
@@ -135,7 +135,7 @@ from vectara_agentic.tools import VectaraToolFactory
|
|
|
135
135
|
vec_factory = VectaraToolFactory(
|
|
136
136
|
vectara_api_key=os.environ['VECTARA_API_KEY'],
|
|
137
137
|
vectara_customer_id=os.environ['VECTARA_CUSTOMER_ID'],
|
|
138
|
-
|
|
138
|
+
vectara_corpus_key=os.environ['VECTARA_CORPUS_KEY']
|
|
139
139
|
)
|
|
140
140
|
```
|
|
141
141
|
|
|
@@ -315,6 +315,10 @@ def mult_func(x, y):
|
|
|
315
315
|
mult_tool = ToolsFactory().create_tool(mult_func)
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
+
Note: When you define your own Python functions as tools, implement them at the top module level,
|
|
319
|
+
and not as nested functions. Nested functions are not supported if you use serialization
|
|
320
|
+
(dumps/loads or from_dict/to_dict).
|
|
321
|
+
|
|
318
322
|
## 🛠️ Configuration
|
|
319
323
|
|
|
320
324
|
## Configuring Vectara-agentic
|
|
@@ -352,10 +356,31 @@ If any of these are not provided, `AgentConfig` first tries to read the values f
|
|
|
352
356
|
|
|
353
357
|
When creating a `VectaraToolFactory`, you can pass in a `vectara_api_key`, `vectara_customer_id`, and `vectara_corpus_id` to the factory.
|
|
354
358
|
|
|
355
|
-
If not passed in, it will be taken from the environment variables (`VECTARA_API_KEY
|
|
359
|
+
If not passed in, it will be taken from the environment variables (`VECTARA_API_KEY` and `VECTARA_CORPUS_KEY`). Note that `VECTARA_CORPUS_KEY` can be a single KEY or a comma-separated list of KEYs (if you want to query multiple corpora).
|
|
356
360
|
|
|
357
361
|
These values will be used as credentials when creating Vectara tools - in `create_rag_tool()` and `create_search_tool()`.
|
|
358
362
|
|
|
363
|
+
## Setting up a privately hosted LLM
|
|
364
|
+
|
|
365
|
+
If you want to setup vectara-agentic to use your own self-hosted LLM endpoint, follow the example below
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
config = AgentConfig(
|
|
369
|
+
agent_type=AgentType.REACT,
|
|
370
|
+
main_llm_provider=ModelProvider.PRIVATE,
|
|
371
|
+
main_llm_model_name="meta-llama/Meta-Llama-3.1-8B-Instruct",
|
|
372
|
+
private_llm_api_base="http://vllm-server.company.com/v1",
|
|
373
|
+
private_llm_api_key="TEST_API_KEY",
|
|
374
|
+
)
|
|
375
|
+
agent = Agent(agent_config=config, tools=tools, topic=topic,
|
|
376
|
+
custom_instructions=custom_instructions)
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
In this case we specify the Main LLM provider to be privately hosted with Llama-3.1-8B as the model.
|
|
380
|
+
- The `ModelProvider.PRIVATE` specifies a privately hosted LLM.
|
|
381
|
+
- The `private_llm_api_base` specifies the api endpoint to use, and the `private_llm_api_key`
|
|
382
|
+
specifies the private API key requires to use this service.
|
|
383
|
+
|
|
359
384
|
## ℹ️ Additional Information
|
|
360
385
|
|
|
361
386
|
### About Custom Instructions for your Agent
|
|
@@ -376,6 +401,8 @@ The `Agent` class defines a few helpful methods to help you understand the inter
|
|
|
376
401
|
|
|
377
402
|
The `Agent` class supports serialization. Use the `dumps()` to serialize and `loads()` to read back from a serialized stream.
|
|
378
403
|
|
|
404
|
+
Note: due to cloudpickle limitations, if a tool contains Python `weakref` objects, serialization won't work and an exception will be raised.
|
|
405
|
+
|
|
379
406
|
### Observability
|
|
380
407
|
|
|
381
408
|
vectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
tests/endpoint.py,sha256=rnHyXEZhjipyR2Stj2Mum331REChWuhmn5WPpyDryV0,1291
|
|
3
|
+
tests/test_agent.py,sha256=SzSE1T_9PyIs-LUjj-fJjfGDlpJBzHUigyVX-KEhmJ4,4967
|
|
4
|
+
tests/test_private_llm.py,sha256=b7RrOHHsTQKARHskCbh2I4f_LmjZmD5bdk1oEWGhP7s,2150
|
|
5
|
+
tests/test_tools.py,sha256=lPihJ5mRdK66exWqDFRPEYIM2kUDeGtoaiG78UH5WMs,3499
|
|
6
|
+
vectara_agentic/__init__.py,sha256=ADH4fPKLbpGNYYYszv3c3QDOjPToPE_qh3LpkH_seCU,430
|
|
7
|
+
vectara_agentic/_callback.py,sha256=jpzHqnl297k2qajYc-6nkPtIPtgVLpVWYEISHS7ySlM,9186
|
|
8
|
+
vectara_agentic/_observability.py,sha256=HeQYJIkqPLW3EWHiXHatkaJzo08IQGESKujdeWTuRgk,3805
|
|
9
|
+
vectara_agentic/_prompts.py,sha256=7xOcRf9XNtpfFpDIUzgb-yMQ516K8X7bAzayAp406FU,6595
|
|
10
|
+
vectara_agentic/_version.py,sha256=r1kR7ilT4Tx4v5m7GtBI1hwUMe-C5VRwnozb3l382_0,65
|
|
11
|
+
vectara_agentic/agent.py,sha256=LMnJJfw2udDrsZAVlYpji0_rkmasHOsCuv206UJpH7Q,32007
|
|
12
|
+
vectara_agentic/agent_config.py,sha256=yof3zU8OgYE5441EAwcoDBpTHDM5lNN-CyeO0LrT4-c,3350
|
|
13
|
+
vectara_agentic/agent_endpoint.py,sha256=QIMejCLlpW2qzXxeDAxv3anF46XMDdVMdKGWhJh3azY,1996
|
|
14
|
+
vectara_agentic/db_tools.py,sha256=3_hPrutNIGEeU2kH503GjcYbtAMsK6BidQLIm6DT6C8,3591
|
|
15
|
+
vectara_agentic/tools.py,sha256=gI6zsVNh2SfAOqeQ5ZzAmf8NxkmtV6NUPJsTN7Cnb7o,39440
|
|
16
|
+
vectara_agentic/tools_catalog.py,sha256=0gfF-JzTEnFS8e_x2uA6mvcvjVkY9ygRskxJetKGtrs,5231
|
|
17
|
+
vectara_agentic/types.py,sha256=Qy7c7gSXJbvzddzhSRx2Flaf6a3go8u2LW17IKNxkKI,1603
|
|
18
|
+
vectara_agentic/utils.py,sha256=ZhS82hA9yconr9yqDJ0GCBUjRxc06ZTlFaBzF67Yb3Y,5008
|
|
19
|
+
vectara_agentic-0.2.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
20
|
+
vectara_agentic-0.2.1.dist-info/METADATA,sha256=ZZpRSVHVy9gI9QsNHFKKtdYyl3DWbR_h_LyD6oX9bJw,21857
|
|
21
|
+
vectara_agentic-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
22
|
+
vectara_agentic-0.2.1.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
|
|
23
|
+
vectara_agentic-0.2.1.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
tests/test_agent.py,sha256=8LQlny0rIuVa13LGtebG0vatES6Ln7gmenbSwX-ctrY,4260
|
|
3
|
-
tests/test_tools.py,sha256=2ofZYz3Q-YMSxjpiEg1VNUlA9gMjvNAcJAO2Ucd0eVE,2969
|
|
4
|
-
vectara_agentic/__init__.py,sha256=ADH4fPKLbpGNYYYszv3c3QDOjPToPE_qh3LpkH_seCU,430
|
|
5
|
-
vectara_agentic/_callback.py,sha256=OBiHk_OJZTS3iKz_LigfEjnl_p5V90XYsQC0vEYVSPo,8782
|
|
6
|
-
vectara_agentic/_observability.py,sha256=HeQYJIkqPLW3EWHiXHatkaJzo08IQGESKujdeWTuRgk,3805
|
|
7
|
-
vectara_agentic/_prompts.py,sha256=mgGx3zUJPtpS1epBLtl0BnoLeE7wb6AX1SX6dFNaTTQ,6368
|
|
8
|
-
vectara_agentic/_version.py,sha256=u9ioOLfZA3qvhfipk_RBrRAVHGDOd7O6rpSxeoT232A,66
|
|
9
|
-
vectara_agentic/agent.py,sha256=PnBKpHOs8TgUxSoLRqsXygRxK64cdybM2kpwawEH7ps,26059
|
|
10
|
-
vectara_agentic/agent_config.py,sha256=9P9lyFAAXLX1ft2dBQ6tYN7dKzp7SC7B-h-DnhUHsSg,2941
|
|
11
|
-
vectara_agentic/agent_endpoint.py,sha256=QIMejCLlpW2qzXxeDAxv3anF46XMDdVMdKGWhJh3azY,1996
|
|
12
|
-
vectara_agentic/db_tools.py,sha256=kCEENzmnorm8i-k4Kpd4KLJt1QWh_ZlAyX1aG-tzET0,3619
|
|
13
|
-
vectara_agentic/tools.py,sha256=M59Y6fDGB0IipITM9f-mYeotN6EBTNB_QG0fQs_cags,35215
|
|
14
|
-
vectara_agentic/tools_catalog.py,sha256=O3vYFpZ5EQeh37X70TiHepXFGN5yGk4_d7CkrkLeUhk,5205
|
|
15
|
-
vectara_agentic/types.py,sha256=00wm3YsJRyddvIBzeVjF3qklA38NuTkCvy_B-e68v6c,1589
|
|
16
|
-
vectara_agentic/utils.py,sha256=eDEOUpCkb0r216LxSLkamll2NmJhu76Z1TgQFbAVq7A,4690
|
|
17
|
-
vectara_agentic-0.1.28.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
18
|
-
vectara_agentic-0.1.28.dist-info/METADATA,sha256=2Cn2kXTWE-BIQ3Mb6rGs740Crxyp3TWejCD5PI3s_wE,20565
|
|
19
|
-
vectara_agentic-0.1.28.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
20
|
-
vectara_agentic-0.1.28.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
|
|
21
|
-
vectara_agentic-0.1.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|