Add a Docstring to your code
This is useful if you need to automatically generate documentation strings for code.
Prompt
Output
PYTHON
API Request
PYTHON
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
1 def add(a: int, b: int) -> int: 2 """ 3 This function takes two integers 'a' and 'b' and returns their sum. 4 5 Parameters: 6 a (int): The first integer. 7 b (int): The second integer. 8 9 Returns: 10 int: The sum of 'a' and 'b'. 11 """ 12 return a + b
API Request
1 import cohere 2 3 co = cohere.ClientV2(api_key="<YOUR API KEY>") 4 5 response = co.chat( 6 model="command-r-plus-08-2024", 7 messages=[{"role": "user", "content": """ 8 You are a Python expert. For the given Python function, add mypy typing and a docstring. Return the Python function only. 9 ```py 10 def add(a,b): 11 return a + b 12 ``` 13 """}] 14 ) 15 16 print(response.message.content[0].text)