Skip to content

Commit

Permalink
allow setting assistant model
Browse files Browse the repository at this point in the history
  • Loading branch information
piEsposito committed Jul 19, 2024
1 parent 6322851 commit 7d8c9c8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
33 changes: 28 additions & 5 deletions pi_ai_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def divide(a: int, b: int) -> int:
the FILES tag must contain the name of the relevant files, one per line, without anything else.
You can only return files that appeared in the context tags, even if they mention other files or directories that were not written there.
If a file does not exist (and the user asks for something that will create it), do not include it in the list of dependencies.
If there are no relevant files, just return the tags without any content.
"""


Expand Down Expand Up @@ -158,10 +159,12 @@ def extract_dependencies(raw_text):


def select_relevant_files_on_chdir(
user_prompt: str, target_dirs: list[str] | None = None
user_prompt: str,
target_dirs: list[str] | None = None,
assistant_model: str = ASSISTANT_MODEL_NAME,
):
assistant = AI(
ASSISTANT_MODEL_NAME,
assistant_model,
system=ASSISTANT_MODEL_SYSTEM_PROMPT,
max_new_tokens=1024,
temperature=0,
Expand Down Expand Up @@ -194,8 +197,16 @@ def extract_code(text: str) -> str:
return match.group(1).strip() if match else None


def pi_ai_os(model: str, initial_message: str, config_file: str, assistant: bool):
def pi_ai_os(
model: str,
initial_message: str,
config_file: str,
assistant: bool,
assistant_model: str,
):
print(f"Welcome to AIOS. Model: {model}\n")
if assistant:
print(f"Assistant model: {assistant_model}")

config_file = config_file or DEFAULT_CONFIG_FILE
if not os.path.exists(config_file):
Expand Down Expand Up @@ -251,7 +262,7 @@ def pi_ai_os(model: str, initial_message: str, config_file: str, assistant: bool

if assistant:
dependencies_context = select_relevant_files_on_chdir(
user_message, target_dirs
user_message, target_dirs, assistant_model
)
user_message = f"{user_message}\n\nYou are also provided following context: {dependencies_context}"

Expand Down Expand Up @@ -309,6 +320,12 @@ def main():
help="Triggers using an assistant model for context gathering",
action="store_true",
)
parser.add_argument(
"-am",
"--assistant-model",
help="Specify the assistant model name",
default=ASSISTANT_MODEL_NAME,
)
parser.add_argument(
"-v",
"--verbose",
Expand All @@ -323,7 +340,13 @@ def main():

initial_message = " ".join(args.message) if args.message else None
try:
pi_ai_os(args.model, initial_message, args.config, args.assistant)
pi_ai_os(
args.model,
initial_message,
args.config,
args.assistant,
args.assistant_model,
)
except KeyboardInterrupt:
print("\nExiting...")
sys.exit(0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pi-ai-os"
version = "0.0.3"
version = "0.0.4"
description = "Integrate your OS with an LLM."
authors = ["piEsposito <piero.skywalker@gmail.com>"]
license = "Apache 2.0"
Expand Down

0 comments on commit 7d8c9c8

Please sign in to comment.