I was using an API of a site to get some details in JSON format and then I was trying to pass this data to an LLM server to extract certain details.
def get_study_data():
url = ""
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers, params=query_params)
return response.json()`
study_data = get_study_data()
if "error" in study_data:
print(study_data)
else:
study_data_str = json.dumps(study_data)
data = {
"model": "llama3-8b-8192",
"messages": [
{
"role": "user",
"content": (
Input prompt + study_data_str
)
}
]
}
This is just an example of the code I was using wherein I haven’t filled any of the necessary fields.
I was passing this data field to a LLM model but after I do so, I keep getting an error which is probably due to some formatting problems in study_data_str
but how do I fix this so that I achieve correct formatting ?
1