From 1641e38d26c76a2fc6db3d4e67c56e4b90aec903 Mon Sep 17 00:00:00 2001 From: ksg Date: Sat, 25 Jan 2025 16:50:21 +0900 Subject: [PATCH] Improve the Ollama analyzer for validating responses. Signed-off-by: ksg --- src/analyzer/analyzers/llm_analyzers/ollama.cr | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/analyzer/analyzers/llm_analyzers/ollama.cr b/src/analyzer/analyzers/llm_analyzers/ollama.cr index 2cb3be05..135edd54 100644 --- a/src/analyzer/analyzers/llm_analyzers/ollama.cr +++ b/src/analyzer/analyzers/llm_analyzers/ollama.cr @@ -28,16 +28,13 @@ module Analyzer::AI filter_prompt = <<-PROMPT Analyze the following list of file paths and identify which files are likely to represent endpoints, including API endpoints, web pages, or static resources. - If no files are found, return: - {"files": []} - Guidelines: - Focus only on individual files. - Do not include directories. - Do not include explanations, comments or additional text. Input Files: - #{all_paths.map { |path| File.expand_path(path) }.join("\n")} + #{all_paths.map { |path| "- #{File.expand_path(path)}" }.join("\n")} PROMPT format = <<-FORMAT @@ -82,9 +79,6 @@ module Analyzer::AI prompt = <<-PROMPT Analyze the provided source code to extract details about the endpoints and their parameters. - If no endpoints are found, return: - {"endpoints": []} - Guidelines: - The "method" field should strictly use one of these values: "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD". - The "param_type" must strictly use one of these values: "query", "json", "form", "header", "cookie" and "path". @@ -131,7 +125,8 @@ module Analyzer::AI "required": ["url", "method", "params"] } } - } + }, + "required": ["endpoints"] } FORMAT