cyber_query_ai.server

Server for the CyberQueryAI application.

Classes

CyberQueryAIServer([config])

AI chatbot server application inheriting from TemplateServer.

class cyber_query_ai.server.CyberQueryAIServer(config=None)[source]

AI chatbot server application inheriting from TemplateServer.

__init__(config=None)[source]

Initialise the CyberQueryAIServer by delegating to the template server.

Parameters:

config (CyberQueryAIConfig | None) – CyberQueryAI server configuration

static parse_response(response_str)[source]

Parse the LLM response string into a dictionary.

Parameters:

response_str (str) – LLM response string

Return dict:

Parsed response dictionary

Raises:

json.JSONDecodeError – If the response cannot be parsed as JSON

Return type:

dict

static validate_keys(required_keys, response_dict)[source]

Validate that all required keys are present in the response dictionary.

Parameters:
  • required_keys (set[str]) – Set of required keys

  • response_dict (dict) – Response dictionary to validate

Raises:

KeyError – If any required keys are missing

Return type:

None

validate_config(config_data)[source]

Validate and parse the configuration data into a CyberQueryAIConfig.

Parameters:

config_data (dict) – Raw configuration data

Return CyberQueryAIConfig:

Validated CyberQueryAI server configuration

Return type:

CyberQueryAIConfig

setup_routes()[source]

Set up API routes.

Return type:

None

async get_api_config(request)[source]

Get the API configuration including model configuration and version.

Return type:

GetApiConfigResponse

async post_chat(request)[source]

Chat with the AI assistant using conversation history.

Return type:

PostChatResponse

async post_generate_code(request)[source]

Generate cybersecurity code based on user prompt.

Return type:

PostCodeGenerationResponse

async post_explain_code(request)[source]

Explain code step-by-step.

Return type:

PostCodeExplanationResponse

Search for known exploits based on target description.

Return type:

PostExploitSearchResponse