vectara-agentic 0.3.3__py3-none-any.whl → 0.4.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/__init__.py +7 -0
- tests/conftest.py +316 -0
- tests/endpoint.py +54 -17
- tests/run_tests.py +112 -0
- tests/test_agent.py +35 -33
- tests/test_agent_fallback_memory.py +270 -0
- tests/test_agent_memory_consistency.py +229 -0
- tests/test_agent_type.py +86 -143
- tests/test_api_endpoint.py +4 -0
- tests/test_bedrock.py +50 -31
- tests/test_fallback.py +4 -0
- tests/test_gemini.py +27 -59
- tests/test_groq.py +50 -31
- tests/test_private_llm.py +11 -2
- tests/test_return_direct.py +6 -2
- tests/test_serialization.py +7 -6
- tests/test_session_memory.py +252 -0
- tests/test_streaming.py +109 -0
- tests/test_together.py +62 -0
- tests/test_tools.py +10 -82
- tests/test_vectara_llms.py +4 -0
- tests/test_vhc.py +67 -0
- tests/test_workflow.py +13 -28
- vectara_agentic/__init__.py +27 -4
- vectara_agentic/_callback.py +65 -67
- vectara_agentic/_observability.py +30 -30
- vectara_agentic/_version.py +1 -1
- vectara_agentic/agent.py +565 -859
- vectara_agentic/agent_config.py +15 -14
- vectara_agentic/agent_core/__init__.py +22 -0
- vectara_agentic/agent_core/factory.py +383 -0
- vectara_agentic/{_prompts.py → agent_core/prompts.py} +21 -46
- vectara_agentic/agent_core/serialization.py +348 -0
- vectara_agentic/agent_core/streaming.py +483 -0
- vectara_agentic/agent_core/utils/__init__.py +29 -0
- vectara_agentic/agent_core/utils/hallucination.py +157 -0
- vectara_agentic/agent_core/utils/logging.py +52 -0
- vectara_agentic/agent_core/utils/schemas.py +87 -0
- vectara_agentic/agent_core/utils/tools.py +125 -0
- vectara_agentic/agent_endpoint.py +4 -6
- vectara_agentic/db_tools.py +37 -12
- vectara_agentic/llm_utils.py +42 -43
- vectara_agentic/sub_query_workflow.py +9 -14
- vectara_agentic/tool_utils.py +138 -83
- vectara_agentic/tools.py +36 -21
- vectara_agentic/tools_catalog.py +16 -16
- vectara_agentic/types.py +106 -8
- {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.1.dist-info}/METADATA +111 -31
- vectara_agentic-0.4.1.dist-info/RECORD +53 -0
- tests/test_agent_planning.py +0 -64
- tests/test_hhem.py +0 -100
- vectara_agentic/hhem.py +0 -82
- vectara_agentic-0.3.3.dist-info/RECORD +0 -39
- {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.1.dist-info}/WHEEL +0 -0
- {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {vectara_agentic-0.3.3.dist-info → vectara_agentic-0.4.1.dist-info}/top_level.txt +0 -0
vectara_agentic/hhem.py
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"""Vectara HHEM (Hypothesis Hypothetical Evaluation Model) client."""
|
|
2
|
-
|
|
3
|
-
import requests
|
|
4
|
-
from commonmark import Parser
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def markdown_to_text(md: str) -> str:
|
|
8
|
-
"""
|
|
9
|
-
Convert a Markdown-formatted string into plain text.
|
|
10
|
-
"""
|
|
11
|
-
parser = Parser()
|
|
12
|
-
ast = parser.parse(md)
|
|
13
|
-
out: list[str] = []
|
|
14
|
-
|
|
15
|
-
def recurse(node):
|
|
16
|
-
if node.t in ("text", "code", "html_inline"):
|
|
17
|
-
out.append(node.literal or "")
|
|
18
|
-
elif node.t == "softbreak":
|
|
19
|
-
out.append(" ")
|
|
20
|
-
elif node.t == "linebreak":
|
|
21
|
-
out.append("\n")
|
|
22
|
-
child = getattr(node, "first_child", None)
|
|
23
|
-
while child is not None:
|
|
24
|
-
recurse(child)
|
|
25
|
-
child = getattr(child, "next", None)
|
|
26
|
-
|
|
27
|
-
recurse(ast)
|
|
28
|
-
text = "".join(out)
|
|
29
|
-
# collapse runs of spaces but preserve newlines
|
|
30
|
-
lines = [" ".join(line.split()) for line in text.splitlines()]
|
|
31
|
-
return "\n".join(line if line.strip() else "" for line in lines)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class HHEM:
|
|
35
|
-
"""Vectara HHEM (Hypothesis Hypothetical Evaluation Model) client."""
|
|
36
|
-
|
|
37
|
-
def __init__(self, vectara_api_key: str):
|
|
38
|
-
self._vectara_api_key = vectara_api_key
|
|
39
|
-
|
|
40
|
-
def compute(self, context: str, hypothesis: str) -> float:
|
|
41
|
-
"""
|
|
42
|
-
Calls the Vectara HHEM endpoint to evaluate the factual consistency of a hypothesis against a given context.
|
|
43
|
-
|
|
44
|
-
Parameters:
|
|
45
|
-
context (str): The source text against which the hypothesis will be evaluated.
|
|
46
|
-
hypothesis (str): The generated text to be evaluated for factual consistency.
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
float: The factual consistency score rounded to four decimal places.
|
|
50
|
-
|
|
51
|
-
Raises:
|
|
52
|
-
requests.exceptions.RequestException: If there is a network-related error or the API call fails.
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
# clean response from any markdown or other formatting.
|
|
56
|
-
try:
|
|
57
|
-
clean_hypothesis = markdown_to_text(hypothesis)
|
|
58
|
-
except Exception as e:
|
|
59
|
-
# If markdown parsing fails, use the original text
|
|
60
|
-
raise ValueError(f"Markdown parsing of hypothesis failed: {e}") from e
|
|
61
|
-
|
|
62
|
-
# compute HHEM with Vectara endpoint
|
|
63
|
-
payload = {
|
|
64
|
-
"model_parameters": {"model_name": "hhem_v2.3"},
|
|
65
|
-
"generated_text": clean_hypothesis,
|
|
66
|
-
"source_texts": [context],
|
|
67
|
-
}
|
|
68
|
-
headers = {
|
|
69
|
-
"Content-Type": "application/json",
|
|
70
|
-
"Accept": "application/json",
|
|
71
|
-
"x-api-key": self._vectara_api_key,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
response = requests.post(
|
|
75
|
-
"https://api.vectara.io/v2/evaluate_factual_consistency",
|
|
76
|
-
json=payload,
|
|
77
|
-
headers=headers,
|
|
78
|
-
timeout=30,
|
|
79
|
-
)
|
|
80
|
-
response.raise_for_status()
|
|
81
|
-
data = response.json()
|
|
82
|
-
return round(data.get("score", 0.0), 4)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
tests/endpoint.py,sha256=frnpdZQpnuQNNKNYgAn2rFTarNG8MCJaNA77Bw_W22A,1420
|
|
3
|
-
tests/test_agent.py,sha256=4aRDhEVM1zARpSOevPR8PFGTkIaSw5g5WvoQDx-4sns,5496
|
|
4
|
-
tests/test_agent_planning.py,sha256=JwEebGooROAvsQ9JZoaH6KEcrSyv1F0lL4TD4FjP8a8,2213
|
|
5
|
-
tests/test_agent_type.py,sha256=9ZImIDw7Qz5EV2tX8bDD0tT1IFYghS3-SShpAezHO7s,7381
|
|
6
|
-
tests/test_api_endpoint.py,sha256=M9YGFCy_Jphzq9JznP4ftHqxZ_yu6dgWdX1jRvdsORA,5002
|
|
7
|
-
tests/test_bedrock.py,sha256=23A5_2FRaEl47PzgfUPDL6dgFDPJ9iktz-A-B1UwIhg,1224
|
|
8
|
-
tests/test_fallback.py,sha256=M5YD7NHZ0joVU1frYIr9_OiRAIje5mrXrYVcekzlyGs,2829
|
|
9
|
-
tests/test_gemini.py,sha256=QUBYWhZkX9AjnhPn5qa7sREf6YHZWeJEmYzKwVC23Io,4081
|
|
10
|
-
tests/test_groq.py,sha256=5yTlOLwpzGRmiBPExAuulK6SEO9O13cMJWVSSHX9CsE,1212
|
|
11
|
-
tests/test_hhem.py,sha256=XFUX3x0xOa9QsafzYNP8_ZsvzIiLnWee4hdsowzHft8,3250
|
|
12
|
-
tests/test_private_llm.py,sha256=-bQBI69Z-SwhhQJGzyC9GGM4kz5c6T5kAbXLbqn_G7E,2248
|
|
13
|
-
tests/test_return_direct.py,sha256=mgj1xJnvOX28aaidhZfH2DaI-kM0yfQ0P1PNV0iyLcw,1405
|
|
14
|
-
tests/test_serialization.py,sha256=Ed23GN2zhSJNdPFrVK4aqLkOhJKviczR_o0t-r9TuRI,4762
|
|
15
|
-
tests/test_tools.py,sha256=bhhq49I3eEJyuNf5FU7M9IxPT0XtwRbRTs3gwoBHihk,17128
|
|
16
|
-
tests/test_vectara_llms.py,sha256=gw5KQ4XT3L-_A6yj2jKqj-QomCjOb9VESKBtBH2Xb8s,2362
|
|
17
|
-
tests/test_workflow.py,sha256=TmNBxBqSW5owk_Nz9LLtHvqryVNsFPkf-M1G_uFSsAM,3739
|
|
18
|
-
vectara_agentic/__init__.py,sha256=2GLDS3U6KckK-dBRl9v_x1kSV507gEhjOfuMmmu0Qxg,850
|
|
19
|
-
vectara_agentic/_callback.py,sha256=c3848EMSpaQWXtuwdqRGbhgbZhiDwgGnemJkgm9yWAc,13238
|
|
20
|
-
vectara_agentic/_observability.py,sha256=iZlByeQTyx6g3Y8aBYcdGcxdRkoYrfxHdcrTEKO26UE,4485
|
|
21
|
-
vectara_agentic/_prompts.py,sha256=9s8VEjaaLuRgNK1xQYWj4bnjM4asJP1Z5zCihUMRonk,10768
|
|
22
|
-
vectara_agentic/_version.py,sha256=T5R4By43ti-oVkkFCfZWO1IEj2YgvFsppQ4MOX0xo2s,65
|
|
23
|
-
vectara_agentic/agent.py,sha256=zu7nMxhKin3rLuV8y4F_OcssU3R8bJOjMixKMC_P2k0,58857
|
|
24
|
-
vectara_agentic/agent_config.py,sha256=E-rtYMcpoGxnEAyy8231bizo2n0uGQ2qWxuSgTEfwdQ,4327
|
|
25
|
-
vectara_agentic/agent_endpoint.py,sha256=PzIN7HhEHv8Mq_Zo5cZ2xYrgdv2AN6kx6dc_2AJq28I,7497
|
|
26
|
-
vectara_agentic/db_tools.py,sha256=GUsQTZfRbT9F5K_e5HNaKXUkU6x8RErUyjDVKlZi1IA,11196
|
|
27
|
-
vectara_agentic/hhem.py,sha256=j4euBX24PSCQ8P_MhhsKKnm1kv6nHKAbduHsTwtQuR0,2774
|
|
28
|
-
vectara_agentic/llm_utils.py,sha256=TX01e4QY8qb5O5D6ZrlkLZEZFHJ4LbDL6g-l52lTB40,7561
|
|
29
|
-
vectara_agentic/sub_query_workflow.py,sha256=JYwN0wK4QzHjTaFDsSCAQvMx9GD4g6CnqxZCnzi6xb4,13086
|
|
30
|
-
vectara_agentic/tool_utils.py,sha256=9xoqVPB97CIDXOxuFIw4yZ2RlXvdayCEGPUaUPC2Tbc,24168
|
|
31
|
-
vectara_agentic/tools.py,sha256=LvUUD4gLYoL68gx8Lnr1GoECyC0wd0ahPyOhoW5ouws,35478
|
|
32
|
-
vectara_agentic/tools_catalog.py,sha256=cAN_kDOWZUoW4GNFwY5GdS6ImMUQNnF2sggx9OGK9Cg,4906
|
|
33
|
-
vectara_agentic/types.py,sha256=3mrtshHiy-d5JHVxl-4tJk5DRspvYKwAYiI5LvKO1Bw,2226
|
|
34
|
-
vectara_agentic/utils.py,sha256=R9HitEG5K3Q_p2M_teosT181OUxkhs1-hnj98qDYGbE,2545
|
|
35
|
-
vectara_agentic-0.3.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
36
|
-
vectara_agentic-0.3.3.dist-info/METADATA,sha256=aWqHgdQi_bbBUO4YgPg8Cd0E4UP3gv5setaJsm23lW0,32079
|
|
37
|
-
vectara_agentic-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
-
vectara_agentic-0.3.3.dist-info/top_level.txt,sha256=Y7TQTFdOYGYodQRltUGRieZKIYuzeZj2kHqAUpfCUfg,22
|
|
39
|
-
vectara_agentic-0.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|