Skip to content

Commit

Permalink
chore: codebase clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
eli64s committed Feb 26, 2024
1 parent 4e2e83b commit 82fd0a2
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 79 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "readmeai"
version = "0.5.062"
version = "0.5.063"
description = "👾 Automated README file generator, powered by large language model APIs."
authors = ["Eli <egsalamie@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion readmeai/config/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Enum classes for the readme-ai CLI."""
"""Enums for the CLI options, used to customize the README file."""

from enum import Enum

Expand Down
22 changes: 11 additions & 11 deletions readmeai/config/settings/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ quick_links = """
## 🔗 Quick Links
> - [📍 Overview](#-overview)
> - [📦 Features](#-features)
> - [🔮 Features](#-features)
> - [📂 Repository Structure](#-repository-structure)
> - [🧩 Modules](#-modules)
> - [🚀 Getting Started](#-getting-started)
> - [⚙️ Install](#️-install)
> - [ Using {repo_name}](#-using-{repo_name})
> - [📦 Install](#️-install)
> - [💻 Using {repo_name}](#-using-{repo_name})
> - [🧪 Tests](#-tests)
> - [🛠 Project Roadmap](#-project-roadmap)
> - [🤝 Contributing](#-contributing)
Expand All @@ -88,12 +88,12 @@ toc = """\
<summary><h4>Table of Contents</h4></summary>
- [📍 Overview](#-overview)
- [📦 Features](#-features)
- [🔮 Features](#-features)
- [📂 Repository Structure](#-repository-structure)
- [🧩 Modules](#-modules)
- [🚀 Getting Started](#-getting-started)
- [⚙️ Install](#️-install)
- [ Using {repo_name}](#-using-{repo_name})
- [📦 Install](#️-install)
- [💻 Using {repo_name}](#-using-{repo_name})
- [🧪 Tests](#-tests)
- [🛠 Project Roadmap](#-project-roadmap)
- [🤝 Contributing](#-contributing)
Expand All @@ -114,7 +114,7 @@ overview = """

# Features Template
features = """
## 📦 Features
## 🔮 Features
{0}
Expand Down Expand Up @@ -145,13 +145,13 @@ quickstart = """
## 🚀 Getting Started
***Requirements***
### ⚙️ Prerequisites
Ensure you have the following dependencies installed on your system:
Ensure you have the following installed on your local machine:
* {prerequisites}
### ⚙️ Install
### 📦 Install
1. Clone the {repo_name} repository:
Expand All @@ -171,7 +171,7 @@ cd {repo_name}
{install_command}
```
### Using `{repo_name}`
### 💻 Using `{repo_name}`
Use the following command to run {repo_name}:
Expand Down
24 changes: 12 additions & 12 deletions readmeai/config/settings/markdown.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ quick_links = """
## 🔗 Quick Links
> - [📍 Overview](#-overview)
> - [📦 Features](#-features)
> - [🔮 Features](#-features)
> - [📂 Repository Structure](#-repository-structure)
> - [🧩 Modules](#-modules)
> - [🚀 Getting Started](#-getting-started)
> - [⚙️ Install](#️-install)
> - [ Using {repo_name}](#-using-{repo_name})
> - [📦 Install](#️-install)
> - [💻 Using {repo_name}](#-using-{repo_name})
> - [🧪 Tests](#-tests)
> - [🛠 Project Roadmap](#-project-roadmap)
> - [🤝 Contributing](#-contributing)
Expand All @@ -61,12 +61,12 @@ toc = """\
<summary><h4>Table of Contents</h4></summary>
- [📍 Overview](#-overview)
- [📦 Features](#-features)
- [🔮 Features](#-features)
- [📂 Repository Structure](#-repository-structure)
- [🧩 Modules](#-modules)
- [🚀 Getting Started](#-getting-started)
- [⚙️ Install](#️-install)
- [ Using {repo_name}](#-using-{repo_name})
- [📦 Install](#️-install)
- [💻 Using {repo_name}](#-using-{repo_name})
- [🧪 Tests](#-tests)
- [🛠 Project Roadmap](#-project-roadmap)
- [🤝 Contributing](#-contributing)
Expand All @@ -87,7 +87,7 @@ overview = """

# Features Template
features = """
## 📦 Features
## 🔮 Features
{0}
Expand Down Expand Up @@ -118,13 +118,13 @@ quickstart = """
## 🚀 Getting Started
***Requirements***
### ⚙️ Prerequisites
Ensure you have the following dependencies installed on your system:
Ensure you have the following installed on your local machine:
* {prerequisites}
### ⚙️ Install
### 📦 Install
1. Clone the {repo_name} repository:
Expand All @@ -144,7 +144,7 @@ cd {repo_name}
{install_command}
```
### Using `{repo_name}`
### 💻 Using `{repo_name}`
Use the following command to run {repo_name}:
Expand Down Expand Up @@ -209,7 +209,7 @@ Contributions are welcome! Here are several ways you can contribute:
<details closed>
<summary>Contributor Graph</summary>
<br>
<p align="left">
<p align="center">
<a href="https://{host_domain}{{/{full_name}/}}graphs/contributors">
<img src="https://contrib.rocks/image?repo={full_name}">
</a>
Expand Down
2 changes: 1 addition & 1 deletion readmeai/config/settings/prompts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ File path: {1}
File contents: {2}
================================================================================
Additionally, avoid using words like `This file`, `This code`, etc. in your response. \
Use concise language and ensure the summary response is no more than 50 tokens.
Use concise language and ensure the summary response is no more than 60 tokens.
"""

overview = """Analyze the codebase named {0} ({1}) and provide a robust, yet succinct overview of the project. \
Expand Down
5 changes: 1 addition & 4 deletions readmeai/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def batch_request(
additional_responses = await self._batch_prompts(additional_prompts)

synthesize_features_table_prompt = await set_feature_context(
additional_responses[0],
additional_responses[0]
)
synthesize_features_table_response = await self._batch_prompts(
synthesize_features_table_prompt
Expand Down Expand Up @@ -259,13 +259,10 @@ async def _handle_response_code_summary(
prompt = self.prompts["prompts"]["file_summary"].format(
self.config.md.tree, file_path, file_content
)

tokens = update_max_tokens(self.tokens, prompt)

_, summary_or_error = await self._handle_response(
file_path, prompt, tokens
)

summary_text.append((file_path, summary_or_error))

return summary_text
Expand Down
10 changes: 5 additions & 5 deletions readmeai/core/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from readmeai.parsers.factory import parser_handler
from readmeai.utils.logger import Logger

GITHUB_ACTIONS_PATH = ".github/workflows"
_github_actions_path = ".github/workflows"


@dataclass
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_dependencies(self, contents: List[FileContext]) -> List[str]:
file_data.file_name
] = file_data.dependencies

if GITHUB_ACTIONS_PATH in str(file_data.file_path):
if _github_actions_path in str(file_data.file_path):
dependencies.add("github actions")

return list(dependencies), dependency_dict
Expand Down Expand Up @@ -143,7 +143,7 @@ def _process_file_path(
Processes an individual file path and returns FileContext.
"""
relative_path = file_path.relative_to(repo_path)
if GITHUB_ACTIONS_PATH in str(relative_path):
if _github_actions_path in str(relative_path):
return FileContext(
file_path=relative_path,
file_name="github actions",
Expand Down Expand Up @@ -205,8 +205,8 @@ def preprocessor(
config = config_loader.config
repo_processor = RepositoryProcessor(config_loader)
repo_context = repo_processor.generate_contents(temp_dir)
# repo_context = repo_processor.tokenize_content(repo_context)
repo_context = repo_processor.language_mapper(repo_context)
# repo_context = repo_processor.tokenize_content(repo_context)

dependencies, dependency_dict = repo_processor.get_dependencies(
repo_context
Expand All @@ -220,4 +220,4 @@ def preprocessor(
config_loader, dependencies, raw_files, temp_dir
).md_tree

return dependencies, raw_files, dependency_dict
return dependencies, raw_files
19 changes: 8 additions & 11 deletions readmeai/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ def set_model_engine(config: Settings) -> None:
config.llm.model = config.llm.model
config.llm.offline = False
_logger.info("Running CLI with OpenAI API llm engine...")
return config

elif vertex_env:
config.llm.api = ModelOptions.VERTEX.name
config.llm.model = "gemini-pro"
config.llm.offline = False
_logger.info("Running CLI with Google Vertex AI llm engine...")
return config

elif config.llm.api == ModelOptions.OLLAMA.name:
config.llm.model = "ollama"
config.llm.offline = False
_logger.info("Running CLI with Ollama llm engine...")
return config

else:
if config.llm.api == ModelOptions.OFFLINE.name:
message = "Offline mode enabled by user via CLI."
else:
message = (
"\n\n\t\t...No LLM API settings exist in environment..."
)
return _set_offline(config, message)
_set_offline(config, message)

elif llm_engine is not None:
_logger.info(f"LLM API CLI input received: {llm_engine}")
Expand All @@ -82,9 +82,9 @@ def set_model_engine(config: Settings) -> None:
config.llm.model = config.llm.model
config.llm.offline = False
_logger.info("OpenAI settings found in environment!")
return config

else:
return _set_offline(
_set_offline(
config,
"\n\t\t...OpenAI settings NOT FOUND in environment...",
)
Expand All @@ -94,7 +94,6 @@ def set_model_engine(config: Settings) -> None:
config.llm.model = "ollama"
config.llm.offline = False
_logger.info("Ollama settings found in environment!")
return config

elif llm_engine == ModelOptions.VERTEX.name:
if (
Expand All @@ -104,10 +103,9 @@ def set_model_engine(config: Settings) -> None:
config.llm.model = "gemini-pro"
config.llm.offline = False
_logger.info("Vertex AI settings found in environment!")
return config

else:
return _set_offline(
_set_offline(
config,
"\n\t\t...Vertex AI settings NOT FOUND in environment...",
)
Expand All @@ -117,7 +115,7 @@ def set_model_engine(config: Settings) -> None:
message = "\n\t\t...Offline mode enabled by user..."
else:
message = "Invalid LLM API service provided!"
return _set_offline(config, message)
_set_offline(config, message)


def _scan_environ(keys: list[str]) -> bool:
Expand All @@ -141,4 +139,3 @@ def _set_offline(config: Settings, log_msg: str) -> Settings:
)
config.llm.api = ModelOptions.OFFLINE.name
config.llm.offline = True
return config
Loading

0 comments on commit 82fd0a2

Please sign in to comment.