url_artifact
Adapted from the Griptape AI Framework documentation.
Bases:
BaseArtifact
Attributes
Name | Type | Description |
---|---|---|
value | str | The url. |
Source Code in griptape/artifacts/url_artifact.py
@define class UrlArtifact(BaseArtifact): """Stores a url. Attributes: value: The url. """ value: str = field(metadata={"serializable": True}) def to_bytes(self, *, headers: dict | None = None, **kwargs: dict) -> bytes: """Fetches the content of the URL and returns it as bytes. Args: headers: Optional headers to include in the request. **kwargs: Additional keyword arguments, not used. Returns: bytes: The content of the URL as bytes. """ response = requests.get(self.value, headers=headers) response.raise_for_status() return response.content def to_text(self) -> str: """Returns the URL as is.""" return self.value
value = field(metadata={'serializable': True})
class-attribute instance-attribute
to_bytes(*, headers=None, **kwargs)
Fetches the content of the URL and returns it as bytes.
Parameters
Name | Type | Description | Default |
---|---|---|---|
headers | dict | None | Optional headers to include in the request. | None |
**kwargs | dict | Additional keyword arguments, not used. | {} |
Returns
Name | Type | Description |
---|---|---|
bytes | bytes | The content of the URL as bytes. |
Source Code in griptape/artifacts/url_artifact.py
def to_bytes(self, *, headers: dict | None = None, **kwargs: dict) -> bytes: """Fetches the content of the URL and returns it as bytes. Args: headers: Optional headers to include in the request. **kwargs: Additional keyword arguments, not used. Returns: bytes: The content of the URL as bytes. """ response = requests.get(self.value, headers=headers) response.raise_for_status() return response.content
to_text()
Source Code in griptape/artifacts/url_artifact.py
def to_text(self) -> str: """Returns the URL as is.""" return self.value
Could this page be better? Report a problem or suggest an addition!