Add a Docstring to your code
This is useful if you need to automatically generate documentation strings for code.
Prompt
You are a Python expert. For the given Python function, add mypy typing and a docstring.
Return the Python function only.
```py
def add(a,b):
return a + b
```
Output
def add(a: int, b: int) -> int:
"""
This function takes two integers 'a' and 'b' and returns their sum.
Parameters:
a (int): The first integer.
b (int): The second integer.
Returns:
int: The sum of 'a' and 'b'.
"""
return a + b
API Request
import cohere
co = cohere.Client('<<apiKey>>')
response = co.chat(
message="""You are a Python expert. For the given Python function, add mypy typing and a docstring. Return the Python function only.
```py
def add(a,b):
return a + b
```
""",
)
print(response)
Updated about 1 month ago