Skip to content

Instantly share code, notes, and snippets.

@wooparadog
Created February 7, 2024 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wooparadog/d0d7e0aae481fef54c0620bef9bf9a15 to your computer and use it in GitHub Desktop.
Save wooparadog/d0d7e0aae481fef54c0620bef9bf9a15 to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File "/home/wooparadog/Codes/github.com/orion-arm-ai/orion/.venv/lib/python3.11/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wooparadog/Codes/github.com/orion-arm-ai/orion/modelbesttest.py", line 57, in <module>
response = response.json()
^^^^^^^^^^^^^^^
File "/home/wooparadog/Codes/github.com/orion-arm-ai/orion/.venv/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
import requests
if __name__ == "__main__":
url = "https://openapi.ali.modelbest.cn/openapi/v1/funcCall/chat/completions"
headers = {
"host": "openapi.ali.modelbest.cn",
"accept-encoding": "gzip, deflate, br",
"connection": "keep-alive",
"accept": "application/json",
"user-agent": "OpenAI/Python 1.9.0",
"x-stainless-lang": "python",
"x-stainless-package-version": "1.9.0",
"x-stainless-os": "MacOS",
"x-stainless-arch": "arm64",
"x-stainless-runtime": "CPython",
"x-stainless-runtime-version": "3.10.9",
"x-model-best-open-app-id": "ff332612-6da6-414d-9591-1ef4b1a1e888",
"x-stainless-async": "false",
}
json_data = {
"messages": [
{"role": "user", "content": "hello, What is the weather like in beijing?"}
],
"model": "func-call-8b-32k-zhouge",
"temperature": 0.7,
"tool_choice": None,
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
},
"required": ["location", "format"],
},
},
}
],
}
response = requests.post(url=url, headers=headers, json=json_data, timeout=300)
print(response.content)
response = response.json()
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment