feat: complete public wiki and embedded previews
This commit is contained in:
1 parent
bc49df4561
commit
30943159bf
18 files changed
+926
-48
No files matched your search
+25
@@ -492,6 +492,31 @@ class WeKnoraClient:
|
||||
raise WeKnoraError("WeKnora returned an invalid Wiki page")
|
||||
return dict(value)
|
||||
|
||||
async def get_wiki_index(
|
||||
self,
|
||||
knowledge_base_id: str,
|
||||
*,
|
||||
types: Sequence[str],
|
||||
limit: int = 50,
|
||||
cursor: str = "",
|
||||
) -> dict[str, Any]:
|
||||
params: dict[str, Any] = {
|
||||
"types": ",".join(value for value in types if value),
|
||||
"limit": max(1, min(limit, 500)),
|
||||
}
|
||||
if cursor:
|
||||
params["cursor"] = cursor
|
||||
value = _data(
|
||||
await self._request(
|
||||
"GET",
|
||||
f"/api/v1/knowledgebase/{quote(knowledge_base_id, safe='')}/wiki/index",
|
||||
params=params,
|
||||
)
|
||||
)
|
||||
if not isinstance(value, dict):
|
||||
raise WeKnoraError("WeKnora returned an invalid Wiki index")
|
||||
return dict(value)
|
||||
|
||||
async def create_wiki_page(self, knowledge_base_id: str, payload: Mapping[str, Any]) -> dict[str, Any]:
|
||||
value = _data(
|
||||
await self._request(
|
||||
|
||||
+4
-2
@@ -66,9 +66,11 @@ class StrictWikiEmbeddingClient:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if self.config.api_key:
|
||||
headers["Authorization"] = f"Bearer {self.config.api_key}"
|
||||
# ``dimensions`` is a local invariant, not a portable request option.
|
||||
# OpenAI-compatible BGE endpoints commonly reject that extra field
|
||||
# with HTTP 400 even though they always return a fixed-size vector.
|
||||
# Keep validating the response against the configured value below.
|
||||
payload: dict = {"model": self.config.model, "input": texts}
|
||||
if self.config.dimensions:
|
||||
payload["dimensions"] = self.config.dimensions
|
||||
last_error: WikiEmbeddingError | None = None
|
||||
for attempt in range(self.config.max_retries + 1):
|
||||
started = monotonic()
|
||||
|
||||
Reference in new issue
Block a user