You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: contrib/hamilton/contrib/user/zilto/llm_generate_code/README.md
+23-4
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,34 @@ This module uses the OpenAI completion API to generate code.
4
4
5
5
For any language, you can request `generated_code` to get the generated response. If you are generating Python code, you can execute it in a subprocess by requesting `execution_output` and `execution_error`.
6
6
7
-
# Configuration Options
8
-
## Config.when
7
+
## Example
8
+
```python
9
+
from hamilton import driver
10
+
import__init__as llm_generate_code
11
+
12
+
dr = driver.Builder().with_modules(llm_generate_code).build()
13
+
14
+
dr.execute(
15
+
["execution_output", "execution_error"],
16
+
inputs=dict(
17
+
query="Retrieve the primary type from a `typing.Annotated` object`",
18
+
)
19
+
)
20
+
```
21
+
22
+
## Configuration Options
23
+
### Config.when
9
24
This module doesn't receive configurations.
10
25
11
-
## Inputs
26
+
###Inputs
12
27
-`query`: The query for which you want code generated.
13
28
-`api_key`: Set the OpenAI API key to use. If None, read the environment variable `OPENAI_API_KEY`
14
29
-`code_language`: Set the code language to generate the reponse in. Defaults to `python`
15
30
16
-
## Overrides
31
+
###Overrides
17
32
-`prompt_template_to_generate_code`: Create a new prompt template with the fields `query` and `code_language`.
18
33
-`prompt_to_generate_code`: Manually provide a prompt to generate Python code
34
+
35
+
## Extension / Limitations
36
+
- Executing arbitrary generated code is a security risk. Proceed with caution.
37
+
- You need to manually install dependencies for your generated code to be executed (i.e., you need to `pip install pandas` yourself)
0 commit comments