I am running below code from: Llama quick start
import json
from llamaapi import LlamaAPI
# Initialize the SDK
llama = LlamaAPI("<your_api_token>")
# Build the API request
api_request_json = {
"model": "llama3.1-70b",
"messages": [
{"role": "user", "content": "What is the weather like in Boston?"},
],
"functions": [
{
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"days": {
"type": "number",
"description": "for how many days ahead you wants the forecast",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
},
"required": ["location", "days"],
}
],
"stream": False,
"function_call": "get_current_weather",
}
# Execute the Request
response = llama.run(api_request_json)
print(json.dumps(response.json(), indent=2))
it return the following error:
Traceback (most recent call last):
File "C:\Users\some_user\OneDrive - Ryder\Projects\Tutorials\Pycharm\AI_tests\llama_api.py", line 39, in <module>
response = llama.run(api_request_json)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\some_user\myenv\Lib\site-packages\llamaapi\llamaapi.py", line 67, in run
return self.run_sync(api_request_json)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\some_user\myenv\Lib\site-packages\llamaapi\llamaapi.py", line 53, in run_sync
raise Exception(f"POST {response.status_code} {response.json()['detail']}")
~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
What is the fix here?