forked from OpenInterpreter/open-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typo in interpreter/code_interpreters/languages/python.py
- Loading branch information
1 parent
295ddfa
commit 8884506
Showing
3 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Function to enable / disable different lang based on operating system. """ | ||
import platform | ||
import copy | ||
|
||
BASE_FUNCTION_SCHEMA = { | ||
"name": "execute", | ||
"description": | ||
"Executes code on the user's machine, **in the users local environment**, and returns the output", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"language": { | ||
"type": "string", | ||
"description": | ||
"The programming language (required parameter to the `execute` function)", | ||
"enum": ["python", "R", "shell", "javascript", "html",] | ||
}, | ||
"code": { | ||
"type": "string", | ||
"description": "The code to execute (required)" | ||
} | ||
}, | ||
"required": ["language", "code"] | ||
}, | ||
} | ||
|
||
def get_schema(): | ||
# Detect the operating system | ||
os_type = platform.system().lower() | ||
|
||
# Define the base languages that are common to all supported operating systems | ||
base_languages = ["python", "R", "shell", "javascript", "html"] | ||
|
||
# Copy the schema to avoid modifying the original | ||
corrected_schema = copy.deepcopy(BASE_FUNCTION_SCHEMA) | ||
|
||
# Add 'powershell' if the OS is Windows, 'applescript' if macOS, or none if it's another OS | ||
if os_type == 'windows': | ||
base_languages.append('powershell') | ||
elif os_type == 'darwin': # Darwin is the system name for macOS | ||
base_languages.append('applescript') | ||
|
||
corrected_schema['parameters']['properties']['language']['enum'] = base_languages | ||
|
||
return corrected_schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters