Skip to content

api接收的数据与chat2db发送的不一致 #7

Open
@clyhs

Description

@clyhs

chat2db发送的格式为:
,{"messages":[{"role":"user","content":"### Please follow the below table properties and SQL inputConvert natural language into SQL queries. \n#\n### MYSQL SQL tables, with their properties:\n#\n# ["CREATE TABLE user ) ENGINE=InnoDB AUTO_INCREMENT=11075 DEFAULT CHARSET=utf8"]\n#\n#\n### SQL input: username"}],"stream":true,"model":"sqlcoder-7b"}

而项目的解析
json_post_raw = await request.json()
print(json_post_raw)
json_post = json.dumps(json_post_raw)
json_post_list = json.loads(json_post)
question = json_post_list.get('prompt')
prompt = prompt_template.format(
user_question=question.replace("#","")
)
取prompt怎么能取到?
报错如下:
File "/root/miniconda3/envs/chat2dbsqlcoder/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/home/tiancom/chat2db-sqlcoder-deploy/api.py", line 33, in create_item
user_question=question.replace("#","")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions