Fail to create project with knext command
Search before asking
- [x] I had searched in the issues and found no similar issues.
Operating system information
Windows
What happened
On version 0.8, while running the command to create the project: knext project restore --host_addr http://172.179.138.222:8887 --proj_path .
it fail with following error:
(kagv2) C:\TestProj\Python\KAGv2\KAG\kag\examples\bas_da_kb>knext project restore --host_addr http://172.179.138.222:8887 --proj_path .
Traceback (most recent call last):
File "\AppData\Roaming\uv\python\cpython-3.10.16-windows-x86_64-none\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "\AppData\Roaming\uv\python\cpython-3.10.16-windows-x86_64-none\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\PythonEnv\kagv2\Scripts\knext.exe_main.py", line 10, in
How to reproduce
Here is the verctor config
vectorize_model: &vectorize_model api_key: **** base_url: https://dowopenaipoceu.openai.azure.com/ model: text-embedding-3-small azure_deployment: text-embedding-3-small api_version: 2024-12-01-preview type: azure_openai vector_dimensions: 1536 enable_check: false vectorizer: *vectorize_model
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
I met the same problem. Is there any solution?
I can confirm I'm experiencing this problem as well. Are there any updates on a potential fix? ubuntu 24
Hello everyone,
I encountered the same HTTP 400 Bad Request error when trying to create a project. The server logs showed a JsonSyntaxException with the message Expected a string but was BEGIN_OBJECT.
I was able to solve this issue. The problem is that the server expects parameters like config, auto_schema, and tag to be sent as a JSON string, not as a raw JSON object.
The Fix:
You need to modify the client-side code to convert these Python dictionaries into JSON strings before sending the API request. Based on my working solution, here is the corrected create function, likely in your client.py file:
``` import json
# Make sure 'rest' is imported, for example:
# from knext_site.rest_client.client import models as rest
# ...
def create(self, name: str, namespace: str, config: str, **kwargs):
if not self._rest_client:
raise Exception("Please set KAG_PROJECT_HOST_ADDR and KAG_PROJECT_ID")
visibility = kwargs.get("visibility", "PRIVATE")
tag_value = kwargs.get("tag", "LOCAL") # Renamed to avoid conflict
auto_schema_value = kwargs.get("auto_schema", False) # Renamed to avoid conflict
desc = kwargs.get("desc", None)
userNo = kwargs.get("userNo", "openspg")
# The core of the fix: Convert dictionaries/values to JSON strings
config_as_string = json.dumps(config)
auto_schema_as_string = json.dumps(auto_schema_value)
tag_as_string = json.dumps(tag_value)
# Create the request object using the stringified values
project_create_request = rest.ProjectCreateRequest(
name=name,
desc=desc,
namespace=namespace,
config=config_as_string, # Use the string version here
auto_schema=auto_schema_as_string, # and here
visibility=visibility,
tag=tag_as_string, # and here
userNo=userNo,
)
project = self._rest_client.project_create_post(
project_create_request=project_create_request
)
return project