Setup in context examples dict
()
| 9 | |
| 10 | IN_CONTEXT_EXAMPLES_DICT = {} |
| 11 | def load_in_context_examples(): |
| 12 | """ |
| 13 | Setup in context examples dict |
| 14 | """ |
| 15 | global IN_CONTEXT_EXAMPLES_DICT |
| 16 | |
| 17 | if not DB_MANAGED_METADATA: |
| 18 | with open("app/models/json/in_context_examples.json", "r") as f: |
| 19 | IN_CONTEXT_EXAMPLES_DICT = json.load(f) |
| 20 | return |
| 21 | |
| 22 | try: |
| 23 | in_context_examples = InContextExamples.query.all() |
| 24 | except Exception as e: |
| 25 | print(e) |
| 26 | in_context_examples = [] |
| 27 | for in_context_example in in_context_examples: |
| 28 | IN_CONTEXT_EXAMPLES_DICT[in_context_example.mode] = in_context_example.examples |
| 29 | |
| 30 | |
| 31 | def get_few_shot_messages(mode: str = "text_to_sql") -> List[Dict]: |