flowllm 0.1.0__py3-none-any.whl → 0.1.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.
- flowllm/__init__.py +12 -0
- flowllm/app.py +25 -0
- flowllm/config/default_config.yaml +82 -0
- flowllm/config/pydantic_config_parser.py +242 -0
- flowllm/context/base_context.py +59 -0
- flowllm/context/flow_context.py +28 -0
- llmflow/op/prompt_mixin.py → flowllm/context/prompt_handler.py +25 -14
- flowllm/context/registry.py +26 -0
- flowllm/context/service_context.py +103 -0
- flowllm/embedding_model/__init__.py +1 -0
- {llmflow → flowllm}/embedding_model/base_embedding_model.py +2 -2
- {llmflow → flowllm}/embedding_model/openai_compatible_embedding_model.py +8 -8
- flowllm/flow_engine/__init__.py +1 -0
- flowllm/flow_engine/base_flow_engine.py +34 -0
- flowllm/flow_engine/simple_flow_engine.py +213 -0
- flowllm/llm/__init__.py +1 -0
- {llmflow → flowllm}/llm/base_llm.py +16 -24
- {llmflow → flowllm}/llm/openai_compatible_llm.py +64 -108
- flowllm/op/__init__.py +3 -0
- flowllm/op/akshare/get_ak_a_code_op.py +116 -0
- flowllm/op/akshare/get_ak_a_code_prompt.yaml +21 -0
- flowllm/op/akshare/get_ak_a_info_op.py +143 -0
- flowllm/op/base_op.py +169 -0
- flowllm/op/llm_base_op.py +63 -0
- flowllm/op/mock_op.py +42 -0
- flowllm/op/parallel_op.py +30 -0
- flowllm/op/sequential_op.py +29 -0
- flowllm/schema/flow_response.py +12 -0
- flowllm/schema/message.py +35 -0
- flowllm/schema/service_config.py +76 -0
- flowllm/schema/tool_call.py +110 -0
- flowllm/service/__init__.py +2 -0
- flowllm/service/base_service.py +59 -0
- flowllm/service/http_service.py +87 -0
- flowllm/service/mcp_service.py +45 -0
- flowllm/storage/__init__.py +1 -0
- flowllm/storage/vector_store/__init__.py +3 -0
- flowllm/storage/vector_store/base_vector_store.py +44 -0
- {llmflow → flowllm/storage}/vector_store/chroma_vector_store.py +11 -10
- {llmflow → flowllm/storage}/vector_store/es_vector_store.py +10 -9
- llmflow/vector_store/file_vector_store.py → flowllm/storage/vector_store/local_vector_store.py +110 -10
- flowllm/utils/common_utils.py +64 -0
- flowllm/utils/dataframe_cache.py +331 -0
- flowllm/utils/fetch_url.py +113 -0
- {llmflow → flowllm}/utils/timer.py +5 -4
- {flowllm-0.1.0.dist-info → flowllm-0.1.1.dist-info}/METADATA +31 -27
- flowllm-0.1.1.dist-info/RECORD +62 -0
- flowllm-0.1.1.dist-info/entry_points.txt +4 -0
- {flowllm-0.1.0.dist-info → flowllm-0.1.1.dist-info}/licenses/LICENSE +1 -1
- flowllm-0.1.1.dist-info/top_level.txt +1 -0
- flowllm-0.1.0.dist-info/RECORD +0 -66
- flowllm-0.1.0.dist-info/entry_points.txt +0 -3
- flowllm-0.1.0.dist-info/top_level.txt +0 -1
- llmflow/app.py +0 -53
- llmflow/config/config_parser.py +0 -80
- llmflow/config/mock_config.yaml +0 -58
- llmflow/embedding_model/__init__.py +0 -5
- llmflow/enumeration/agent_state.py +0 -8
- llmflow/llm/__init__.py +0 -5
- llmflow/mcp_server.py +0 -110
- llmflow/op/__init__.py +0 -10
- llmflow/op/base_op.py +0 -125
- llmflow/op/mock_op.py +0 -40
- llmflow/op/react/react_v1_op.py +0 -88
- llmflow/op/react/react_v1_prompt.yaml +0 -28
- llmflow/op/vector_store/__init__.py +0 -13
- llmflow/op/vector_store/recall_vector_store_op.py +0 -48
- llmflow/op/vector_store/update_vector_store_op.py +0 -28
- llmflow/op/vector_store/vector_store_action_op.py +0 -46
- llmflow/pipeline/pipeline.py +0 -94
- llmflow/pipeline/pipeline_context.py +0 -37
- llmflow/schema/app_config.py +0 -69
- llmflow/schema/experience.py +0 -144
- llmflow/schema/message.py +0 -68
- llmflow/schema/request.py +0 -32
- llmflow/schema/response.py +0 -29
- llmflow/service/__init__.py +0 -0
- llmflow/service/llmflow_service.py +0 -96
- llmflow/tool/__init__.py +0 -9
- llmflow/tool/base_tool.py +0 -80
- llmflow/tool/code_tool.py +0 -43
- llmflow/tool/dashscope_search_tool.py +0 -162
- llmflow/tool/mcp_tool.py +0 -77
- llmflow/tool/tavily_search_tool.py +0 -109
- llmflow/tool/terminate_tool.py +0 -23
- llmflow/utils/__init__.py +0 -0
- llmflow/utils/common_utils.py +0 -17
- llmflow/utils/file_handler.py +0 -25
- llmflow/utils/http_client.py +0 -156
- llmflow/utils/op_utils.py +0 -102
- llmflow/utils/registry.py +0 -33
- llmflow/vector_store/__init__.py +0 -7
- llmflow/vector_store/base_vector_store.py +0 -136
- {llmflow → flowllm/config}/__init__.py +0 -0
- {llmflow/config → flowllm/context}/__init__.py +0 -0
- {llmflow → flowllm}/enumeration/__init__.py +0 -0
- {llmflow → flowllm}/enumeration/chunk_enum.py +0 -0
- {llmflow → flowllm}/enumeration/http_enum.py +0 -0
- {llmflow → flowllm}/enumeration/role.py +0 -0
- {llmflow/op/react → flowllm/op/akshare}/__init__.py +0 -0
- {llmflow/pipeline → flowllm/schema}/__init__.py +0 -0
- {llmflow → flowllm}/schema/vector_node.py +0 -0
- {llmflow/schema → flowllm/utils}/__init__.py +0 -0
- {llmflow → flowllm}/utils/singleton.py +0 -0
- {flowllm-0.1.0.dist-info → flowllm-0.1.1.dist-info}/WHEEL +0 -0
@@ -1,136 +0,0 @@
|
|
1
|
-
import fcntl
|
2
|
-
import json
|
3
|
-
from abc import ABC
|
4
|
-
from pathlib import Path
|
5
|
-
from typing import List, Iterable
|
6
|
-
|
7
|
-
from loguru import logger
|
8
|
-
from pydantic import BaseModel, Field
|
9
|
-
from tqdm import tqdm
|
10
|
-
|
11
|
-
from llmflow.embedding_model.base_embedding_model import BaseEmbeddingModel
|
12
|
-
from llmflow.schema.vector_node import VectorNode
|
13
|
-
|
14
|
-
|
15
|
-
class BaseVectorStore(BaseModel, ABC):
|
16
|
-
embedding_model: BaseEmbeddingModel | None = Field(default=None)
|
17
|
-
batch_size: int = Field(default=1024)
|
18
|
-
|
19
|
-
@staticmethod
|
20
|
-
def _load_from_path(workspace_id: str, path: str | Path, callback_fn=None, **kwargs) -> Iterable[VectorNode]:
|
21
|
-
workspace_path = Path(path) / f"{workspace_id}.jsonl"
|
22
|
-
if not workspace_path.exists():
|
23
|
-
logger.warning(f"workspace_path={workspace_path} is not exists!")
|
24
|
-
return
|
25
|
-
|
26
|
-
with workspace_path.open() as f:
|
27
|
-
fcntl.flock(f, fcntl.LOCK_SH)
|
28
|
-
try:
|
29
|
-
for line in tqdm(f, desc="load from path"):
|
30
|
-
if line.strip():
|
31
|
-
node_dict = json.loads(line.strip())
|
32
|
-
if callback_fn:
|
33
|
-
node = callback_fn(node_dict)
|
34
|
-
else:
|
35
|
-
node = VectorNode(**node_dict, **kwargs)
|
36
|
-
node.workspace_id = workspace_id
|
37
|
-
yield node
|
38
|
-
|
39
|
-
finally:
|
40
|
-
fcntl.flock(f, fcntl.LOCK_UN)
|
41
|
-
|
42
|
-
@staticmethod
|
43
|
-
def _dump_to_path(nodes: Iterable[VectorNode], workspace_id: str, path: str | Path = "", callback_fn=None,
|
44
|
-
ensure_ascii: bool = False, **kwargs):
|
45
|
-
dump_path: Path = Path(path)
|
46
|
-
dump_path.mkdir(parents=True, exist_ok=True)
|
47
|
-
dump_file = dump_path / f"{workspace_id}.jsonl"
|
48
|
-
|
49
|
-
count = 0
|
50
|
-
with dump_file.open("w") as f:
|
51
|
-
fcntl.flock(f, fcntl.LOCK_EX)
|
52
|
-
try:
|
53
|
-
for node in tqdm(nodes, desc="dump to path"):
|
54
|
-
node.workspace_id = workspace_id
|
55
|
-
if callback_fn:
|
56
|
-
node_dict = callback_fn(node)
|
57
|
-
else:
|
58
|
-
node_dict = node.model_dump()
|
59
|
-
assert isinstance(node_dict, dict)
|
60
|
-
f.write(json.dumps(node_dict, ensure_ascii=ensure_ascii, **kwargs))
|
61
|
-
f.write("\n")
|
62
|
-
count += 1
|
63
|
-
|
64
|
-
return {"size": count}
|
65
|
-
finally:
|
66
|
-
fcntl.flock(f, fcntl.LOCK_UN)
|
67
|
-
|
68
|
-
def exist_workspace(self, workspace_id: str, **kwargs) -> bool:
|
69
|
-
raise NotImplementedError
|
70
|
-
|
71
|
-
def delete_workspace(self, workspace_id: str, **kwargs):
|
72
|
-
raise NotImplementedError
|
73
|
-
|
74
|
-
def create_workspace(self, workspace_id: str, **kwargs):
|
75
|
-
raise NotImplementedError
|
76
|
-
|
77
|
-
def _iter_workspace_nodes(self, workspace_id: str, **kwargs) -> Iterable[VectorNode]:
|
78
|
-
raise NotImplementedError
|
79
|
-
|
80
|
-
def dump_workspace(self, workspace_id: str, path: str | Path = "", callback_fn=None, **kwargs):
|
81
|
-
if not self.exist_workspace(workspace_id=workspace_id, **kwargs):
|
82
|
-
logger.warning(f"workspace_id={workspace_id} is not exist!")
|
83
|
-
return {}
|
84
|
-
|
85
|
-
return self._dump_to_path(nodes=self._iter_workspace_nodes(workspace_id=workspace_id, **kwargs),
|
86
|
-
workspace_id=workspace_id,
|
87
|
-
path=path,
|
88
|
-
callback_fn=callback_fn,
|
89
|
-
**kwargs)
|
90
|
-
|
91
|
-
def load_workspace(self, workspace_id: str, path: str | Path = "", nodes: List[VectorNode] = None, callback_fn=None,
|
92
|
-
**kwargs):
|
93
|
-
if self.exist_workspace(workspace_id, **kwargs):
|
94
|
-
self.delete_workspace(workspace_id=workspace_id, **kwargs)
|
95
|
-
logger.info(f"delete workspace_id={workspace_id}")
|
96
|
-
|
97
|
-
self.create_workspace(workspace_id=workspace_id, **kwargs)
|
98
|
-
|
99
|
-
all_nodes: List[VectorNode] = []
|
100
|
-
if nodes:
|
101
|
-
all_nodes.extend(nodes)
|
102
|
-
for node in self._load_from_path(path=path, workspace_id=workspace_id, callback_fn=callback_fn, **kwargs):
|
103
|
-
all_nodes.append(node)
|
104
|
-
self.insert(nodes=all_nodes, workspace_id=workspace_id, **kwargs)
|
105
|
-
return {"size": len(all_nodes)}
|
106
|
-
|
107
|
-
def copy_workspace(self, src_workspace_id: str, dest_workspace_id: str, **kwargs):
|
108
|
-
if not self.exist_workspace(workspace_id=src_workspace_id, **kwargs):
|
109
|
-
logger.warning(f"src_workspace_id={src_workspace_id} is not exist!")
|
110
|
-
return {}
|
111
|
-
|
112
|
-
if not self.exist_workspace(dest_workspace_id, **kwargs):
|
113
|
-
self.create_workspace(workspace_id=dest_workspace_id, **kwargs)
|
114
|
-
|
115
|
-
nodes = []
|
116
|
-
node_size = 0
|
117
|
-
for node in self._iter_workspace_nodes(workspace_id=src_workspace_id, **kwargs):
|
118
|
-
nodes.append(node)
|
119
|
-
node_size += 1
|
120
|
-
if len(nodes) >= self.batch_size:
|
121
|
-
self.insert(nodes=nodes, workspace_id=dest_workspace_id, **kwargs)
|
122
|
-
nodes.clear()
|
123
|
-
|
124
|
-
if nodes:
|
125
|
-
self.insert(nodes=nodes, workspace_id=dest_workspace_id, **kwargs)
|
126
|
-
return {"size": node_size}
|
127
|
-
|
128
|
-
def search(self, query: str, workspace_id: str, top_k: int = 1, **kwargs) -> List[VectorNode]:
|
129
|
-
raise NotImplementedError
|
130
|
-
|
131
|
-
def insert(self, nodes: VectorNode | List[VectorNode], workspace_id: str, **kwargs):
|
132
|
-
raise NotImplementedError
|
133
|
-
|
134
|
-
def delete(self, node_ids: str | List[str], workspace_id: str, **kwargs):
|
135
|
-
raise NotImplementedError
|
136
|
-
|
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
|