mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
code quality improvements
This commit is contained in:
@@ -20,13 +20,6 @@ class ExampleAPIException(Exception):
|
||||
self.status_code = status_code
|
||||
|
||||
|
||||
def _get_headers(credentials: APIKeyCredentials) -> dict[str, str]:
|
||||
return {
|
||||
"Authorization": credentials.api_key.get_secret_value(),
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
class ExampleClient:
|
||||
"""Client for the Example API"""
|
||||
|
||||
@@ -52,7 +45,8 @@ class ExampleClient:
|
||||
raise_for_status=False,
|
||||
)
|
||||
|
||||
def _handle_response(self, response) -> Any:
|
||||
@staticmethod
|
||||
def _handle_response(response) -> Any:
|
||||
"""
|
||||
Handles API response and checks for errors.
|
||||
|
||||
|
||||
@@ -99,20 +99,20 @@ class ExampleBlock(Block):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def my_static_method(input: str) -> str:
|
||||
logger.info("my_static_method called with input: %s", input)
|
||||
return f"Hello, {input}!"
|
||||
def my_static_method(post_greeting: str) -> str:
|
||||
logger.info("my_static_method called with input: %s", post_greeting)
|
||||
return f"Hello, {post_greeting}!"
|
||||
|
||||
def my_function_that_can_be_mocked(
|
||||
self, input: str, credentials: APIKeyCredentials
|
||||
self, name: str, credentials: APIKeyCredentials
|
||||
) -> str:
|
||||
logger.info("my_function_that_can_be_mocked called with input: %s", input)
|
||||
logger.info("my_function_that_can_be_mocked called with input: %s", name)
|
||||
|
||||
# Use the ExampleClient from _api.py to make an API call
|
||||
client = ExampleClient(credentials=credentials)
|
||||
|
||||
# Create a sample resource using the client
|
||||
resource_data = {"name": input, "type": "greeting"}
|
||||
resource_data = {"name": name, "type": "greeting"}
|
||||
response = client.create_resource(resource_data)
|
||||
return f"API response: {response.get('message', 'Hello, world!')}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user