【书生大模型】python基础知识
概要
提示:这里可以添加技术概要
例如:
openAI 的 GPT 大模型的发展历程。
任务一 leecode 383
任务二
利用debug找错误
发现 error
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
debug发现 res的参数:
'```json\n{\n "model_name": "书生浦语InternLM2.5",\n "developer": "上海人工智能实验室",\n "parameter_versions": ["1.8B", "7B", "20B"],\n "max_context_length": "1M"\n}\n```'
chatgpt一下
出现 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 错误的原因是因为 json.loads(res) 尝试解析的字符串 res 包含了多余的非JSON格式的字符。在你提供的例子中,res 字符串包含了额外的反引号(```)和换行符(\n),这些都不是有效的JSON格式的一部分。
所以 添加代码
#移除字符串开头和结尾的 ```和换行符
res = res.strip().replace('```json', '').replace('```', '').strip()
成功啦