-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor alignment command into separate module
The alignment command was previously defined in the cli.py file. This commit moves the alignment command into its own module, alignment.py, improving the organization of the codebase. The alignment command is now imported in the cli.py and commands/__init__.py files. This change enhances the modularity of the code, making it easier to maintain and extend in the future.
- Loading branch information
1 parent
f9c5966
commit 42055d1
Showing
3 changed files
with
43 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from .alignment import alignment | ||
from .configure import configure | ||
from .debug import debug | ||
from .learn import learn | ||
from .sidekick import sidekick, sidekick_agent | ||
|
||
__all__ = ["configure", "debug", "learn", "sidekick", "sidekick_agent"] | ||
__all__ = ["alignment", "configure", "debug", "learn", "sidekick", "sidekick_agent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from aicodebot.coder import CREATIVE_TEMPERATURE, Coder | ||
from aicodebot.helpers import logger | ||
from aicodebot.output import OurMarkdown, RichLiveCallbackHandler, get_console | ||
from aicodebot.prompts import get_prompt | ||
from langchain.chains import LLMChain | ||
from rich.live import Live | ||
import click | ||
|
||
|
||
@click.command() | ||
@click.option("-t", "--response-token-size", type=int, default=350) | ||
@click.option("-v", "--verbose", count=True) | ||
def alignment(response_token_size, verbose): | ||
"""A message from AICodeBot about AI Alignment ❤ + 🤖.""" | ||
console = get_console() | ||
|
||
# Load the prompt | ||
prompt = get_prompt("alignment") | ||
logger.trace(f"Prompt: {prompt}") | ||
|
||
# Set up the language model | ||
model_name = Coder.get_llm_model_name(Coder.get_token_length(prompt.template) + response_token_size) | ||
|
||
with Live(OurMarkdown(""), auto_refresh=True) as live: | ||
llm = Coder.get_llm( | ||
model_name, | ||
verbose, | ||
response_token_size, | ||
temperature=CREATIVE_TEMPERATURE, | ||
streaming=True, | ||
callbacks=[RichLiveCallbackHandler(live, console.bot_style)], | ||
) | ||
|
||
# Set up the chain | ||
chain = LLMChain(llm=llm, prompt=prompt, verbose=verbose) | ||
|
||
chain.run({}) |