Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
feat: re-enable Exa search
Browse files Browse the repository at this point in the history
docs: add information regarding what models to use in `.env.example`

From my testing, Mistral was the best at telling me the current Android + iOS versions. It actually used DuckDuckGo. However, it was still slightly off for Android. Might have been better to only provide Exa instead. In the future, it may be beneficial to add an argument that disables DuckDuckGo or just disable DuckDuckGo if Exa is being used.
  • Loading branch information
slashtechno committed Jun 3, 2024
1 parent d4d63aa commit 4517bbe
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ LLM_BASE_URL="https://openrouter.ai/api/v1"
# The model to use
# For openrouter.ai, you can check the available models at https://openrouter.ai/docs#models
# For Ollama, you can check the available models at https://ollama.com/library
# So far, for the function-calling models I've tested, `mistral:7b-instruct-v0.3-q6_K` works the best (show_tool_calls disabled)
# I use this as a reference for the quantization methods: https://github.com/ggerganov/llama.cpp/discussions/2094#discussioncomment-6351796
LLM_MODEL = "mistralai/mistral-7b-instruct:free"

SHOW_TOOL_CALLS = false
# Settings for Gmail
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
Expand Down
56 changes: 36 additions & 20 deletions llmail/utils/cli_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@ def set_argparse():
# Subcommand: list-folders
_ = subparsers.add_parser("list-folders", help="List all folders in the IMAP account and exit")
# General arguments
argparser.add_argument(
"--log-level",
"-l",
help="Log level",
default=os.getenv("LOG_LEVEL") if os.getenv("LOG_LEVEL") else "INFO",
)
argparser.add_argument(
"--redact-email-addresses",
help="Replace email addresses with '[redacted]' in logs",
action="store_true",
default=(
True
if (
os.getenv("REDACT_EMAIL_ADDRESSES")
and os.getenv("REDACT_EMAIL_ADDRESSES").lower() == "true"
and os.getenv("REDACT_EMAIL_ADDRESSES").lower() != "false"
)
else False
),
)
argparser.add_argument(
"--exa-api-key",
help="Exa API key",
Expand Down Expand Up @@ -168,6 +148,42 @@ def set_argparse():
default=(os.getenv("MESSAGE_ID_DOMAIN") if os.getenv("MESSAGE_ID_DOMAIN") else None),
)

# Debuggiongm arguments
debug = argparser.add_argument_group("Debugging")
debug.add_argument(
"--log-level",
"-l",
help="Log level",
default=os.getenv("LOG_LEVEL") if os.getenv("LOG_LEVEL") else "INFO",
)
debug.add_argument(
"--redact-email-addresses",
help="Replace email addresses with '[redacted]' in logs",
action="store_true",
default=(
True
if (
os.getenv("REDACT_EMAIL_ADDRESSES")
and os.getenv("REDACT_EMAIL_ADDRESSES").lower() == "true"
and os.getenv("REDACT_EMAIL_ADDRESSES").lower() != "false"
)
else False
),
)
debug.add_argument(
"--show-tool-calls",
help="Pass show_tool_calls=True to phidata",
action="store_true",
default=(
True
if (
os.getenv("SHOW_TOOL_CALLS")
and os.getenv("SHOW_TOOL_CALLS").lower() == "true"
and os.getenv("SHOW_TOOL_CALLS").lower() != "false"
)
else False
),
)
check_required_args(
[
"imap_host",
Expand Down
19 changes: 15 additions & 4 deletions llmail/utils/responding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from phi.llm.ollama import Ollama
from phi.tools.exa import ExaTools
from phi.tools.website import WebsiteTools

import ollama

# Uses utils/__init__.py to import from utils/logging.py and utils/cli_args.py respectively
from llmail.utils import logger, args, bot_email
Expand Down Expand Up @@ -166,8 +166,8 @@ def fetch_and_process_emails(
WebsiteTools(),
DuckDuckGo(search=True, news=True)
]
# if args.exa_api_key is not None:
# tools.append(ExaTools(api_key=args.exa_api_key, use_autoprompt=True, highlights=True))
if args.exa_api_key is not None:
tools.append(ExaTools(api_key=args.exa_api_key, highlights=True))
if args.no_tools:
tools = []
# Chose how to send the request to the provider
Expand All @@ -179,20 +179,31 @@ def fetch_and_process_emails(
base_url=args.llm_base_url,
)
case "ollama":
ollama_client = ollama.Client(host=args.llm_base_url)
for model in ollama_client.list()["models"]:
if model["name"] == args.llm_model:
logger.debug(f"{args.llm_model} is already downloaded")
break
else:
logger.info(f"Downloading {args.llm_model}")
ollama_client.pull(model=args.llm_model)
llm = Ollama(
model=args.llm_model,
host=args.llm_base_url,
)
assistant = Assistant(
llm=llm,
tools=tools,
show_tool_calls=False,
show_tool_calls=args.show_tool_calls,
# additional_messages=[
# {
# "role": "system",
# "content": "Functions generally need arguments. Only provide your final iteration to the user. For example, if you're searching for a website, don't tell the user that you're searching for the website. Just provide the final result. Remember, the user is only going to see the final response, not the steps you took to get there. Only provide the final result. Try to use the most appropriate tool for the task. For example, if the user asks about a website, try searching for it and scraping it too. For URLs, ensure the protocol is included (e.g. https://). Use the functions to ensure that the information is accurate and up-to-date",
# },
# ],
tool_call_limit=10,
debug_mode=False,
prevent_hallucinations=True,
)
send_reply(
thread=tracking.get_thread_history(client, email_thread),
Expand Down

0 comments on commit 4517bbe

Please sign in to comment.