add testProfileId option in py-sdk

This commit is contained in:
ramnique 2025-02-28 17:45:54 +05:30
parent 768c5749a0
commit edf901bf11
4 changed files with 32 additions and 7 deletions

View file

@ -101,6 +101,23 @@ chat = StatefulChat(
)
```
#### Using a test profile
You can specify a test profile ID to use a specific test configuration:
```python
response_messages, state = client.chat(
messages=messages,
test_profile_id="<TEST_PROFILE_ID>"
)
# or
chat = StatefulChat(
client,
test_profile_id="<TEST_PROFILE_ID>"
)
```
#### Skip tool call runs
This will surface the tool calls to the SDK instead of running them automatically on the Rowboat server.

View file

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "rowboat"
version = "1.0.4"
version = "1.0.6"
authors = [
{ name = "Your Name", email = "your.email@example.com" },
]

View file

@ -27,14 +27,16 @@ class Client:
state: Optional[Dict[str, Any]] = None,
skip_tool_calls: bool = False,
max_turns: int = 3,
workflow_id: Optional[str] = None
workflow_id: Optional[str] = None,
test_profile_id: Optional[str] = None
) -> ApiResponse:
request = ApiRequest(
messages=messages,
state=state,
skipToolCalls=skip_tool_calls,
maxTurns=max_turns,
workflowId=workflow_id
workflowId=workflow_id,
testProfileId=test_profile_id
)
response = requests.post(self.base_url, headers=self.headers, data=request.model_dump_json())
@ -83,7 +85,8 @@ class Client:
state: Optional[Dict[str, Any]] = None,
max_turns: int = 3,
skip_tool_calls: bool = False,
workflow_id: Optional[str] = None
workflow_id: Optional[str] = None,
test_profile_id: Optional[str] = None
) -> Tuple[List[ApiMessage], Optional[Dict[str, Any]]]:
"""Stateless chat method that handles a single conversation turn with multiple tool call rounds"""
@ -102,7 +105,8 @@ class Client:
state=current_state,
skip_tool_calls=skip_tool_calls,
max_turns=max_turns,
workflow_id=workflow_id
workflow_id=workflow_id,
test_profile_id=test_profile_id
)
current_messages.extend(response_data.messages)
@ -141,7 +145,8 @@ class StatefulChat:
system_prompt: Optional[str] = None,
max_turns: int = 3,
skip_tool_calls: bool = False,
workflow_id: Optional[str] = None
workflow_id: Optional[str] = None,
test_profile_id: Optional[str] = None
) -> None:
self.client = client
self.tools = tools
@ -150,6 +155,7 @@ class StatefulChat:
self.max_turns = max_turns
self.skip_tool_calls = skip_tool_calls
self.workflow_id = workflow_id
self.test_profile_id = test_profile_id
if system_prompt:
self.messages.append(SystemMessage(role='system', content=system_prompt))
@ -167,7 +173,8 @@ class StatefulChat:
state=self.state,
max_turns=self.max_turns,
skip_tool_calls=self.skip_tool_calls,
workflow_id=self.workflow_id
workflow_id=self.workflow_id,
test_profile_id=self.test_profile_id
)
# Update internal state

View file

@ -51,6 +51,7 @@ class ApiRequest(BaseModel):
skipToolCalls: Optional[bool] = None
maxTurns: Optional[int] = None
workflowId: Optional[str] = None
testProfileId: Optional[str] = None
class ApiResponse(BaseModel):
messages: List[ApiMessage]