Skip to content
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

Adding Literal Enum support. #2

Merged
merged 2 commits into from Sep 30, 2023
Merged

Adding Literal Enum support. #2

merged 2 commits into from Sep 30, 2023

Conversation

nova-land
Copy link
Contributor

@nova-land nova-land commented Sep 30, 2023

Adding Enum support with the following format:

enum EnumName { ChoiceA, ChoiceB, ChoiceC }

So we can have the following interface:

enum Tool { WebSearch, Wikipedia, Calculator, FileRead, FileWrite }

interface ReAct {
  select: Tool;
  reason: string;
}

With the following output

root ::= ReAct
ReAct ::= "{"   ws   "\"select\":"   ws   enumTool   ","   ws   "\"reason\":"   ws   string   "}"
ReActlist ::= "[]" | "["   ws   ReAct   (","   ws   ReAct)*   "]"
string ::= "\""   ([^"]*)   "\""
boolean ::= "true" | "false"
ws ::= [ \t\n]*
number ::= [0-9]+   "."?   [0-9]*
stringlist ::= "["   ws   "]" | "["   ws   string   (","   ws   string)*   ws   "]"
numberlist ::= "["   ws   "]" | "["   ws   string   (","   ws   number)*   ws   "]"
enumTool ::= "\"" "WebSearch" "\"" | "\"" "Wikipedia" "\"" | "\"" "Calculator" "\"" | "\"" "FileRead" "\"" | "\"" "FileWrite" "\""

The additional code provides the default Grammar Register with original grammar elements and then adds dynamic Enum Grammar Elements based on the source file.

Also, separate some helper functions into util.py.

Copy link
Contributor

@a10y a10y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Really appreciate you putting in the effort here to clean things up and add tests as well!

I have a few small tweaks but I'll make them after merge :)

@a10y a10y merged commit 8ad1e8d into IntrinsicLabsAI:main Sep 30, 2023
a10y added a commit that referenced this pull request Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants