Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalAI21 committed Dec 16, 2024
1 parent 2cd5541 commit 54c8e0e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
9 changes: 3 additions & 6 deletions ai21/clients/common/beta/assistant/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ def _create_body(
) -> Dict[str, Any]:
code_str = self._parse_code(code)

if schemas is NOT_GIVEN:
schema_dicts = NOT_GIVEN
else:
schema_dicts = [self._parse_schema(schema) for schema in schemas]

return remove_not_given(
{
"code": code_str,
"schemas": schema_dicts,
"schemas": [self._parse_schema(schema) for schema in schemas]
if schemas is not NOT_GIVEN
else NOT_GIVEN,
**kwargs,
}
)
Expand Down
2 changes: 1 addition & 1 deletion ai21/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ def __init__(self, details: Optional[str] = None):

class CodeParsingError(AI21Error):
def __init__(self, details: Optional[str] = None):
message = f"Code can't be parsed: {details}"
message = f"Code can't be parsed{'' if details is None else f': {details}'}"
super().__init__(message)
self.message = message
4 changes: 2 additions & 2 deletions ai21/models/responses/plan_response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional
from typing import List, Optional, Dict, Any

from ai21.models.ai21_base_model import AI21BaseModel

Expand All @@ -10,7 +10,7 @@ class PlanResponse(AI21BaseModel):
updated_at: datetime
assistant_id: str
code: str
schemas: List[dict]
schemas: List[Dict[str, Any]]


class ListPlanResponse(AI21BaseModel):
Expand Down
7 changes: 2 additions & 5 deletions examples/studio/assistant/user_defined_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def main():
assistant = ai21_client.beta.assistants.create(name="My Assistant")

plan = ai21_client.beta.assistants.plans.create(assistant_id=assistant.id, code=test_func, schemas=[ExampleSchema])
ai21_client.beta.assistants.routes.create(
route = ai21_client.beta.assistants.routes.create(
assistant_id=assistant.id, plan_id=plan.id, name="My Route", examples=["hi"], description="My Route Description"
)


if __name__ == "__main__":
main()
print(f"Route: {route}")

0 comments on commit 54c8e0e

Please sign in to comment.