openbb-agent-server 0.1.0__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.
- openbb_agent_server/__init__.py +17 -0
- openbb_agent_server/_vendor/__init__.py +0 -0
- openbb_agent_server/_vendor/sqlitevec.py +135 -0
- openbb_agent_server/acp/__init__.py +32 -0
- openbb_agent_server/acp/canvas.py +1056 -0
- openbb_agent_server/acp/canvas_app.py +480 -0
- openbb_agent_server/acp/provider.py +580 -0
- openbb_agent_server/app/__init__.py +1 -0
- openbb_agent_server/app/app.py +299 -0
- openbb_agent_server/app/config.py +754 -0
- openbb_agent_server/app/router.py +1680 -0
- openbb_agent_server/app/settings.py +779 -0
- openbb_agent_server/main.py +396 -0
- openbb_agent_server/memory/__init__.py +1 -0
- openbb_agent_server/memory/classifier.py +201 -0
- openbb_agent_server/memory/embeddings.py +118 -0
- openbb_agent_server/memory/factory.py +226 -0
- openbb_agent_server/memory/ingestion.py +424 -0
- openbb_agent_server/memory/reranker.py +165 -0
- openbb_agent_server/memory/retrievers.py +177 -0
- openbb_agent_server/memory/sqlite_store.py +593 -0
- openbb_agent_server/memory/store.py +196 -0
- openbb_agent_server/memory/translation.py +161 -0
- openbb_agent_server/memory/writer.py +163 -0
- openbb_agent_server/observability/__init__.py +1 -0
- openbb_agent_server/observability/logging.py +272 -0
- openbb_agent_server/openbb.toml.example +332 -0
- openbb_agent_server/persistence/__init__.py +1 -0
- openbb_agent_server/persistence/models.py +650 -0
- openbb_agent_server/persistence/prune.py +297 -0
- openbb_agent_server/persistence/sqlite_store.py +857 -0
- openbb_agent_server/persistence/store.py +444 -0
- openbb_agent_server/plugins/__init__.py +1 -0
- openbb_agent_server/plugins/auth/__init__.py +1 -0
- openbb_agent_server/plugins/auth/api_key_table.py +303 -0
- openbb_agent_server/plugins/auth/bearer_static.py +107 -0
- openbb_agent_server/plugins/auth/none.py +60 -0
- openbb_agent_server/plugins/auth/oidc_jwt.py +138 -0
- openbb_agent_server/plugins/auth/openbb_workspace.py +111 -0
- openbb_agent_server/plugins/checkpointers/__init__.py +1 -0
- openbb_agent_server/plugins/checkpointers/inmemory.py +61 -0
- openbb_agent_server/plugins/checkpointers/postgres.py +148 -0
- openbb_agent_server/plugins/checkpointers/sqlite.py +109 -0
- openbb_agent_server/plugins/middleware/__init__.py +1 -0
- openbb_agent_server/plugins/middleware/call_limit.py +143 -0
- openbb_agent_server/plugins/middleware/loop_guard.py +152 -0
- openbb_agent_server/plugins/middleware/tool_call_announcer.py +120 -0
- openbb_agent_server/plugins/middleware/tool_call_ledger.py +147 -0
- openbb_agent_server/plugins/middleware/tool_filter.py +117 -0
- openbb_agent_server/plugins/middleware/tool_message_normaliser.py +336 -0
- openbb_agent_server/plugins/middleware/usage_recorder.py +95 -0
- openbb_agent_server/plugins/models/__init__.py +1 -0
- openbb_agent_server/plugins/models/_validation.py +55 -0
- openbb_agent_server/plugins/models/anthropic_provider.py +158 -0
- openbb_agent_server/plugins/models/bedrock_provider.py +182 -0
- openbb_agent_server/plugins/models/fake_provider.py +138 -0
- openbb_agent_server/plugins/models/google_genai_provider.py +226 -0
- openbb_agent_server/plugins/models/groq_provider.py +248 -0
- openbb_agent_server/plugins/models/groq_rate_limiter.py +447 -0
- openbb_agent_server/plugins/models/nvidia_provider.py +241 -0
- openbb_agent_server/plugins/models/openai_compat_provider.py +266 -0
- openbb_agent_server/plugins/models/openai_provider.py +198 -0
- openbb_agent_server/plugins/models/vertex_provider.py +221 -0
- openbb_agent_server/plugins/subagents/__init__.py +1 -0
- openbb_agent_server/plugins/subagents/analyst.py +50 -0
- openbb_agent_server/plugins/subagents/charter.py +51 -0
- openbb_agent_server/plugins/subagents/pdf_reader.py +57 -0
- openbb_agent_server/plugins/subagents/researcher.py +69 -0
- openbb_agent_server/plugins/tools/__init__.py +1 -0
- openbb_agent_server/plugins/tools/_media.py +470 -0
- openbb_agent_server/plugins/tools/artifacts.py +328 -0
- openbb_agent_server/plugins/tools/background_jobs.py +158 -0
- openbb_agent_server/plugins/tools/client_side.py +115 -0
- openbb_agent_server/plugins/tools/dashboard.py +108 -0
- openbb_agent_server/plugins/tools/fetch_url.py +294 -0
- openbb_agent_server/plugins/tools/gemini_embeddings.py +230 -0
- openbb_agent_server/plugins/tools/gemini_image.py +621 -0
- openbb_agent_server/plugins/tools/gemma_audio.py +461 -0
- openbb_agent_server/plugins/tools/groq_audio.py +404 -0
- openbb_agent_server/plugins/tools/inspect_widget_data.py +389 -0
- openbb_agent_server/plugins/tools/mcp_http.py +230 -0
- openbb_agent_server/plugins/tools/mcp_local.py +194 -0
- openbb_agent_server/plugins/tools/memory_recall.py +95 -0
- openbb_agent_server/plugins/tools/paligemma_vision.py +468 -0
- openbb_agent_server/plugins/tools/pdf_extract.py +1089 -0
- openbb_agent_server/plugins/tools/python_module.py +93 -0
- openbb_agent_server/plugins/tools/pywry_canvas.py +1730 -0
- openbb_agent_server/plugins/tools/rerank.py +160 -0
- openbb_agent_server/plugins/tools/translate.py +138 -0
- openbb_agent_server/plugins/tools/vision_qa.py +380 -0
- openbb_agent_server/plugins/tools/web_search.py +177 -0
- openbb_agent_server/plugins/tools/widget_data.py +194 -0
- openbb_agent_server/plugins/tools/workspace_mcp.py +84 -0
- openbb_agent_server/prompts/__init__.py +12 -0
- openbb_agent_server/prompts/default_system_prompt.md +412 -0
- openbb_agent_server/protocol/__init__.py +1 -0
- openbb_agent_server/protocol/adapter.py +771 -0
- openbb_agent_server/protocol/schemas.py +556 -0
- openbb_agent_server/protocol/sse.py +60 -0
- openbb_agent_server/py.typed +0 -0
- openbb_agent_server/runtime/__init__.py +1 -0
- openbb_agent_server/runtime/builder.py +987 -0
- openbb_agent_server/runtime/canvas.py +234 -0
- openbb_agent_server/runtime/context.py +216 -0
- openbb_agent_server/runtime/embedded.py +384 -0
- openbb_agent_server/runtime/emit.py +568 -0
- openbb_agent_server/runtime/identity.py +118 -0
- openbb_agent_server/runtime/jobs.py +386 -0
- openbb_agent_server/runtime/pdf_store.py +715 -0
- openbb_agent_server/runtime/plugins.py +190 -0
- openbb_agent_server/runtime/principal.py +54 -0
- openbb_agent_server/runtime/registry.py +107 -0
- openbb_agent_server/runtime/services.py +169 -0
- openbb_agent_server/runtime/widget_store.py +707 -0
- openbb_agent_server-0.1.0.dist-info/METADATA +137 -0
- openbb_agent_server-0.1.0.dist-info/RECORD +118 -0
- openbb_agent_server-0.1.0.dist-info/WHEEL +4 -0
- openbb_agent_server-0.1.0.dist-info/entry_points.txt +67 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""OpenBB Platform Agent Server — pluggable, multi-tenant agent backend."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
from langchain_core._api.deprecation import ( # noqa: E402
|
|
10
|
+
LangChainPendingDeprecationWarning,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
warnings.filterwarnings(
|
|
14
|
+
"ignore",
|
|
15
|
+
message=r"The default value of `allowed_objects` will change.*",
|
|
16
|
+
category=LangChainPendingDeprecationWarning,
|
|
17
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Vendored SQLiteVec vector store.
|
|
2
|
+
|
|
3
|
+
Adapted from ``langchain_community.vectorstores.sqlitevec`` (MIT licence)
|
|
4
|
+
to remove the ``langchain-community`` dependency, which is now archived.
|
|
5
|
+
|
|
6
|
+
Only the surface used by this project is kept:
|
|
7
|
+
|
|
8
|
+
* ``create_table_if_not_exists``
|
|
9
|
+
* ``add_texts``
|
|
10
|
+
* ``similarity_search_with_score``
|
|
11
|
+
|
|
12
|
+
The class intentionally does **not** manage connection lifecycle — the
|
|
13
|
+
caller is responsible for opening and closing the ``sqlite3.Connection``.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import sqlite3
|
|
20
|
+
import struct
|
|
21
|
+
from typing import Any
|
|
22
|
+
|
|
23
|
+
from langchain_core.documents import Document
|
|
24
|
+
from langchain_core.embeddings import Embeddings
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _serialize_f32(vector: list[float]) -> bytes:
|
|
28
|
+
"""Pack a float vector into the raw-bytes format sqlite-vec expects."""
|
|
29
|
+
return struct.pack(f"{len(vector)}f", *vector)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SQLiteVec:
|
|
33
|
+
"""Thin wrapper around a ``sqlite-vec`` virtual table.
|
|
34
|
+
|
|
35
|
+
Requires a pre-configured ``sqlite3.Connection`` with the ``sqlite-vec``
|
|
36
|
+
extension already loaded.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
table: str,
|
|
42
|
+
connection: sqlite3.Connection,
|
|
43
|
+
embedding: Embeddings,
|
|
44
|
+
db_file: str = "vec.db",
|
|
45
|
+
) -> None:
|
|
46
|
+
self._connection = connection
|
|
47
|
+
self._table = table
|
|
48
|
+
self._embedding = embedding
|
|
49
|
+
|
|
50
|
+
# ------------------------------------------------------------------
|
|
51
|
+
# Schema helpers
|
|
52
|
+
# ------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
def create_table_if_not_exists(self) -> None:
|
|
55
|
+
"""Create the data table, vec0 virtual table, and insert trigger."""
|
|
56
|
+
dim = len(self._embedding.embed_query("dim probe"))
|
|
57
|
+
self._connection.execute(
|
|
58
|
+
f"CREATE TABLE IF NOT EXISTS {self._table}"
|
|
59
|
+
" (rowid INTEGER PRIMARY KEY AUTOINCREMENT,"
|
|
60
|
+
" text TEXT, metadata BLOB, text_embedding BLOB)"
|
|
61
|
+
)
|
|
62
|
+
self._connection.execute(
|
|
63
|
+
f"CREATE VIRTUAL TABLE IF NOT EXISTS {self._table}_vec"
|
|
64
|
+
f" USING vec0(rowid INTEGER PRIMARY KEY,"
|
|
65
|
+
f" text_embedding float[{dim}])"
|
|
66
|
+
)
|
|
67
|
+
self._connection.execute(
|
|
68
|
+
f"CREATE TRIGGER IF NOT EXISTS {self._table}_embed_text "
|
|
69
|
+
f"AFTER INSERT ON {self._table} BEGIN"
|
|
70
|
+
f" INSERT INTO {self._table}_vec(rowid, text_embedding)"
|
|
71
|
+
f" VALUES (new.rowid, new.text_embedding); END;"
|
|
72
|
+
)
|
|
73
|
+
self._connection.commit()
|
|
74
|
+
|
|
75
|
+
# ------------------------------------------------------------------
|
|
76
|
+
# Write
|
|
77
|
+
# ------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
def add_texts(
|
|
80
|
+
self,
|
|
81
|
+
texts: list[str],
|
|
82
|
+
metadatas: list[dict[str, Any]],
|
|
83
|
+
**kwargs: Any,
|
|
84
|
+
) -> list[int]:
|
|
85
|
+
"""Embed *texts* and insert them into the store.
|
|
86
|
+
|
|
87
|
+
Returns the ``rowid`` values of the newly inserted rows.
|
|
88
|
+
"""
|
|
89
|
+
row = self._connection.execute(
|
|
90
|
+
f"SELECT max(rowid) AS rowid FROM {self._table}"
|
|
91
|
+
).fetchone()
|
|
92
|
+
max_id: int = row["rowid"] if row["rowid"] is not None else 0
|
|
93
|
+
|
|
94
|
+
embeds = self._embedding.embed_documents(list(texts))
|
|
95
|
+
|
|
96
|
+
self._connection.executemany(
|
|
97
|
+
f"INSERT INTO {self._table}(text, metadata, text_embedding)"
|
|
98
|
+
" VALUES (?, ?, ?)",
|
|
99
|
+
[
|
|
100
|
+
(text, json.dumps(meta), _serialize_f32(emb))
|
|
101
|
+
for text, meta, emb in zip(texts, metadatas, embeds)
|
|
102
|
+
],
|
|
103
|
+
)
|
|
104
|
+
self._connection.commit()
|
|
105
|
+
|
|
106
|
+
rows = self._connection.execute(
|
|
107
|
+
f"SELECT rowid FROM {self._table} WHERE rowid > {max_id}"
|
|
108
|
+
)
|
|
109
|
+
return [r["rowid"] for r in rows]
|
|
110
|
+
|
|
111
|
+
# ------------------------------------------------------------------
|
|
112
|
+
# Read
|
|
113
|
+
# ------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
def similarity_search_with_score(
|
|
116
|
+
self, query: str, k: int = 4, **kwargs: Any
|
|
117
|
+
) -> list[tuple[Document, float]]:
|
|
118
|
+
"""Return the *k* closest documents with their distance scores."""
|
|
119
|
+
embedding = self._embedding.embed_query(query)
|
|
120
|
+
cursor = self._connection.cursor()
|
|
121
|
+
cursor.execute(
|
|
122
|
+
f"SELECT text, metadata, distance"
|
|
123
|
+
f" FROM {self._table} AS e"
|
|
124
|
+
f" INNER JOIN {self._table}_vec AS v ON v.rowid = e.rowid"
|
|
125
|
+
f" WHERE v.text_embedding MATCH ? AND k = ?"
|
|
126
|
+
f" ORDER BY distance",
|
|
127
|
+
[_serialize_f32(embedding), k],
|
|
128
|
+
)
|
|
129
|
+
results: list[tuple[Document, float]] = []
|
|
130
|
+
for row in cursor.fetchall():
|
|
131
|
+
meta = json.loads(row["metadata"]) if row["metadata"] else {}
|
|
132
|
+
results.append(
|
|
133
|
+
(Document(page_content=row["text"], metadata=meta), row["distance"])
|
|
134
|
+
)
|
|
135
|
+
return results
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""ACP shim — expose the agent loop to PyWry chat components.
|
|
2
|
+
|
|
3
|
+
Lazy re-exports so ``import openbb_agent_server.acp`` works without
|
|
4
|
+
pywry installed; the ImportError with install instructions surfaces on
|
|
5
|
+
first attribute access instead. ``PyWryCanvas`` / ``build_canvas_html``
|
|
6
|
+
are pywry-free and always importable.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from importlib import import_module
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
_EXPORTS: dict[str, str] = {
|
|
15
|
+
"OpenBBAgentProvider": "openbb_agent_server.acp.provider",
|
|
16
|
+
"create_chat_manager": "openbb_agent_server.acp.provider",
|
|
17
|
+
"translate_sse": "openbb_agent_server.acp.provider",
|
|
18
|
+
"launch": "openbb_agent_server.acp.canvas_app",
|
|
19
|
+
"CanvasApp": "openbb_agent_server.acp.canvas_app",
|
|
20
|
+
"PyWryCanvas": "openbb_agent_server.acp.canvas",
|
|
21
|
+
"build_canvas_html": "openbb_agent_server.acp.canvas",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
__all__ = list(_EXPORTS)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def __getattr__(name: str) -> Any:
|
|
28
|
+
"""Defer submodule imports until a symbol is actually used."""
|
|
29
|
+
module_path = _EXPORTS.get(name)
|
|
30
|
+
if module_path is None:
|
|
31
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
32
|
+
return getattr(import_module(module_path), name)
|