jarvis / main.py
megamined's picture
Do not raise errors if `.env` not found
0399d44
from functools import partial
from os import getenv
from pathlib import Path
from dotenv import find_dotenv, load_dotenv
from simpleaichat import AIChat
from utils.google_serper import GoogleSerper
from utils.weather_forecast import WeatherAPI
load_dotenv(find_dotenv())
local_dir = Path(getenv("LOCAL_DIR"))
OPENAI_API_KEY = getenv("OPENAI_API_KEY")
MODEL = "gpt-4"
# MODEL = "gpt-3.5-turbo-16k"
# %%
# This uses the Wikipedia Search API.
# Results from it are nondeterministic, your mileage will vary.
# def search(query):
# """Search the internet."""
# wiki_matches = wikipedia_search(query, n=3)
# return {"context": ", ".join(wiki_matches), "titles": wiki_matches}
# def lookup(query):
# """Lookup more information about a topic."""
# page = wikipedia_search_lookup(query, sentences=3)
# return page
def weather(query):
"""Use this tool to get real-time temperature and weather forecast information"""
w = WeatherAPI()
weather_info = w.run(query)
return weather_info
def search(query):
"""Search the internet."""
g = GoogleSerper()
search_result = g.run(query)
return search_result
if __name__ == "__main__":
params = {"temperature": 0.1, "max_tokens": 200}
system_prompt = (
"You are an assistant that likes to use emoticons. "
"You are also curt and concise with your responses."
)
ai = AIChat(console=False, id="chat_1")
ai.load_session("chat_session_3.json", id="chat_1")
ai.get_session()
# AIChat(character="Morgan Freeman")
tools = [weather, search]
ai("can you summarize the conversation?")
ai.save_session("chat_session_3.json", format="json")
ai_with_tools = partial(ai, tools=tools)
while True:
response = ai_with_tools(input("User: "))
print(response["response"])
# ai.reset_session()
# TODO: play music, create routines for spotify and/or amazon music; play videos on youtube (i know it will just be the audio)
# use faster-whisper instead of the API
# using llama.cpp https://github.com/minimaxir/simpleaichat/pull/52
# checkout swarms: https://github.com/kyegomez/swarms
# improve chat interface: https://www.gradio.app/guides/creating-a-custom-chatbot-with-blocks