beekeeper-core 1.0.2__py3-none-any.whl → 1.0.4__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.
- beekeeper/core/embeddings/base.py +23 -12
- beekeeper/core/evaluation/context_similarity.py +2 -2
- beekeeper/core/llms/__init__.py +1 -3
- beekeeper/core/llms/base.py +3 -3
- beekeeper/core/monitors/__init__.py +3 -0
- beekeeper/core/monitors/base.py +36 -0
- beekeeper/core/observers/__init__.py +2 -2
- beekeeper/core/observers/base.py +25 -28
- beekeeper/core/prompts/__init__.py +1 -1
- {beekeeper_core-1.0.2.dist-info → beekeeper_core-1.0.4.dist-info}/METADATA +1 -1
- {beekeeper_core-1.0.2.dist-info → beekeeper_core-1.0.4.dist-info}/RECORD +13 -11
- /beekeeper/core/{observers → monitors}/types.py +0 -0
- {beekeeper_core-1.0.2.dist-info → beekeeper_core-1.0.4.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from enum import Enum
|
|
3
|
-
from typing import List
|
|
3
|
+
from typing import List, Union
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from beekeeper.core.document import Document
|
|
@@ -43,17 +43,20 @@ class BaseEmbedding(TransformerComponent, ABC):
|
|
|
43
43
|
return "BaseEmbedding"
|
|
44
44
|
|
|
45
45
|
@abstractmethod
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"""Embed a single text string."""
|
|
51
|
-
return self.embed_texts([query])[0]
|
|
46
|
+
def embed_text(
|
|
47
|
+
self, input: Union[str, List[str]]
|
|
48
|
+
) -> Union[Embedding, List[Embedding]]:
|
|
49
|
+
"""Embed one or more text strings."""
|
|
52
50
|
|
|
53
51
|
def embed_documents(self, documents: List[Document]) -> List[Document]:
|
|
54
|
-
"""
|
|
52
|
+
"""
|
|
53
|
+
Embed a list of documents and assign the computed embeddings to the 'embedding' attribute.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
documents (List[Document]): List of documents to compute embeddings.
|
|
57
|
+
"""
|
|
55
58
|
texts = [document.get_content() for document in documents]
|
|
56
|
-
embeddings = self.
|
|
59
|
+
embeddings = self.embed_text(texts)
|
|
57
60
|
|
|
58
61
|
for document, embedding in zip(documents, embeddings):
|
|
59
62
|
document.embedding = embedding
|
|
@@ -61,7 +64,15 @@ class BaseEmbedding(TransformerComponent, ABC):
|
|
|
61
64
|
return documents
|
|
62
65
|
|
|
63
66
|
@deprecated(
|
|
64
|
-
reason="'
|
|
67
|
+
reason="'embed_texts()' is deprecated and will be removed in a future version. Use 'embed_text()' instead.",
|
|
68
|
+
version="1.0.3",
|
|
69
|
+
action="always",
|
|
70
|
+
)
|
|
71
|
+
def embed_texts(self, texts: List[str]) -> List[Embedding]:
|
|
72
|
+
return self.embed_text(texts)
|
|
73
|
+
|
|
74
|
+
@deprecated(
|
|
75
|
+
reason="'get_text_embedding()' is deprecated and will be removed in a future version. Use 'embed_text()' instead.",
|
|
65
76
|
version="1.0.2",
|
|
66
77
|
action="always",
|
|
67
78
|
)
|
|
@@ -69,7 +80,7 @@ class BaseEmbedding(TransformerComponent, ABC):
|
|
|
69
80
|
return self.embed_text(query)
|
|
70
81
|
|
|
71
82
|
@deprecated(
|
|
72
|
-
reason="'get_texts_embedding()' is deprecated and will be removed in a future version. Use 'embed_texts' instead.",
|
|
83
|
+
reason="'get_texts_embedding()' is deprecated and will be removed in a future version. Use 'embed_texts()' instead.",
|
|
73
84
|
version="1.0.2",
|
|
74
85
|
action="always",
|
|
75
86
|
)
|
|
@@ -77,7 +88,7 @@ class BaseEmbedding(TransformerComponent, ABC):
|
|
|
77
88
|
return self.embed_texts(texts)
|
|
78
89
|
|
|
79
90
|
@deprecated(
|
|
80
|
-
reason="'get_documents_embedding()' is deprecated and will be removed in a future version. Use 'embed_documents' instead.",
|
|
91
|
+
reason="'get_documents_embedding()' is deprecated and will be removed in a future version. Use 'embed_documents()' instead.",
|
|
81
92
|
version="1.0.2",
|
|
82
93
|
action="always",
|
|
83
94
|
)
|
|
@@ -53,10 +53,10 @@ class ContextSimilarityEvaluator(BaseModel):
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
evaluation_result = {"contexts_score": [], "score": 0}
|
|
56
|
-
candidate_embedding = self.embed_model.
|
|
56
|
+
candidate_embedding = self.embed_model.embed_text(generated_text)
|
|
57
57
|
|
|
58
58
|
for context in contexts:
|
|
59
|
-
context_embedding = self.embed_model.
|
|
59
|
+
context_embedding = self.embed_model.embed_text(context)
|
|
60
60
|
evaluation_result["contexts_score"].append(
|
|
61
61
|
self.embed_model.similarity(
|
|
62
62
|
candidate_embedding,
|
beekeeper/core/llms/__init__.py
CHANGED
beekeeper/core/llms/base.py
CHANGED
|
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|
|
2
2
|
from typing import Any, List, Optional
|
|
3
3
|
|
|
4
4
|
from beekeeper.core.llms.types import ChatMessage, ChatResponse, GenerateResponse
|
|
5
|
-
from beekeeper.core.
|
|
5
|
+
from beekeeper.core.monitors import BaseMonitor
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
|
|
8
8
|
|
|
@@ -10,14 +10,14 @@ class BaseLLM(ABC, BaseModel):
|
|
|
10
10
|
"""Abstract base class defining the interface for LLMs."""
|
|
11
11
|
|
|
12
12
|
model_config = {"arbitrary_types_allowed": True}
|
|
13
|
-
callback_manager: Optional[
|
|
13
|
+
callback_manager: Optional[BaseMonitor] = None
|
|
14
14
|
|
|
15
15
|
@classmethod
|
|
16
16
|
def class_name(cls) -> str:
|
|
17
17
|
return "BaseLLM"
|
|
18
18
|
|
|
19
19
|
def convert_chat_messages(self, messages: List[ChatMessage]) -> List[dict]:
|
|
20
|
-
"""Convert
|
|
20
|
+
"""Convert ChatMessage to LLM message dict format."""
|
|
21
21
|
return [message.model_dump() for message in messages]
|
|
22
22
|
|
|
23
23
|
@abstractmethod
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from beekeeper.core.monitors.types import PayloadRecord
|
|
5
|
+
from beekeeper.core.prompts import PromptTemplate
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseMonitor(ABC):
|
|
9
|
+
"""Abstract base class defining the interface for monitors."""
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def class_name(cls) -> str:
|
|
13
|
+
return "BaseMonitor"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PromptMonitor(BaseMonitor):
|
|
17
|
+
"""Abstract base class defining the interface for prompt observability."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, prompt_template: Optional[PromptTemplate] = None) -> None:
|
|
20
|
+
self.prompt_template = prompt_template
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def class_name(cls) -> str:
|
|
24
|
+
return "PromptMonitor"
|
|
25
|
+
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def __call__(self, payload: PayloadRecord) -> None:
|
|
28
|
+
"""PromptMonitor."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TelemetryMonitor(BaseMonitor):
|
|
32
|
+
"""Abstract base class defining the interface for telemetry observability."""
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def class_name(cls) -> str:
|
|
36
|
+
return "TelemetryMonitor"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from beekeeper.core.observers.base import BaseObserver, ModelObserver
|
|
1
|
+
from beekeeper.core.observers.base import BaseObserver, ModelObserver, PromptObserver
|
|
2
2
|
|
|
3
|
-
__all__ =
|
|
3
|
+
__all__ = ["BaseObserver", "ModelObserver", "PromptObserver"]
|
beekeeper/core/observers/base.py
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
from
|
|
2
|
-
from
|
|
1
|
+
from beekeeper.core.monitors import BaseMonitor, PromptMonitor
|
|
2
|
+
from deprecated import deprecated
|
|
3
3
|
|
|
4
|
-
from beekeeper.core.observers.types import PayloadRecord
|
|
5
|
-
from beekeeper.core.prompts import PromptTemplate
|
|
6
4
|
|
|
5
|
+
class BaseObserver(BaseMonitor):
|
|
6
|
+
"""DEPRECATED: An interface for observability."""
|
|
7
7
|
|
|
8
|
-
class BaseObserver(ABC):
|
|
9
|
-
"""An interface for observability."""
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
@deprecated(
|
|
10
|
+
reason="'PromptObserver()' is deprecated and will be removed in a future version. Use 'PromptMonitor()' from 'beekeeper.core.monitors' instead.",
|
|
11
|
+
version="1.0.4",
|
|
12
|
+
action="always",
|
|
13
|
+
)
|
|
14
|
+
class PromptObserver(PromptMonitor):
|
|
15
|
+
"""DEPRECATED: Abstract base class defining the interface for prompt observability."""
|
|
14
16
|
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
+
@deprecated(
|
|
19
|
+
reason="'ModelObserver()' is deprecated and will be removed in a future version. Use 'PromptMonitor()' from 'beekeeper.core.monitors' instead.",
|
|
20
|
+
version="1.0.3",
|
|
21
|
+
action="always",
|
|
22
|
+
)
|
|
23
|
+
class ModelObserver(PromptMonitor):
|
|
24
|
+
"""DEPRECATED: This class is deprecated and kept only for backward compatibility."""
|
|
18
25
|
|
|
19
|
-
def __init__(self, prompt_template: Optional[PromptTemplate] = None) -> None:
|
|
20
|
-
self.prompt_template = prompt_template
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class TelemetryObserver(BaseObserver):
|
|
32
|
-
"""Abstract base class defining the interface for telemetry observability."""
|
|
33
|
-
|
|
34
|
-
@classmethod
|
|
35
|
-
def class_name(cls) -> str:
|
|
36
|
-
return "TelemetryObserver"
|
|
27
|
+
@deprecated(
|
|
28
|
+
reason="'TelemetryObserver()' is deprecated and will be removed in a future version. Use 'TelemetryMonitor()' from 'beekeeper.core.monitors' instead.",
|
|
29
|
+
version="1.0.4",
|
|
30
|
+
action="always",
|
|
31
|
+
)
|
|
32
|
+
class TelemetryObserver(BaseMonitor):
|
|
33
|
+
"""DEPRECATED: Abstract base class defining the interface for telemetry observability."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: beekeeper-core
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: Load any data in one line of code and connect with AI applications
|
|
5
5
|
Project-URL: Repository, https://github.com/beekeeper-ai/beekeeper
|
|
6
6
|
Author-email: Leonardo Furnielis <leonardofurnielis@outlook.com>
|
|
@@ -3,19 +3,21 @@ beekeeper/core/schema.py,sha256=8OZkRVDry6nglof38w4AvWaRDpf0zOUtqGyfWBhj8lk,267
|
|
|
3
3
|
beekeeper/core/document/__init__.py,sha256=nCN0CNee1v-28W5a26Ca6iAVefcr_KAieAH6QfN4eyw,144
|
|
4
4
|
beekeeper/core/document/base.py,sha256=NBlyj8C0uvvsiElU1wFcXU27LOb3VP0U11nMgOR6cgY,2635
|
|
5
5
|
beekeeper/core/embeddings/__init__.py,sha256=4AzGUtoL7wComtQ-bEVwzoMQgahBhpxcF_4M5rQ0ClQ,159
|
|
6
|
-
beekeeper/core/embeddings/base.py,sha256=
|
|
6
|
+
beekeeper/core/embeddings/base.py,sha256=3r_gr9ceezuAXexkeS5Bq23778BeF7h--IDEvL5pLjE,3464
|
|
7
7
|
beekeeper/core/evaluation/__init__.py,sha256=FyZGpbTXcIM3BynssiS6wUm2KZkMnLVmKF50D7iqkXM,135
|
|
8
|
-
beekeeper/core/evaluation/context_similarity.py,sha256=
|
|
8
|
+
beekeeper/core/evaluation/context_similarity.py,sha256=kT1J3HUgF51HHQA5Sew9ahbSV_jhgbCBMRYqPLKlljQ,2690
|
|
9
9
|
beekeeper/core/flows/__init__.py,sha256=v6VLJ309l5bHYcG1JLUu6_kRoOwIZazonH4-n_UQzYQ,91
|
|
10
10
|
beekeeper/core/flows/ingestion_flow.py,sha256=lfZM6lHF9rBTviimSlptHm_1htaA5qLLhE-Sm_7fwGY,6110
|
|
11
|
-
beekeeper/core/llms/__init__.py,sha256=
|
|
12
|
-
beekeeper/core/llms/base.py,sha256=
|
|
11
|
+
beekeeper/core/llms/__init__.py,sha256=PN-5Y_Km_l2vO8v9d7iJ6_5xPCZJBh8UzwqRvQZlmTo,250
|
|
12
|
+
beekeeper/core/llms/base.py,sha256=cMllU_pJeNQGnSXX8WfHc09nrlLLx7cSKtRk9e_ubSg,1174
|
|
13
13
|
beekeeper/core/llms/decorators.py,sha256=lPfrQPFiCLAp468mVsiX6DIxSIvmrHjz3urnV9-q54U,3284
|
|
14
14
|
beekeeper/core/llms/types.py,sha256=CqLsB78y6-y8actABp87nHQh3AhHcE5i4IjeUxaXyA4,722
|
|
15
|
-
beekeeper/core/
|
|
16
|
-
beekeeper/core/
|
|
17
|
-
beekeeper/core/
|
|
18
|
-
beekeeper/core/
|
|
15
|
+
beekeeper/core/monitors/__init__.py,sha256=TvoiIUJtWRO_4zqCICsFaGl_v4Tpvft1M542Bi13pOI,112
|
|
16
|
+
beekeeper/core/monitors/base.py,sha256=3ooSfgVpWoRLe2TqizHMRK_bI5C-sla57aYJ47FmIXM,980
|
|
17
|
+
beekeeper/core/monitors/types.py,sha256=s-4tB8OdeaCUIRvi6FLuib2u4Yl9evqQdCundNREXQY,217
|
|
18
|
+
beekeeper/core/observers/__init__.py,sha256=Z5sDAajai4QLdGIrjq-vr5eJEBhriMMCw5u46j6xHvA,149
|
|
19
|
+
beekeeper/core/observers/base.py,sha256=y1SE_0WQusKhVomFuZCkk42Jb7r93ZS6r_j8vs_Y_r4,1203
|
|
20
|
+
beekeeper/core/prompts/__init__.py,sha256=kFp2N5giNEMA4hc3eZqstqaZu0c0BRAnP0NuF5aUaqI,85
|
|
19
21
|
beekeeper/core/prompts/base.py,sha256=cuRSv30aromymNO2wuuprrrWFm5PxRTymYoVqscK4Us,739
|
|
20
22
|
beekeeper/core/prompts/utils.py,sha256=Cqpefzzxd6DxPbOKVyUCsIs-ibBGKhYU6ppYqhPT9vM,1378
|
|
21
23
|
beekeeper/core/readers/__init__.py,sha256=vPCmWmK92LYL-R0LFcPqjOKFHqxW0xUP5r6M9GNxoqY,157
|
|
@@ -32,6 +34,6 @@ beekeeper/core/tools/base.py,sha256=A6TXn7g3DAZMREYAobfVlyOBuJn_8mIeCByc5412L9Y,
|
|
|
32
34
|
beekeeper/core/utils/pairwise.py,sha256=cpi8GItPFSYP4sjB5zgTFHi6JfBVWsMnNu8koA9VYQU,536
|
|
33
35
|
beekeeper/core/vector_stores/__init__.py,sha256=R5SRG3YpOZqRwIfBLB8KVV6FALWqhIzIhCjRGj-bwPc,93
|
|
34
36
|
beekeeper/core/vector_stores/base.py,sha256=YFW1ioZbFEcJovAh0ZCpHnj0eiXtZvqy_pj2lxPS92k,1652
|
|
35
|
-
beekeeper_core-1.0.
|
|
36
|
-
beekeeper_core-1.0.
|
|
37
|
-
beekeeper_core-1.0.
|
|
37
|
+
beekeeper_core-1.0.4.dist-info/METADATA,sha256=jQ78PrN-WvYM4Kmt_hLLEzPeWN_wrGk49mNGh826ZMY,1331
|
|
38
|
+
beekeeper_core-1.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
39
|
+
beekeeper_core-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|