lhk commited on
Commit
f7b7259
·
1 Parent(s): 5006aed

adding a simplified code generator

Browse files
Files changed (2) hide show
  1. CodeGenerator.py +10 -0
  2. CodeGenerator.yaml +61 -0
CodeGenerator.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from flows.flow_verse import load_class
4
+ repository_id = "martinjosifoski/OpenAIChatAtomicFlow"
5
+ OpenAIChatAtomicFlow = load_class(repository_id, "OpenAIChatAtomicFlow")
6
+
7
+
8
+ class CodeGenerator(OpenAIChatAtomicFlow):
9
+ def __init__(self, **kwargs):
10
+ super().__init__(**kwargs)
CodeGenerator.yaml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "CodeGenerator"
2
+ verbose: True
3
+ description: "A simple demonstration flow that outputs python code"
4
+
5
+ model_name: "gpt-4"
6
+ generation_parameters:
7
+ n: 1
8
+ max_tokens: 3000
9
+ temperature: 0.3
10
+
11
+ model_kwargs:
12
+ top_p: 0.2
13
+ frequency_penalty: 0
14
+ presence_penalty: 0
15
+
16
+ system_message_prompt_template:
17
+ _target_: langchain.PromptTemplate
18
+ template: |2-
19
+ Your goal is to provide executable Python code that solves a problem described by the user.
20
+ The user will provide you with an output format that you will strictly follow.
21
+ input_variables: []
22
+ template_format: jinja2
23
+
24
+ human_message_prompt_template:
25
+ _target_: langchain.PromptTemplate
26
+ template: "{{query}}"
27
+ input_variables:
28
+ - "query"
29
+ template_format: jinja2
30
+
31
+ query_message_prompt_template:
32
+ _target_: langchain.PromptTemplate
33
+ template: |2-
34
+ # Problem statement
35
+ {{problem_description}}
36
+
37
+ Return Python code that solves the problem. Reply in the following format:
38
+ ```python
39
+ {{code_placeholder}}
40
+ ```
41
+ input_variables:
42
+ - "problem_description"
43
+ partial_variables:
44
+ code_placeholder: "{{python_code}}"
45
+ template_format: jinja2
46
+
47
+ input_data_transformations: []
48
+ input_keys:
49
+ - "problem_description"
50
+
51
+ output_data_transformations:
52
+ - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
53
+ regex: '(?<=```python)([\s\S]*?)(?=```)'
54
+ regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
55
+ input_key: "raw_response"
56
+ output_key: "code"
57
+ strip: True
58
+ assert_unique: True
59
+ verbose: True
60
+ output_keys:
61
+ - "code"