langroid 0.1.251__tar.gz → 0.1.252__tar.gz
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.
- {langroid-0.1.251 → langroid-0.1.252}/PKG-INFO +1 -1
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/base.py +11 -1
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/task.py +25 -8
- {langroid-0.1.251 → langroid-0.1.252}/pyproject.toml +1 -1
- {langroid-0.1.251 → langroid-0.1.252}/LICENSE +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/README.md +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/batch.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/chat_document.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/helpers.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/junk +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tool_message.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/agent_config.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/cachedb/base.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/base.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/models.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/exceptions.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/base.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/config.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/openai_assistants.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/openai_gpt.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/utils.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/mytypes.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/config.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/image_text.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/parser.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/routing.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/search.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/spider.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/urls.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/utils.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/parsing/web_search.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/dialog.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/templates.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/prompts/transforms.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/configuration.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/constants.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/docker.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/globals.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/logging.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/output/printing.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/output/status.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/system.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/utils/web/login.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/base.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/momento.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.1.251 → langroid-0.1.252}/langroid/vector_store/qdrantdb.py +0 -0
@@ -2,6 +2,7 @@ import asyncio
|
|
2
2
|
import inspect
|
3
3
|
import json
|
4
4
|
import logging
|
5
|
+
import re
|
5
6
|
from abc import ABC
|
6
7
|
from contextlib import ExitStack
|
7
8
|
from types import SimpleNamespace
|
@@ -19,7 +20,7 @@ from typing import (
|
|
19
20
|
no_type_check,
|
20
21
|
)
|
21
22
|
|
22
|
-
from pydantic import BaseSettings, ValidationError
|
23
|
+
from pydantic import BaseSettings, ValidationError, validator
|
23
24
|
from rich import print
|
24
25
|
from rich.console import Console
|
25
26
|
from rich.markup import escape
|
@@ -64,6 +65,15 @@ class AgentConfig(BaseSettings):
|
|
64
65
|
prompts: Optional[PromptsConfig] = PromptsConfig()
|
65
66
|
show_stats: bool = True # show token usage/cost stats?
|
66
67
|
|
68
|
+
@validator("name")
|
69
|
+
def check_name_alphanum(cls, v: str) -> str:
|
70
|
+
if not re.match(r"^[a-zA-Z0-9_-]+$", v):
|
71
|
+
raise ValueError(
|
72
|
+
"The name must only contain alphanumeric characters, "
|
73
|
+
"underscores, or hyphens, with no spaces"
|
74
|
+
)
|
75
|
+
return v
|
76
|
+
|
67
77
|
|
68
78
|
def noop_fn(*args: List[Any], **kwargs: Dict[str, Any]) -> None:
|
69
79
|
pass
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import asyncio
|
3
4
|
import copy
|
4
5
|
import logging
|
5
6
|
from collections import Counter, deque
|
@@ -59,13 +60,18 @@ def noop_fn(*args: List[Any], **kwargs: Dict[str, Any]) -> None:
|
|
59
60
|
|
60
61
|
class TaskConfig(BaseModel):
|
61
62
|
"""Configuration for a Task. This is a container for any params that
|
62
|
-
we didn't include in the task __init__ method.
|
63
|
+
we didn't include in the task `__init__` method.
|
63
64
|
We may eventually move all the task __init__ params to this class, analogous to how
|
64
|
-
we have config classes for Agent
|
65
|
+
we have config classes for `Agent`, `ChatAgent`, `LanguageModel`, etc.
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
Attributes:
|
68
|
+
inf_loop_cycle_len: max exact-loop cycle length: 0 => no inf loop test
|
69
|
+
inf_loop_dominance_factor: dominance factor for exact-loop detection
|
70
|
+
inf_loop_wait_factor: wait this * cycle_len msgs before loop-check
|
71
|
+
"""
|
72
|
+
|
73
|
+
inf_loop_cycle_len: int = 10
|
74
|
+
inf_loop_dominance_factor: float = 1.5
|
69
75
|
inf_loop_wait_factor: float = 5.0
|
70
76
|
|
71
77
|
|
@@ -517,7 +523,12 @@ class Task:
|
|
517
523
|
and i % self.config.inf_loop_cycle_len == 0
|
518
524
|
and self._maybe_infinite_loop()
|
519
525
|
):
|
520
|
-
raise InfiniteLoopException(
|
526
|
+
raise InfiniteLoopException(
|
527
|
+
"""Possible infinite loop detected!
|
528
|
+
You can adjust infinite loop detection by changing the params
|
529
|
+
in the TaskConfig passed to the Task constructor:
|
530
|
+
e.g. set inf_loop_cycle_len=0 to disable loop detection."""
|
531
|
+
)
|
521
532
|
|
522
533
|
final_result = self.result()
|
523
534
|
if final_result is not None:
|
@@ -587,6 +598,7 @@ class Task:
|
|
587
598
|
i = 0
|
588
599
|
while True:
|
589
600
|
await self.step_async()
|
601
|
+
await asyncio.sleep(0.01) # temp yield to avoid blocking
|
590
602
|
done, status = self.done()
|
591
603
|
if done:
|
592
604
|
if self._level == 0 and not settings.quiet:
|
@@ -606,7 +618,12 @@ class Task:
|
|
606
618
|
and i % self.config.inf_loop_cycle_len == 0
|
607
619
|
and self._maybe_infinite_loop()
|
608
620
|
):
|
609
|
-
raise InfiniteLoopException(
|
621
|
+
raise InfiniteLoopException(
|
622
|
+
"""Possible infinite loop detected!
|
623
|
+
You can adjust infinite loop detection by changing the params
|
624
|
+
in the TaskConfig passed to the Task constructor:
|
625
|
+
e.g. set inf_loop_cycle_len=0 to disable loop detection."""
|
626
|
+
)
|
610
627
|
|
611
628
|
final_result = self.result()
|
612
629
|
if final_result is not None:
|
@@ -1122,7 +1139,7 @@ class Task:
|
|
1122
1139
|
where F = config.inf_loop_dominance_factor (default 1.5) and
|
1123
1140
|
W = config.inf_loop_wait_factor (default 5).
|
1124
1141
|
So if you plot these frequencies in decreasing order,
|
1125
|
-
you will see a big in the plot, from m to m+1.
|
1142
|
+
you will see a big drop in the plot, from m to m+1.
|
1126
1143
|
We call the freqs until m the "dominant" freqs.
|
1127
1144
|
2. Say we found m such dominant frequencies.
|
1128
1145
|
If these are the same as the freqs of the last m messages,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/lance_rag/query_planner_agent.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.251 → langroid-0.1.252}/langroid/agent/special/sql/utils/description_extractors.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.251 → langroid-0.1.252}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.1.251 → langroid-0.1.252}/langroid/language_models/prompt_formatter/llama2_formatter.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|