flowcept 0.8.11__py3-none-any.whl → 0.8.12__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.
- flowcept/__init__.py +7 -4
- flowcept/agents/__init__.py +5 -0
- flowcept/{flowceptor/consumers/agent/client_agent.py → agents/agent_client.py} +22 -12
- flowcept/agents/agents_utils.py +181 -0
- flowcept/agents/dynamic_schema_tracker.py +191 -0
- flowcept/agents/flowcept_agent.py +30 -0
- flowcept/agents/flowcept_ctx_manager.py +175 -0
- flowcept/agents/gui/__init__.py +5 -0
- flowcept/agents/gui/agent_gui.py +76 -0
- flowcept/agents/gui/gui_utils.py +239 -0
- flowcept/agents/llms/__init__.py +1 -0
- flowcept/agents/llms/claude_gcp.py +139 -0
- flowcept/agents/llms/gemini25.py +119 -0
- flowcept/agents/prompts/__init__.py +1 -0
- flowcept/{flowceptor/adapters/agents/prompts.py → agents/prompts/general_prompts.py} +18 -0
- flowcept/agents/prompts/in_memory_query_prompts.py +297 -0
- flowcept/agents/tools/__init__.py +1 -0
- flowcept/agents/tools/general_tools.py +102 -0
- flowcept/agents/tools/in_memory_queries/__init__.py +1 -0
- flowcept/agents/tools/in_memory_queries/in_memory_queries_tools.py +704 -0
- flowcept/agents/tools/in_memory_queries/pandas_agent_utils.py +309 -0
- flowcept/cli.py +286 -44
- flowcept/commons/daos/docdb_dao/mongodb_dao.py +47 -0
- flowcept/commons/daos/mq_dao/mq_dao_base.py +24 -13
- flowcept/commons/daos/mq_dao/mq_dao_kafka.py +18 -2
- flowcept/commons/flowcept_dataclasses/task_object.py +16 -21
- flowcept/commons/flowcept_dataclasses/workflow_object.py +9 -1
- flowcept/commons/task_data_preprocess.py +260 -60
- flowcept/commons/utils.py +25 -6
- flowcept/configs.py +41 -26
- flowcept/flowcept_api/flowcept_controller.py +73 -6
- flowcept/flowceptor/adapters/base_interceptor.py +11 -5
- flowcept/flowceptor/consumers/agent/base_agent_context_manager.py +25 -1
- flowcept/flowceptor/consumers/base_consumer.py +4 -0
- flowcept/flowceptor/consumers/consumer_utils.py +5 -4
- flowcept/flowceptor/consumers/document_inserter.py +2 -2
- flowcept/flowceptor/telemetry_capture.py +5 -2
- flowcept/instrumentation/flowcept_agent_task.py +294 -0
- flowcept/instrumentation/flowcept_decorator.py +43 -0
- flowcept/instrumentation/flowcept_loop.py +3 -3
- flowcept/instrumentation/flowcept_task.py +64 -24
- flowcept/instrumentation/flowcept_torch.py +5 -5
- flowcept/instrumentation/task_capture.py +83 -6
- flowcept/version.py +1 -1
- {flowcept-0.8.11.dist-info → flowcept-0.8.12.dist-info}/METADATA +42 -14
- {flowcept-0.8.11.dist-info → flowcept-0.8.12.dist-info}/RECORD +50 -36
- resources/sample_settings.yaml +12 -4
- flowcept/flowceptor/adapters/agents/__init__.py +0 -1
- flowcept/flowceptor/adapters/agents/agents_utils.py +0 -89
- flowcept/flowceptor/adapters/agents/flowcept_agent.py +0 -292
- flowcept/flowceptor/adapters/agents/flowcept_llm_prov_capture.py +0 -186
- flowcept/flowceptor/consumers/agent/flowcept_agent_context_manager.py +0 -145
- flowcept/flowceptor/consumers/agent/flowcept_qa_manager.py +0 -112
- {flowcept-0.8.11.dist-info → flowcept-0.8.12.dist-info}/WHEEL +0 -0
- {flowcept-0.8.11.dist-info → flowcept-0.8.12.dist-info}/entry_points.txt +0 -0
- {flowcept-0.8.11.dist-info → flowcept-0.8.12.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
from typing import Dict, List
|
|
2
|
-
|
|
3
|
-
from langchain.chains.retrieval_qa.base import RetrievalQA
|
|
4
|
-
from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
5
|
-
from langchain_community.vectorstores import FAISS
|
|
6
|
-
from langchain.schema import Document
|
|
7
|
-
from langchain_core.language_models import LLM
|
|
8
|
-
|
|
9
|
-
from flowcept.commons.flowcept_logger import FlowceptLogger
|
|
10
|
-
from flowcept.flowceptor.adapters.agents.agents_utils import build_llm_model
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# TODO If all methods are static, this doesnt need to be a class.
|
|
14
|
-
class FlowceptQAManager(object):
|
|
15
|
-
"""
|
|
16
|
-
Manager for building and loading question-answering (QA) chains using LangChain.
|
|
17
|
-
|
|
18
|
-
This utility constructs a `RetrievalQA` chain by converting task dictionaries into
|
|
19
|
-
`Document` objects, embedding them with HuggingFace, storing them in a FAISS vectorstore,
|
|
20
|
-
and returning a ready-to-query QA pipeline.
|
|
21
|
-
|
|
22
|
-
Attributes
|
|
23
|
-
----------
|
|
24
|
-
embedding_model : HuggingFaceEmbeddings
|
|
25
|
-
The default embedding model used to embed documents into vector representations.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
embedding_model = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
|
29
|
-
|
|
30
|
-
@staticmethod
|
|
31
|
-
def build_qa(docs: List[Dict] = None, llm: LLM = None):
|
|
32
|
-
"""
|
|
33
|
-
Build a RetrievalQA chain from a list of task dictionaries.
|
|
34
|
-
|
|
35
|
-
Parameters
|
|
36
|
-
----------
|
|
37
|
-
docs : List[Dict], optional
|
|
38
|
-
A list of task dictionaries to be converted into retrievable documents.
|
|
39
|
-
llm : LLM, optional
|
|
40
|
-
The language model to use for the QA chain. If None, a default model is built.
|
|
41
|
-
|
|
42
|
-
Returns
|
|
43
|
-
-------
|
|
44
|
-
dict
|
|
45
|
-
A dictionary containing:
|
|
46
|
-
- 'qa_chain': the constructed RetrievalQA chain
|
|
47
|
-
- 'path': local path where the FAISS vectorstore is saved
|
|
48
|
-
|
|
49
|
-
Notes
|
|
50
|
-
-----
|
|
51
|
-
If no documents are provided, the method returns None.
|
|
52
|
-
"""
|
|
53
|
-
if not len(docs):
|
|
54
|
-
return None
|
|
55
|
-
|
|
56
|
-
if llm is None:
|
|
57
|
-
llm = build_llm_model()
|
|
58
|
-
|
|
59
|
-
documents = []
|
|
60
|
-
for d in docs:
|
|
61
|
-
content = str(d) # convert the dict to a string
|
|
62
|
-
metadata = {"task_id": d.get("task_id", "unknown")}
|
|
63
|
-
documents.append(Document(page_content=content, metadata=metadata))
|
|
64
|
-
|
|
65
|
-
FlowceptLogger().debug(f"Number of documents to index: {len(documents)}")
|
|
66
|
-
vectorstore = FAISS.from_documents(documents=documents, embedding=FlowceptQAManager.embedding_model)
|
|
67
|
-
path = "/tmp/qa_index"
|
|
68
|
-
vectorstore.save_local(path)
|
|
69
|
-
|
|
70
|
-
retriever = vectorstore.as_retriever()
|
|
71
|
-
qa_chain = RetrievalQA.from_chain_type(llm=llm, retriever=retriever, return_source_documents=True)
|
|
72
|
-
|
|
73
|
-
return {"qa_chain": qa_chain, "path": path}
|
|
74
|
-
|
|
75
|
-
@staticmethod
|
|
76
|
-
def _load_qa_chain(path, llm=None, embedding_model=None) -> RetrievalQA:
|
|
77
|
-
if embedding_model is None:
|
|
78
|
-
embedding_model = FlowceptQAManager.embedding_model
|
|
79
|
-
if llm is None:
|
|
80
|
-
llm = build_llm_model()
|
|
81
|
-
|
|
82
|
-
vectorstore = FAISS.load_local(path, embeddings=embedding_model, allow_dangerous_deserialization=True)
|
|
83
|
-
|
|
84
|
-
retriever = vectorstore.as_retriever()
|
|
85
|
-
|
|
86
|
-
return RetrievalQA.from_chain_type(llm=llm, retriever=retriever, return_source_documents=True)
|
|
87
|
-
|
|
88
|
-
@staticmethod
|
|
89
|
-
def build_qa_chain_from_vectorstore_path(vectorstore_path, llm=None) -> RetrievalQA:
|
|
90
|
-
"""
|
|
91
|
-
Build a RetrievalQA chain from an existing vectorstore path.
|
|
92
|
-
|
|
93
|
-
Parameters
|
|
94
|
-
----------
|
|
95
|
-
vectorstore_path : str
|
|
96
|
-
Path to the FAISS vectorstore previously saved to disk.
|
|
97
|
-
llm : LLM, optional
|
|
98
|
-
Language model to use. If None, a default model is built.
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
RetrievalQA
|
|
103
|
-
A RetrievalQA chain constructed using the loaded vectorstore.
|
|
104
|
-
"""
|
|
105
|
-
if llm is None:
|
|
106
|
-
llm = build_llm_model() # TODO: consider making this llm instance static
|
|
107
|
-
qa_chain = FlowceptQAManager._load_qa_chain(
|
|
108
|
-
path=vectorstore_path, # Only here we really need the QA. We might no
|
|
109
|
-
llm=llm,
|
|
110
|
-
embedding_model=FlowceptQAManager.embedding_model,
|
|
111
|
-
)
|
|
112
|
-
return qa_chain
|
|
File without changes
|
|
File without changes
|
|
File without changes
|