Skip to content

Commit 58d5727

Browse files
committed
Local III 0.3.4
1 parent 8ad54e9 commit 58d5727

File tree

3 files changed

+107
-1
lines changed

3 files changed

+107
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
This is an Open Interpreter profile.
3+
"""
4+
5+
import e2b
6+
7+
from interpreter import interpreter
8+
9+
10+
class PythonE2B:
11+
"""
12+
This class contains all requirements for being a custom language in Open Interpreter:
13+
14+
- name (an attribute)
15+
- run (a method)
16+
- stop (a method)
17+
- terminate (a method)
18+
19+
Here, we'll use E2B to power the `run` method.
20+
"""
21+
22+
# This is the name that will appear to the LLM.
23+
name = "python"
24+
25+
# Optionally, you can append some information about this language to the system message:
26+
system_message = "# Follow this rule: Every Python code block MUST contain at least one print statement."
27+
28+
# (E2B isn't a Jupyter Notebook, so we added ^ this so it would print things,
29+
# instead of putting variables at the end of code blocks, which is a Jupyter thing.)
30+
31+
def run(self, code):
32+
"""Generator that yields a dictionary in LMC Format."""
33+
34+
# Run the code on E2B
35+
stdout, stderr = e2b.run_code("Python3", code)
36+
37+
# Yield the output
38+
yield {
39+
"type": "console",
40+
"format": "output",
41+
"content": stdout
42+
+ stderr, # We combined these arbitrarily. Yield anything you'd like!
43+
}
44+
45+
def stop(self):
46+
"""Stops the code."""
47+
# Not needed here, because e2b.run_code isn't stateful.
48+
pass
49+
50+
def terminate(self):
51+
"""Terminates the entire process."""
52+
# Not needed here, because e2b.run_code isn't stateful.
53+
pass
54+
55+
56+
# (Tip: Do this before adding/removing languages, otherwise OI might retain the state of previous languages:)
57+
interpreter.computer.terminate()
58+
59+
# Give Open Interpreter its languages. This will only let it run PythonE2B:
60+
interpreter.computer.languages = [PythonE2B]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
This is an Open Interpreter profile. It configures Open Interpreter to run `gemma2` using Ollama.
3+
"""
4+
5+
from interpreter import interpreter
6+
7+
interpreter.system_message = """You are an AI assistant that writes tiny markdown code snippets to answer the user's request. You speak very concisely and quickly, you say nothing irrelevant to the user's request. For example:
8+
9+
User: Open the chrome app.
10+
Assistant: On it.
11+
```python
12+
import webbrowser
13+
webbrowser.open('https://chrome.google.com')
14+
```
15+
User: The code you ran produced no output. Was this expected, or are we finished?
16+
Assistant: No further action is required; the provided snippet opens Chrome.
17+
18+
Now, your turn:""".strip()
19+
20+
# Message templates
21+
interpreter.code_output_template = """I executed that code. This was the output: \n\n{content}\n\nWhat does this output mean? I can't understand it, please help / what code needs to be run next (if anything, or are we done with my query)?"""
22+
interpreter.empty_code_output_template = "I executed your code snippet. It produced no text output. What's next (if anything, or are we done?)"
23+
interpreter.user_message_template = (
24+
"Write a ```python code snippet that would answer this query: `{content}`"
25+
)
26+
interpreter.code_output_sender = "user"
27+
28+
# LLM settings
29+
interpreter.llm.model = "ollama/gemma2"
30+
interpreter.llm.supports_functions = False
31+
interpreter.llm.execution_instructions = False
32+
interpreter.llm.max_tokens = 1000
33+
interpreter.llm.context_window = 7000
34+
interpreter.llm.load() # Loads Ollama models
35+
36+
# Computer settings
37+
interpreter.computer.import_computer_api = False
38+
39+
# Misc settings
40+
interpreter.auto_run = True
41+
interpreter.offline = True
42+
43+
# Final message
44+
interpreter.display_message(
45+
"> Model set to `gemma2`\n\n**Open Interpreter** will require approval before running code.\n\nUse `interpreter -y` to bypass this.\n\nPress `CTRL-C` to exit.\n"
46+
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "open-interpreter"
33
packages = [
44
{include = "interpreter"},
55
]
6-
version = "0.3.3" # Use "-rc1", "-rc2", etc. for pre-release versions
6+
version = "0.3.4" # Use "-rc1", "-rc2", etc. for pre-release versions
77
description = "Let language models run code"
88
authors = ["Killian Lucas <[email protected]>"]
99
readme = "README.md"

0 commit comments

Comments
 (0)