flowcept 0.8.11__py3-none-any.whl → 0.9.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.
Files changed (56) hide show
  1. flowcept/__init__.py +7 -4
  2. flowcept/agents/__init__.py +5 -0
  3. flowcept/{flowceptor/consumers/agent/client_agent.py → agents/agent_client.py} +22 -12
  4. flowcept/agents/agents_utils.py +181 -0
  5. flowcept/agents/dynamic_schema_tracker.py +191 -0
  6. flowcept/agents/flowcept_agent.py +30 -0
  7. flowcept/agents/flowcept_ctx_manager.py +175 -0
  8. flowcept/agents/gui/__init__.py +5 -0
  9. flowcept/agents/gui/agent_gui.py +76 -0
  10. flowcept/agents/gui/gui_utils.py +239 -0
  11. flowcept/agents/llms/__init__.py +1 -0
  12. flowcept/agents/llms/claude_gcp.py +139 -0
  13. flowcept/agents/llms/gemini25.py +119 -0
  14. flowcept/agents/prompts/__init__.py +1 -0
  15. flowcept/{flowceptor/adapters/agents/prompts.py → agents/prompts/general_prompts.py} +18 -0
  16. flowcept/agents/prompts/in_memory_query_prompts.py +297 -0
  17. flowcept/agents/tools/__init__.py +1 -0
  18. flowcept/agents/tools/general_tools.py +102 -0
  19. flowcept/agents/tools/in_memory_queries/__init__.py +1 -0
  20. flowcept/agents/tools/in_memory_queries/in_memory_queries_tools.py +704 -0
  21. flowcept/agents/tools/in_memory_queries/pandas_agent_utils.py +309 -0
  22. flowcept/cli.py +286 -44
  23. flowcept/commons/daos/docdb_dao/mongodb_dao.py +47 -0
  24. flowcept/commons/daos/mq_dao/mq_dao_base.py +24 -13
  25. flowcept/commons/daos/mq_dao/mq_dao_kafka.py +18 -2
  26. flowcept/commons/flowcept_dataclasses/task_object.py +16 -21
  27. flowcept/commons/flowcept_dataclasses/workflow_object.py +9 -1
  28. flowcept/commons/task_data_preprocess.py +260 -60
  29. flowcept/commons/utils.py +25 -6
  30. flowcept/configs.py +41 -26
  31. flowcept/flowcept_api/flowcept_controller.py +73 -6
  32. flowcept/flowceptor/adapters/base_interceptor.py +11 -5
  33. flowcept/flowceptor/consumers/agent/base_agent_context_manager.py +25 -1
  34. flowcept/flowceptor/consumers/base_consumer.py +4 -0
  35. flowcept/flowceptor/consumers/consumer_utils.py +5 -4
  36. flowcept/flowceptor/consumers/document_inserter.py +2 -2
  37. flowcept/flowceptor/telemetry_capture.py +5 -2
  38. flowcept/instrumentation/flowcept_agent_task.py +294 -0
  39. flowcept/instrumentation/flowcept_decorator.py +43 -0
  40. flowcept/instrumentation/flowcept_loop.py +3 -3
  41. flowcept/instrumentation/flowcept_task.py +64 -24
  42. flowcept/instrumentation/flowcept_torch.py +5 -5
  43. flowcept/instrumentation/task_capture.py +83 -6
  44. flowcept/version.py +1 -1
  45. {flowcept-0.8.11.dist-info → flowcept-0.9.1.dist-info}/METADATA +42 -14
  46. {flowcept-0.8.11.dist-info → flowcept-0.9.1.dist-info}/RECORD +50 -36
  47. resources/sample_settings.yaml +12 -4
  48. flowcept/flowceptor/adapters/agents/__init__.py +0 -1
  49. flowcept/flowceptor/adapters/agents/agents_utils.py +0 -89
  50. flowcept/flowceptor/adapters/agents/flowcept_agent.py +0 -292
  51. flowcept/flowceptor/adapters/agents/flowcept_llm_prov_capture.py +0 -186
  52. flowcept/flowceptor/consumers/agent/flowcept_agent_context_manager.py +0 -145
  53. flowcept/flowceptor/consumers/agent/flowcept_qa_manager.py +0 -112
  54. {flowcept-0.8.11.dist-info → flowcept-0.9.1.dist-info}/WHEEL +0 -0
  55. {flowcept-0.8.11.dist-info → flowcept-0.9.1.dist-info}/entry_points.txt +0 -0
  56. {flowcept-0.8.11.dist-info → flowcept-0.9.1.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