-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an openai with function calls example #110
Conversation
Looking to be great! Maybe @sophiamyang can write a blog post about this too :) |
This is ready for review. One day someone with more time might
|
All the |
I refreshed the key. Seems like it doesn't recognize the actions env key.
|
Trying to fix it here. #112 |
I will review this in detail tomorrow. |
Try adding a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing this; I think if things were moved around, it would improve understandability. Also potentially use serialize
if possible.
The JSON schema reminds me of the time when I experimented with hvplot using marvin + pydantic; might be another useful example!
from marvin import ai_model
from collections import Mapping
from pydantic import BaseModel, Field
from typing import List, Union, Tuple, Dict, Any
@ai_model
class HoloViewsConfig(BaseModel, Mapping):
class Config:
arbitrary_types_allowed = True
cnorm: str = Field(
"linear",
description="Color scaling which must be one of 'linear', 'log' or 'eq_hist'",
)
colorbar: bool = Field(False, description="Enables a colorbar")
fontscale: float = Field(
1.0, description="Scales the size of all fonts by the same amount"
)
fontsize: Union[float, Dict[str, Union[str, int]]] = Field(
12.0, description="Set title, label and legend text to the same fontsize."
)
flip_xaxis: bool = Field(
False, description="Whether to flip the axis left to right"
)
flip_yaxis: bool = Field(False, description="Whether to flip the axis up and down")
grid: bool = Field(False, description="Whether to show a grid")
hover: bool = Field(True, description="Whether to show hover tooltips")
hover_cols: List[Union[str, List[str]]] = Field(
[], description="Additional columns to add to the hover tool"
)
invert: bool = Field(False, description="Swaps x- and y-axis")
frame_width: int = Field(800, description="The width of the data area of the plot")
frame_height: int = Field(
600, description="The height of the data area of the plot"
)
logx: bool = Field(False, description="Enables logarithmic x-axis")
logy: bool = Field(False, description="Enables logarithmic y-axis")
logz: bool = Field(False, description="Enables logarithmic colormapping")
loglog: bool = Field(False, description="Enables logarithmic x- and y-axis")
max_width: int = Field(
800, description="The maximum width of the plot for responsive modes"
)
max_height: int = Field(
600, description="The maximum height of the plot for responsive modes"
)
min_width: int = Field(
300, description="The minimum width of the plot for responsive modes"
)
min_height: int = Field(
300, description="The minimum height of the plot for responsive modes"
)
rescale_discrete_levels: bool = Field(
True,
description="If cnorm='eq_hist' and there are only a few discrete values, then rescale_discrete_levels=True",
)
responsive: bool = Field(
False,
description="Whether the plot should responsively resize depending on the size of the browser",
)
rot: float = Field(
0.0,
description="Rotates the axis ticks along the x-axis by the specified number of degrees",
)
shared_axes: bool = Field(True, description="Whether to link axes between plots")
transforms: Dict[str, Any] = Field(
default_factory=dict,
description="A dictionary of HoloViews dim transforms to apply before plotting",
)
title: str = Field("", description="Title for the plot")
tools: List[Union[str, BaseModel]] = Field(
default_factory=list, description="List of tool instances or strings"
)
xaxis: Union[str, None] = Field(True, description="Whether to show the x-axis")
yaxis: Union[str, None] = Field(True, description="Whether to show the y-axis")
xformatter: Union[str, BaseModel, None] = Field(
None, description="Formatter for the x-axis"
)
yformatter: Union[str, BaseModel, None] = Field(
None, description="Formatter for the y-axis"
)
xlabel: Union[str, None] = Field(None, description="Axis labels for the x-axis")
ylabel: Union[str, None] = Field(None, description="Axis labels for the y-axis")
clabel: Union[str, None] = Field(None, description="Axis label for the colorbar")
xlim: Union[Tuple, List[float], None] = Field(
None, description="Plot limits of the x-axis"
)
ylim: Union[Tuple, List[float], None] = Field(
None, description="Plot limits of the y-axis"
)
xticks: Union[int, List[Union[int, Tuple]], None] = Field(
None, description="Ticks along x-axis"
)
yticks: Union[int, List[Union[int, Tuple]], None] = Field(
None, description="Ticks along y-axis"
)
width: int = Field(700, description="The width of the plot in pixels")
height: int = Field(300, description="The height of the plot in pixels")
attr_labels: Union[bool, None] = Field(
None, description="Whether to use an xarray object's attributes as labels"
)
check_symmetric_max: int = Field(
1000000,
description="Size above which to stop checking for symmetry by default on the data",
)
x: str = Field(..., description="The 'x' parameter")
y: str = Field(..., description="The 'y' parameter")
kind: Union[str, None] = Field(None, description="The 'kind' parameter")
by: Union[str, None] = Field(None, description="The 'by' parameter")
group_label: Union[str, None] = Field(
None, description="The 'group_label' parameter"
)
value_label: str = Field("value", description="The 'value_label' parameter")
backlog: int = Field(1000, description="The 'backlog' parameter")
crs: Union[str, None] = Field(None, description="The 'crs' parameter")
fields: Dict[str, Any] = Field(
default_factory=dict, description="The 'fields' parameter"
)
groupby: Union[str, None] = Field(None, description="The 'groupby' parameter")
dynamic: bool = Field(True, description="The 'dynamic' parameter")
grid: Union[bool, None] = Field(None, description="The 'grid' parameter")
legend: Union[bool, str, None] = Field(None, description="The 'legend' parameter")
def __iter__(self):
return self.dict().items()
def __getitem__(self, x):
return self.__dict__[x]
def __iter__(self):
return iter(self.dict())
def __len__(self):
return len(self.dict())
import pandas as pd
import hvplot.pandas
# pandas dataframe
df = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv")
df.hvplot(**HoloViewsConfig("scatter plot of bill_length_mm vs bill_depth_mm; groupby species, grid, larger font size"))
…xamples into enhancement/add-openai-with-tools
Okay looks good to me! |
This adds an openai with function calls example.
I've based it on hvPlot. A lot could be invested in polishing the
tool_hvplot.json
file such that most of hvplots api would be available.Bugs and Feature Requests identified
When the bugs below are fixed or features implemented it would be possible to make this even more awesome.
pn.template.FastListTemplate(theme=...)
.ohlc
plot needs some styling to be visible in dark mode.currentColor
. Thus they are always colored black and hard to see in dark theme.Assets