### What problem does this PR solve? #2270 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)tags/v0.11.0
| if self._param.symbols_datatype == "quotes": | if self._param.symbols_datatype == "quotes": | ||||
| for i in response['data']: | for i in response['data']: | ||||
| i['Selling Price'] = i['a'] | i['Selling Price'] = i['a'] | ||||
| i['buying price'] = i['b'] | |||||
| i['commodity code'] = i['c'] | |||||
| i['Buying Price'] = i['b'] | |||||
| i['Commodity Code'] = i['c'] | |||||
| i['Stock Exchange'] = i['e'] | i['Stock Exchange'] = i['e'] | ||||
| i['Highest Price'] = i['h'] | i['Highest Price'] = i['h'] | ||||
| i['Yesterday’s Closing Price'] = i['hc'] | i['Yesterday’s Closing Price'] = i['hc'] |
| } | } | ||||
| text = perform_variable_replacements(self._extraction_prompt, variables=variables) | text = perform_variable_replacements(self._extraction_prompt, variables=variables) | ||||
| gen_conf = {"temperature": 0.5} | gen_conf = {"temperature": 0.5} | ||||
| results = self._llm.chat(text, [], gen_conf) | |||||
| results = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf) | |||||
| claims = results.strip().removesuffix(completion_delimiter) | claims = results.strip().removesuffix(completion_delimiter) | ||||
| history = [{"role": "system", "content": text}, {"role": "assistant", "content": results}] | history = [{"role": "system", "content": text}, {"role": "assistant", "content": results}] | ||||
| text = perform_variable_replacements(self._extraction_prompt, variables=prompt_variables) | text = perform_variable_replacements(self._extraction_prompt, variables=prompt_variables) | ||||
| gen_conf = {"temperature": 0.3} | gen_conf = {"temperature": 0.3} | ||||
| try: | try: | ||||
| response = self._llm.chat(text, [], gen_conf) | |||||
| response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf) | |||||
| token_count += num_tokens_from_string(text + response) | token_count += num_tokens_from_string(text + response) | ||||
| response = re.sub(r"^[^\{]*", "", response) | response = re.sub(r"^[^\{]*", "", response) | ||||
| response = re.sub(r"[^\}]*$", "", response) | response = re.sub(r"[^\}]*$", "", response) | ||||
| report_sections = "\n\n".join( | report_sections = "\n\n".join( | ||||
| f"## {finding_summary(f)}\n\n{finding_explanation(f)}" for f in findings | f"## {finding_summary(f)}\n\n{finding_explanation(f)}" for f in findings | ||||
| ) | ) | ||||
| return f"# {title}\n\n{summary}\n\n{report_sections}" | |||||
| return f"# {title}\n\n{summary}\n\n{report_sections}" |
| } | } | ||||
| text = perform_variable_replacements(self._resolution_prompt, variables=variables) | text = perform_variable_replacements(self._resolution_prompt, variables=variables) | ||||
| response = self._llm.chat(text, [], gen_conf) | |||||
| response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf) | |||||
| result = self._process_results(len(candidate_resolution_i[1]), response, | result = self._process_results(len(candidate_resolution_i[1]), response, | ||||
| prompt_variables.get(self._record_delimiter_key, | prompt_variables.get(self._record_delimiter_key, | ||||
| DEFAULT_RECORD_DELIMITER), | DEFAULT_RECORD_DELIMITER), |
| token_count = 0 | token_count = 0 | ||||
| text = perform_variable_replacements(self._extraction_prompt, variables=variables) | text = perform_variable_replacements(self._extraction_prompt, variables=variables) | ||||
| gen_conf = {"temperature": 0.3} | gen_conf = {"temperature": 0.3} | ||||
| response = self._llm.chat(text, [], gen_conf) | |||||
| response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf) | |||||
| token_count = num_tokens_from_string(text + response) | token_count = num_tokens_from_string(text + response) | ||||
| results = response or "" | results = response or "" |
| } | } | ||||
| text = perform_variable_replacements(self._mind_map_prompt, variables=variables) | text = perform_variable_replacements(self._mind_map_prompt, variables=variables) | ||||
| gen_conf = {"temperature": 0.5} | gen_conf = {"temperature": 0.5} | ||||
| response = self._llm.chat(text, [], gen_conf) | |||||
| response = self._llm.chat(text, [{"role": "user", "content": "Output:"}], gen_conf) | |||||
| response = re.sub(r"```[^\n]*", "", response) | response = re.sub(r"```[^\n]*", "", response) | ||||
| print(response) | print(response) | ||||
| print("---------------------------------------------------\n", self._todict(markdown_to_json.dictify(response))) | print("---------------------------------------------------\n", self._todict(markdown_to_json.dictify(response))) |