Skip to content

Commit

Permalink
Merge pull request #21 from SubstrateLabs/ben-req-id
Browse files Browse the repository at this point in the history
add request_id to response
  • Loading branch information
0thernet authored Jun 13, 2024
2 parents c3f007c + 029ee29 commit 8b58513
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
summary = GenerateText(prompt=sb.concat("Summarize this story: ", story.future.text))

response = substrate.run(story, summary)
print(response.api_response.json)
print(response.api_response.status_code)
print(response)

# summary_out = response.get(summary)
# print(summary_out.text)
summary_out = response.get(summary)
print(summary_out.text)

# viz = Substrate.visualize(ry)
# print(viz)
12 changes: 12 additions & 0 deletions substrate/substrate_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ class SubstrateResponse:
def __init__(self, api_response: APIResponse):
self._api_response = api_response

def __str__(self):
return f"SubstrateResponse(request_id={self.request_id}, api_response={self._api_response.status_code})"

@property
def request_id(self) -> Optional[str]:
"""
The request id.
"""
if self.json:
return self.json.get("substrate_request_id")
return None

def get(self, node: CoreNode[OT]) -> OT:
"""
Get the output of a specific node.
Expand Down

0 comments on commit 8b58513

Please sign in to comment.