Skip to content

Commit e8598be

Browse files
agnieszka-mdfokina
andauthored
Docs: Update OpenAIGen docstrings and add missing headers (#8105)
* update docstrings * Update haystack/components/generators/openai.py Co-authored-by: Daria Fokina <[email protected]> --------- Co-authored-by: Daria Fokina <[email protected]>
1 parent 92e2377 commit e8598be

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

haystack/components/generators/openai.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,21 @@
1818
@component
1919
class OpenAIGenerator:
2020
"""
21-
Text generation component using OpenAI's large language models (LLMs).
21+
Generates text using OpenAI's large language models (LLMs).
2222
23-
Enables text generation using OpenAI's large language models (LLMs). It supports gpt-4 and gpt-3.5-turbo
24-
family of models.
23+
It works with the gpt-4 and gpt-3.5-turbo models and supports streaming responses
24+
from OpenAI API. It uses strings as input and output.
2525
26-
Users can pass any text generation parameters valid for the `openai.ChatCompletion.create` method
27-
directly to this component via the `**generation_kwargs` parameter in __init__ or the `**generation_kwargs`
28-
parameter in `run` method.
26+
You can customize how the text is generated by passing parameters to the
27+
OpenAI API. Use the `**generation_kwargs` argument when you initialize
28+
the component or when you run it. Any parameter that works with
29+
`openai.ChatCompletion.create` will work here too.
2930
30-
For more details on the parameters supported by the OpenAI API, refer to the OpenAI
31-
[documentation](https://platform.openai.com/docs/api-reference/chat).
3231
33-
Key Features and Compatibility:
34-
- Primary Compatibility: Designed to work seamlessly with gpt-4, gpt-3.5-turbo family of models.
35-
- Streaming Support: Supports streaming responses from the OpenAI API.
36-
- Customizability: Supports all parameters supported by the OpenAI API.
32+
For details on OpenAI API parameters, see
33+
[OpenAI documentation](https://platform.openai.com/docs/api-reference/chat).
3734
38-
Input and Output Format:
39-
- String Format: This component uses the strings for both input and output.
35+
### Usage example
4036
4137
```python
4238
from haystack.components.generators import OpenAIGenerator
@@ -65,12 +61,12 @@ def __init__(
6561
max_retries: Optional[int] = None,
6662
):
6763
"""
68-
Creates an instance of OpenAIGenerator. Unless specified otherwise in the `model`, OpenAI's GPT-3.5 is used.
64+
Creates an instance of OpenAIGenerator. Unless specified otherwise in `model`, uses OpenAI's GPT-3.5.
6965
7066
By setting the 'OPENAI_TIMEOUT' and 'OPENAI_MAX_RETRIES' you can change the timeout and max_retries parameters
7167
in the OpenAI client.
7268
73-
:param api_key: The OpenAI API key.
69+
:param api_key: The OpenAI API key to connect to OpenAI.
7470
:param model: The name of the model to use.
7571
:param streaming_callback: A callback function that is called when a new token is received from the stream.
7672
The callback function accepts StreamingChunk as an argument.

haystack/components/retrievers/in_memory/embedding_retriever.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InMemoryEmbeddingRetriever:
2020
In indexing pipelines, use a DocumentEmbedder to embed documents.
2121
In query pipelines, use a TextEmbedder to embed queries and send them to the retriever.
2222
23-
Usage example:
23+
### Usage example
2424
```python
2525
from haystack import Document
2626
from haystack.components.embedders import SentenceTransformersDocumentEmbedder, SentenceTransformersTextEmbedder

haystack/components/writers/document_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DocumentWriter:
1616
"""
1717
Writes documents to a DocumentStore.
1818
19-
Usage example:
19+
### Usage example
2020
```python
2121
from haystack import Document
2222
from haystack.components.writers import DocumentWriter

0 commit comments

Comments
 (0)