Skip to content

Commit

Permalink
Improve pydoc
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje committed Jun 7, 2024
1 parent e360081 commit 3c8f07e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions haystack_experimental/components/tools/openapi/openapi_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
@component
class OpenAPITool:
"""
The OpenAPITool calls an OpenAPI service using payloads generated by the chat generator from human instructions.
The OpenAPITool calls a RESTful endpoint of an OpenAPI service using payloads generated from human instructions.
Here is an example of how to use the OpenAPITool component to scrape a URL using the FireCrawl API:
```python
from haystack_experimental.components.tools import OpenAPITool
from haystack.components.generators.chat.openai import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack_experimental.components.tools.openapi import OpenAPITool, LLMProvider
tool = OpenAPITool(model="gpt-3.5-turbo",
tool = OpenAPITool(generator_api=LLMProvider.OPENAI,
generator_api_params={"model":"gpt-3.5-turbo"},
tool_spec="https://raw.githubusercontent.com/mendableai/firecrawl/main/apps/api/openapi.json",
tool_credentials="<your-tool-token>")
Expand All @@ -63,8 +63,9 @@ def __init__(
Initialize the OpenAPITool component.
:param generator_api: The API provider for the chat generator.
:param generator_api_params: Parameters for the chat generator.
:param tool_spec: OpenAPI specification for the tool/service.
:param generator_api_params: Parameters to pass for the chat generator creation.
:param tool_spec: OpenAPI specification for the tool/service. This can be a URL, a local file path, or
an OpenAPI service specification provided as a string.
:param tool_credentials: Credentials for the tool/service.
"""
self.generator_api = generator_api
Expand Down Expand Up @@ -95,7 +96,10 @@ def run(
:param tool_spec: OpenAPI specification for the tool/service, overrides the one provided at initialization.
:param tool_credentials: Credentials for the tool/service, overrides the one provided at initialization.
:returns: a dictionary containing the service response with the following key:
- `service_response`: List of ChatMessages containing the service response.
- `service_response`: List of ChatMessages containing the service response. ChatMessages are generated
based on the response from the OpenAPI service/tool and contains the JSON response from the service.
If there is an error during the invocation, the response will be a ChatMessage with the error message under
the `error` key.
"""
last_message = messages[-1]
if not last_message.is_from(ChatRole.USER):
Expand Down

0 comments on commit 3c8f07e

Please sign in to comment.