feat: rename project to "reetor's guide to modern python"
feat: add comprehensive tutorial docs: update readme with installation instructions and quick start guide feat: include information on modern python features and aiohttp refactor: move database get/set/query functions refactor: update autonomous mode response processing refactor: update api call function feat: implement realistic http headers maintenance: update dependencies maintenance: clean up imports and files
This commit is contained in:
+7
-2
@@ -7,7 +7,9 @@ from rp.core.http_client import http_client
|
||||
logger = logging.getLogger("rp")
|
||||
|
||||
|
||||
def call_api(messages, model, api_url, api_key, use_tools, tools_definition, verbose=False, db_conn=None):
|
||||
def call_api(
|
||||
messages, model, api_url, api_key, use_tools, tools_definition, verbose=False, db_conn=None
|
||||
):
|
||||
try:
|
||||
messages = auto_slim_messages(messages, verbose=verbose)
|
||||
logger.debug(f"=== API CALL START ===")
|
||||
@@ -38,11 +40,14 @@ def call_api(messages, model, api_url, api_key, use_tools, tools_definition, ver
|
||||
if db_conn:
|
||||
|
||||
from rp.tools.database import log_api_request
|
||||
|
||||
log_result = log_api_request(model, api_url, request_json, db_conn)
|
||||
if log_result.get("status") != "success":
|
||||
logger.warning(f"Failed to log API request: {log_result.get('error')}")
|
||||
logger.debug("Sending HTTP request...")
|
||||
response = http_client.post(api_url, headers=headers, json_data=request_json, db_conn=db_conn)
|
||||
response = http_client.post(
|
||||
api_url, headers=headers, json_data=request_json, db_conn=db_conn
|
||||
)
|
||||
if response.get("error"):
|
||||
if "status" in response:
|
||||
logger.error(f"API HTTP Error: {response['status']} - {response.get('text', '')}")
|
||||
|
||||
Reference in New Issue
Block a user