Making an Ollama Model read dict/json data properly

1 day ago 7
ARTICLE AD BOX

I am using Big Query to pull SQL data from a certain database. I am having issues making an Ollama model, particularly the llama3.3 70B, making it read the SQL query data properly. It only just reiterates the given prompt and asks for more information. I convert the SQL data into a dictionary, and convert the dictionary to json data through the .jsondump().

If anyone has any suggestions so that I can make it read it properly. My main goal is for the model to be able to read the JSON formatted data and provide a summary on the query results. The results of the SQL entail certain parameters used for the Big Query, for example a Goldstein scale is a component of the query. My main goal is to have the model summarize what each query component entails, and give a snapshot of the overall query response. For example, SQL parameters below should be summarized by the model after the query response, then analyzed and used to forecast the current situation of the input.

SQLDATE, Actor1Name, Actor2Name, EventCode, EventRootCode, AvgTone, GoldsteinScale, SOURCEURL def askollamaHandler(param2,param2,param3, model="llama3.1:latest"): prompt = { f"Context: ------" f"Tasl: --------" f"Metrics: ----------." f"Analyze: ------" } response = requests.post( "http://localhost:11434/api/generate", json={ "model": model, "prompt": prompt, "stream": False } ) return response.json()["response"] def askollamaQuery(param1, param2, model="llama3.1:latest"): prompt = { f"Task: ------" f"Context: ----" f"Metrics: ----" f"Analyze: ---- " f"Data:---" } response = requests.post( "http://localhost:11434/api/generate", json={ "model": model, "prompt": prompt, "stream": False } ) return response.json()["response"] QUERY_RESULT_DATA = client.query(query) DATA_DICT = [dict(row) for row in QUERY_RESULT_DATA] # 1 query to dict df = pd.DataFrame(DATA_DICT) #for XLSX save json_data = json.dump(DATA_DICT) #for LLM read llama_handler_summary = askollamaHandler(country_code_filter,keyword_filter,event_filter) llama_query_summary = askollamaQuery(DATA_DICT,llama_handler_summary)
Read Entire Article