File size: 1,723 Bytes
5dbfb3f
 
0f04201
5dbfb3f
 
60ee11d
5dbfb3f
0f04201
fea02f6
962f893
5dbfb3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f04201
 
5dbfb3f
 
 
 
 
 
 
 
0f04201
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from datetime import datetime
import inspect
from langchain.tools import StructuredTool

from .common import execute_function_call, extract_func_args, vehicle as vehicle_obj
from .weather import get_weather_current_location, get_weather, get_forecast
from .routing import find_route
from .poi import search_points_of_interest, search_along_route_w_coordinates
from .vehicle import vehicle_status, set_vehicle_speed, set_vehicle_destination
from .interpreter import code_interpreter



def date_time_info():
    """Get the current date and time."""
    time = getattr(vehicle_obj, "time")
    date = getattr(vehicle_obj, "date")
    datetime_obj = datetime.fromisoformat(f"{date}T{time}")
    human_readable_datetime = datetime_obj.strftime("%I:%M %p %A, %B %d, %Y")
    return f"It is {human_readable_datetime}."


def do_anything_else():
    """If the user wants to do anything else call this function. If the question doesn't match any of the functions use this one."""
    return True


def format_functions_for_prompt_raven(*functions):
    """Format functions for use in Prompt Raven.
    
    Args:
    *functions (function): One or more functions to format.
    """
    formatted_functions = []
    for func in functions:
        if isinstance(func, StructuredTool):
            func = func.func
        signature = f"{func.__name__}{inspect.signature(func)}"
        docstring = inspect.getdoc(func)
        formatted_functions.append(
            f"Function:\n<func_start>{signature}<func_end>\n<docstring_start>\n{docstring}\n<docstring_end>"
        )
    return "\n".join(formatted_functions)


SKILLS_PROMPT = format_functions_for_prompt_raven(get_weather, get_forecast, find_route, search_points_of_interest)