Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structure run tool #764

Merged
merged 7 commits into from
Apr 30, 2024
Merged

Add structure run tool #764

merged 7 commits into from
Apr 30, 2024

Conversation

zachgiordano
Copy link
Member

  • Add GriptapeCloudStructureRunClient tool for invoking Griptape Cloud Structure Run APIs
  • Refactor the Griptape Cloud tools to use a BaseGriptapeCloudClient

@zachgiordano zachgiordano requested review from collindutter, vachillo and a team April 29, 2024 19:11
Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work and thanks for the refactors!

Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just bake in the whole submit/polling logic into a single method. Can't think of any benefits to having the LLM be the one to poll.

@zachgiordano
Copy link
Member Author

@collindutter @vachillo Thanks for the comments! Attempted to address everything. Lmk how it looks

Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please create a docs page for this Tool.

@zachgiordano
Copy link
Member Author

@collindutter good call, added a docs page and refactored based on comments!

Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more minor things.

Comment on lines 82 to 99
@property
def description(self) -> str:
if self._description is None:
from requests import get

url = urljoin(self.base_url.strip("/"), f"/api/structures/{self.structure_id}/")

response = get(url, headers=self.headers).json()
if "description" in response:
self._description = response["description"]
else:
raise ValueError(f'Error getting Structure description: {response["message"]}')

return self._description

@description.setter
def description(self, value: str) -> None:
self._description = value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properties should come after class fields

status = result.get("status")

wait_attempts = 0
while status in ["QUEUED", "RUNNING"] and wait_attempts < self.structure_run_max_wait_time_attempts:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use tuple over list.

url = urljoin(self.base_url.strip("/"), f"/api/structure-runs/{structure_run_id}")

result = self._get_structure_run_result_attempt(url)
status = result.get("status")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the potential to be None. We should use a regular dictionary lookup or handle the None case if we ever expect it to be so.

Copy link
Member

@collindutter collindutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 😎

@zachgiordano zachgiordano merged commit a33324b into dev Apr 30, 2024
8 checks passed
@zachgiordano zachgiordano deleted the zach/structure-run-tool branch April 30, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants