Skip to content

Commit 18c20eb

Browse files
committed
docs: refactor models docstrings
1 parent 1409797 commit 18c20eb

File tree

8 files changed

+61
-103
lines changed

8 files changed

+61
-103
lines changed

scrapegraphai/models/azure_openai.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""
2-
Azure Openai configuration wrapper
2+
AzureOpenAI Module
33
"""
44
from langchain_openai import AzureChatOpenAI
55

66

77
class AzureOpenAI(AzureChatOpenAI):
8-
"""Class for wrapping openai module"""
8+
"""
9+
A wrapper for the AzureChatOpenAI class that provides default configuration
10+
and could be extended with additional methods if needed.
11+
12+
Args:
13+
llm_config (dict): Configuration parameters for the language model.
14+
"""
915

1016
def __init__(self, llm_config: dict):
11-
"""
12-
A wrapper for the ChatOpenAI class that provides default configuration
13-
and could be extended with additional methods if needed.
14-
15-
Args:
16-
llm_config (dict): Configuration parameters for the language model.
17-
"""
18-
# Initialize the superclass (AzureChatOpenAI) with provided config parameters
1917
super().__init__(**llm_config)

scrapegraphai/models/gemini.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
"""
2-
Gemini module configuration
2+
Gemini Module
33
"""
44
from langchain_google_genai import ChatGoogleGenerativeAI
55

66

77
class Gemini(ChatGoogleGenerativeAI):
8-
"""Class for wrapping gemini module"""
8+
"""
9+
A wrapper for the Gemini class that provides default configuration
10+
and could be extended with additional methods if needed.
911
10-
def __init__(self, llm_config: dict):
11-
"""
12-
A wrapper for the Gemini class that provides default configuration
13-
and could be extended with additional methods if needed.
12+
Args:
13+
llm_config (dict): Configuration parameters for the language model (e.g., model="gemini-pro")
14+
"""
1415

15-
Args:
16-
llm_config (dict): Configuration parameters for the language model.
17-
such as model="gemini-pro" and api_key
18-
"""
19-
# Initialize the superclass (ChatOpenAI) with provided config parameters
16+
def __init__(self, llm_config: dict):
2017
super().__init__(**llm_config)

scrapegraphai/models/groq.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
"""
2-
Groq module configuration
2+
Groq Module
33
"""
44

55
from langchain_groq import ChatGroq
66

77

88
class Groq(ChatGroq):
9-
"""Class for wrapping Groq module"""
9+
"""
10+
A wrapper for the Groq class that provides default configuration
11+
and could be extended with additional methods if needed.
1012
11-
def __init__(self, llm_config: dict):
12-
"""
13-
A wrapper for the Groq class that provides default configuration
14-
and could be extended with additional methods if needed.
13+
Args:
14+
llm_config (dict): Configuration parameters for the language model (e.g., model="llama3-70b-8192")
15+
"""
1516

16-
Args:
17-
llm_config (dict): Configuration parameters for the language model.
18-
such as model="llama3-70b-8192" and api_key
19-
"""
20-
# Initialize the superclass (ChatOpenAI) with provided config parameters
17+
def __init__(self, llm_config: dict):
2118
super().__init__(**llm_config)

scrapegraphai/models/hugging_face.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
"""
2-
Module for implementing the hugginface class
2+
HuggingFace Module
33
"""
44
from langchain_community.chat_models.huggingface import ChatHuggingFace
55

66

77
class HuggingFace(ChatHuggingFace):
8-
"""Provides a convenient wrapper for interacting with Hugging Face language models
9-
designed for conversational AI applications.
8+
"""
9+
A wrapper for the HuggingFace class that provides default configuration
10+
and could be extended with additional methods if needed.
1011
1112
Args:
12-
llm_config (dict): A configuration dictionary containing:
13-
* api_key (str, optional): Your Hugging Face API key.
14-
* model_name (str): The name of the Hugging Face LLM to load.
15-
* tokenizer_name (str, optional): Name of the corresponding tokenizer.
16-
* device (str, optional): Device for running the model ('cpu' by default).
17-
13+
llm_config (dict): Configuration parameters for the language model.
1814
"""
1915

2016
def __init__(self, llm_config: dict):
21-
"""Initializes the HuggingFace chat model wrapper"""
2217
super().__init__(**llm_config)

scrapegraphai/models/ollama.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""
2-
openai configuration wrapper
2+
Ollama Module
33
"""
44
from langchain_community.chat_models import ChatOllama
55

66

77
class Ollama(ChatOllama):
8-
"""Class for wrapping ollama module"""
8+
"""
9+
A wrapper for the ChatOllama class that provides default configuration
10+
and could be extended with additional methods if needed.
911
10-
def __init__(self, llm_config: dict):
11-
"""
12-
A wrapper for the ChatOllama class that provides default configuration
13-
and could be extended with additional methods if needed.
12+
Args:
13+
llm_config (dict): Configuration parameters for the language model.
14+
"""
1415

15-
Args:
16-
llm_config (dict): Configuration parameters for the language model.
17-
"""
18-
# Initialize the superclass (ChatOllama) with provided config parameters
16+
def __init__(self, llm_config: dict):
1917
super().__init__(**llm_config)

scrapegraphai/models/openai.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
"""
2-
openai configuration wrapper
2+
OpenAI Module
33
"""
44
from langchain_openai import ChatOpenAI
55

66

77
class OpenAI(ChatOpenAI):
8-
"""Class for wrapping openai module"""
8+
"""
9+
A wrapper for the ChatOpenAI class that provides default configuration
10+
and could be extended with additional methods if needed.
911
10-
def __init__(self, llm_config: dict):
11-
"""
12-
A wrapper for the ChatOpenAI class that provides default configuration
13-
and could be extended with additional methods if needed.
12+
Args:
13+
llm_config (dict): Configuration parameters for the language model.
14+
"""
1415

15-
Args:
16-
llm_config (dict): Configuration parameters for the language model.
17-
"""
18-
# Initialize the superclass (ChatOpenAI) with provided config parameters
16+
def __init__(self, llm_config: dict):
1917
super().__init__(**llm_config)

scrapegraphai/models/openai_itt.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
2-
This module contains the OpenAIImageToText class,
3-
which is a subclass of ChatOpenAI that is specialized for converting images to text.
2+
OpenAIImageToText Module
43
"""
54

65
from langchain_openai import ChatOpenAI
@@ -9,39 +8,27 @@
98

109
class OpenAIImageToText(ChatOpenAI):
1110
"""
12-
A class that uses OpenAI's Chat API to convert an image to text.
11+
A wrapper for the OpenAIImageToText class that provides default configuration
12+
and could be extended with additional methods if needed.
1313
1414
Args:
15-
llm_config (dict): The configuration for the language model.
16-
17-
Attributes:
18-
max_tokens (int): The maximum number of tokens to generate in the response.
19-
20-
Methods:
21-
run(image_url): Runs the image-to-text conversion using the provided image URL.
15+
llm_config (dict): Configuration parameters for the language model.
16+
max_tokens (int): The maximum number of tokens to generate.
2217
2318
"""
2419

2520
def __init__(self, llm_config: dict):
26-
"""
27-
Initializes an instance of the OpenAIImageToText class.
28-
29-
Args:
30-
llm_config (dict): The configuration for the language model.
31-
32-
"""
3321
super().__init__(**llm_config, max_tokens=256)
3422

35-
def run(self, image_url: str):
23+
def run(self, image_url: str) -> str:
3624
"""
3725
Runs the image-to-text conversion using the provided image URL.
3826
3927
Args:
40-
image_url (str): The URL of the image to convert to text.
28+
image_url (str): The URL of the image to convert.
4129
4230
Returns:
43-
str: The generated text description of the image.
44-
31+
str: The text description of the image.
4532
"""
4633
message = HumanMessage(
4734
content=[

scrapegraphai/models/openai_tts.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,39 @@
11
"""
2-
This module contains the OpenAITextToSpeech class, which uses OpenAI's API
3-
to convert text into speech.
2+
OpenAITextToSpeech Module
43
"""
54

65
from openai import OpenAI
76

87

98
class OpenAITextToSpeech:
109
"""
11-
A class that uses OpenAI's API to convert text to speech.
12-
13-
Args:
14-
llm_config (dict): The configuration for the language model.
10+
Implements a text-to-speech model using the OpenAI API.
1511
1612
Attributes:
13+
client (OpenAI): The OpenAI client used to interact with the API.
1714
model (str): The model to use for text-to-speech conversion.
1815
voice (str): The voice model to use for generating speech.
1916
20-
Methods:
21-
run(text): Converts the provided text to speech and returns the
22-
bytes of the generated speech.
17+
Args:
18+
tts_config (dict): Configuration parameters for the text-to-speech model.
2319
"""
2420

2521
def __init__(self, tts_config: dict):
26-
"""
27-
Initializes an instance of the OpenAITextToSpeech class.
28-
29-
Args:
30-
llm_config (dict): The configuration for the language model.
31-
model (str, optional): The model to use for text-to-speech conversion.
32-
Defaults to "tts-1".
33-
voice (str, optional): The voice model to use for generating speech.
34-
Defaults to "alloy".
35-
"""
3622

3723
# convert model_name to model
3824
self.client = OpenAI(api_key=tts_config.get("api_key"))
3925
self.model = tts_config.get("model", "tts-1")
4026
self.voice = tts_config.get("voice", "alloy")
4127

42-
def run(self, text):
28+
def run(self, text: str) -> bytes:
4329
"""
4430
Converts the provided text to speech and returns the bytes of the generated speech.
4531
4632
Args:
4733
text (str): The text to convert to speech.
4834
35+
Returns:
36+
bytes: The bytes of the generated speech audio.
4937
"""
5038
response = self.client.audio.speech.create(
5139
model=self.model,

0 commit comments

Comments
 (0)