Alibrown commited on
Commit
bca8e0e
·
verified ·
1 Parent(s): c828461

Create modules/model_handler.py

Browse files
Files changed (1) hide show
  1. modules/model_handler.py +28 -0
modules/model_handler.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from jinja2 import Environment, FileSystemLoader
2
+ import os
3
+
4
+ AI_MODELS = {
5
+ # Deine Modelldefinitionen hier (wie zuvor)
6
+ }
7
+
8
+ def render_template(template_name, context):
9
+ env = Environment(
10
+ loader=FileSystemLoader('templates'),
11
+ trim_blocks=True,
12
+ lstrip_blocks=True
13
+ )
14
+ template = env.get_template(template_name)
15
+ return template.render(context)
16
+
17
+ def generate_code(task_input, api_key, language, hf_space=False, temp_dir='/tmp'):
18
+ params = parse_tasks(task_input) # Deine bestehende Parse-Logik
19
+
20
+ context = {
21
+ "params": params,
22
+ "api_key": api_key,
23
+ "hf_space": hf_space,
24
+ "temp_dir": temp_dir,
25
+ "model_config": AI_MODELS[params['api']]
26
+ }
27
+
28
+ return render_template(f"{language}.jinja2", context)