Files
dev-gpt/dev_gpt/options/generate/prompt_factory.py
Florian Hönicke c29c212e12 refactor: cleanup
2023-05-09 18:08:09 +02:00

18 lines
357 B
Python

import json
def context_to_string(context):
context_strings = []
for k, v in context.items():
if isinstance(v, dict):
v = json.dumps(v, indent=4)
v = v.replace('{', '{{').replace('}', '}}')
context_strings.append(f'''\
{k}:
```
{v}
```
'''
)
return '\n'.join(context_strings)