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

CIRCLE-40469: debug issues with LastMile AI tutorial #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

LOGGER = get_logger()


async def main(argv: list[str]) -> int:
try:
user_query = argv[1]
Expand Down
2 changes: 1 addition & 1 deletion book_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def call_function(name: str, args: str) -> Book | None | list[Book]:
case "search":
return search(args_dict["name"])
case "get":
return get(args_dict["book"])
return get(args_dict["id"])
case _:
raise ValueError(f"Unknown function: {name}")
45 changes: 25 additions & 20 deletions book_db_function_calling.aiconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "Book Finder",
"description": "Use OpenAI function calling to help recommend books",
"schema_version": "latest",
"metadata": {},
"metadata": {
"parameters": {},
"models": {}
},
"description": "Use OpenAI function calling to help recommend books",
"prompts": [
{
"name": "user_query_to_function_call",
Expand All @@ -11,61 +14,62 @@
"model": {
"name": "gpt-3.5-turbo",
"settings": {
"model": "gpt-3.5-turbo",
"functions": [
{
"name": "list",
"description": "list queries books by genre, and returns a list of names of books",
"name": "list",
"parameters": {
"type": "object",
"properties": {
"genre": {
"type": "string",
"enum": [
"mystery",
"nonfiction",
"memoir",
"romance",
"historical"
]
],
"type": "string"
}
}
},
"type": "object"
}
},
{
"description": "search queries books by their name and returns a list of book names and their ids",
"name": "search",
"description": "search queries books and returns a list",
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"type": "object"
}
},
{
"description": "get returns a book's detailed information based on the id of the book. Note that this does not accept names, and only IDs, which you can get by using search.",
"name": "get",
"description": "get returns a book's detailed information for a book.",
"parameters": {
"type": "object",
"properties": {
"book": {
"id": {
"type": "string"
}
}
},
"type": "object"
}
}
],
"model": "gpt-3.5-turbo",
"system_prompt": {
"role": "system",
"content": "Please use our book database, which you can access using functions to answer the following questions."
"content": "Please use our book database, which you can access using functions to answer the following questions.",
"role": "system"
}
}
},
"parameters": {},
"remember_chat_context": false
}
},
"outputs": []
},
{
"name": "function_output_to_text_response",
Expand All @@ -80,8 +84,9 @@
},
"parameters": {},
"remember_chat_context": false
}
},
"outputs": []
}
],
"$schema": "https://json.schemastore.org/aiconfig-1.0"
}
}
2 changes: 1 addition & 1 deletion test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def test_function_accuracy():
(
{"user_query": "ID isbn123"},
#
{"arguments": '{\n "book": "isbn123"\n}', "name": "get"},
{"arguments": '{\n "id": "isbn123"\n}', "name": "get"},
),
(
{"user_query": "To kill a mockingbird"},
Expand Down