Skip to content

Commit 7161e25

Browse files
Merge remote-tracking branch 'origin/main' into predict
2 parents 44f1f72 + 4b5852e commit 7161e25

7 files changed

Lines changed: 112 additions & 3 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2025, Salesforce, Inc.
2+
# SPDX-License-Identifier: Apache-2
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""Function runtime for Data Cloud Custom Code."""
17+
18+
from datacustomcode.function.runtime import Runtime
19+
20+
__all__ = ["Runtime"]
File renamed without changes.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) 2025, Salesforce, Inc.
2+
# SPDX-License-Identifier: Apache-2
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""
17+
Pydantic models for byoc-function-proto (uds_chunking.proto)
18+
Auto-generated - validation rules from buf.validate
19+
"""
20+
21+
from typing import (
22+
Any,
23+
Dict,
24+
List,
25+
Literal,
26+
)
27+
28+
from pydantic import BaseModel, Field
29+
30+
31+
class DocElement(BaseModel):
32+
"""Document element to be chunked"""
33+
34+
text: str = Field(..., description="Text content to be chunked")
35+
metadata: Dict[str, Any] = Field(
36+
default_factory=dict, description="Source document metadata"
37+
)
38+
39+
40+
class ChunkOutput(BaseModel):
41+
"""Output chunk from the chunking process"""
42+
43+
chunk_id: str = Field(..., description="UUID for this chunk")
44+
chunk_type: str = Field(..., description="Type: 'text'")
45+
text: str = Field(..., description="Chunk text content")
46+
seq_no: int = Field(..., description="Sequential chunk number (1-based)")
47+
metadata: Dict[str, str] = Field(
48+
default_factory=dict, description="Metadata from source (DMO fields)"
49+
)
50+
tag_metadata: Dict[str, Any] = Field(
51+
default_factory=dict, description="Additional tags"
52+
)
53+
citations: Dict[str, Any] = Field(
54+
default_factory=dict, description="Citation information"
55+
)
56+
57+
58+
class StatusResponse(BaseModel):
59+
"""Status response for operation"""
60+
61+
status_type: str = Field(..., description="'success' or 'error'")
62+
status_message: str = Field(..., description="Human-readable status")
63+
64+
65+
class UdsChunkingV1BatchRequest(BaseModel):
66+
"""Batch request for UDS chunking"""
67+
68+
version: Literal["v1"] = Field(
69+
default="v1", description="API version, must be 'v1'"
70+
)
71+
input: List[DocElement] = Field(
72+
..., min_length=1, description="List of documents (min 1)"
73+
)
74+
max_characters: int = Field(..., description="Max chars per chunk (default: 100)")
75+
additional_params: Dict[str, Any] = Field(
76+
default_factory=dict, description="Future extension point"
77+
)
78+
79+
80+
class UdsChunkingV1BatchResponse(BaseModel):
81+
"""Batch response for UDS chunking"""
82+
83+
version: Literal["v1"] = Field(
84+
default="v1", description="API version, must be 'v1'"
85+
)
86+
output: List[ChunkOutput] = Field(
87+
default_factory=list, description="Flat list of chunks from all docs"
88+
)
89+
status: StatusResponse = Field(..., description="Overall operation status")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from typing import Optional
1919

2020
from datacustomcode.file.path.default import DefaultFindFilePath
21+
from datacustomcode.function.base import BaseRuntime
2122
from datacustomcode.llm_gateway.default import DefaultLLMGateway
22-
from datacustomcode.runtime.base import BaseRuntime
2323

2424

2525
class Runtime(BaseRuntime):

src/datacustomcode/templates/function/payload/entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from typing import List
33
from uuid import uuid4
44

5+
from datacustomcode.function import Runtime
56
from datacustomcode.llm_gateway.types.generate_text_request_builder import (
67
GenerateTextRequestBuilder,
78
)
8-
from datacustomcode.runtime.function import Runtime
99

1010
logger = logging.getLogger(__name__)
1111

tests/test_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import pytest
66

77
from datacustomcode.file.path.default import DefaultFindFilePath
8+
from datacustomcode.function.runtime import Runtime
89
from datacustomcode.llm_gateway.default import DefaultLLMGateway
9-
from datacustomcode.runtime.function import Runtime
1010

1111

1212
class TestRuntimeSingleton:

0 commit comments

Comments
 (0)