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 #### Skip tool call runs
This will surface the tool calls to the SDK instead of running them automatically on the Rowboat server. 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] [project]
name = "rowboat" name = "rowboat"
version = "1.0.4" version = "1.0.6"
authors = [ authors = [
{ name = "Your Name", email = "your.email@example.com" }, { name = "Your Name", email = "your.email@example.com" },
] ]

View file

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

View file

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