diff --git a/app/gemini_analyzer.py b/app/gemini_analyzer.py index aa92679..dabbbc5 100644 --- a/app/gemini_analyzer.py +++ b/app/gemini_analyzer.py @@ -1,6 +1,7 @@ import google.generativeai as genai from typing import List from .gemini_config import AnalyzerConfigs +# for logging import structlog structlog.stdlib.recreate_defaults() @@ -8,6 +9,7 @@ __all__ = ["CodeAnalyzer"] + class CodeAnalyzer: def __init__(self) -> None: self.language: str = "python" @@ -26,7 +28,7 @@ def analyze_code(self, lines: List[str]) -> str: This method analyzes the input lines of code and generates a style guide using the Gemini model. """ try: - prompt = f'''Analyze the following {self.language} code according to {self.style_guide} style guidelines, the array below contains line-wise code: + prompt = f'''Analyze the following {self.language} code according to {self.style_guide} style guidelines: {lines} @@ -40,7 +42,7 @@ def analyze_code(self, lines: List[str]) -> str: Using this JSON schema: response = {{"line": int, "message": str, "severity": str, "start_char": int, "end_char": int}} Return a `list[response]` - ''' + ''' model = self.gemini_model response = model.generate_content(prompt) diff --git a/app/gemini_config.py b/app/gemini_config.py index 1d9fba0..a136322 100644 --- a/app/gemini_config.py +++ b/app/gemini_config.py @@ -1,5 +1,6 @@ import streamlit as st + class AnalyzerConfigs: """ This class contains configuration settings for the CodeAnalyzer class. @@ -25,5 +26,3 @@ class AnalyzerConfigs: "google style": "https://google.github.io/styleguide/pyguide.html", "pep8": "https://pep8.org/", } - - diff --git a/app/response_config.py b/app/response_config.py index 48e18aa..4116223 100644 --- a/app/response_config.py +++ b/app/response_config.py @@ -10,4 +10,4 @@ class ResponseData(TypedDict): message: str severity: str start_char: int - end_char: int \ No newline at end of file + end_char: int diff --git a/streamlit.py b/streamlit.py index afbda03..4e70764 100644 --- a/streamlit.py +++ b/streamlit.py @@ -17,7 +17,9 @@ st.subheader("Style Guide and Suggestions:") # Expanders for items in data: - with st.expander(f"Line `{items['line']}` | Severity: `{items['severity']}`"): + with st.expander( + f"Line `{items['line']}` | Severity: `{items['severity']}`" + ): st.write(items["message"]) # JSON output st.subheader("Raw API response : ")