Onurcan Genç commited on
Commit ·
bd1ed67
1
Parent(s): fb273bd
3213
Browse files
app.py
CHANGED
|
@@ -15,7 +15,11 @@ if not api_key:
|
|
| 15 |
# Set the API key and model for the interpreter
|
| 16 |
interpreter.llm.api_key = api_key
|
| 17 |
interpreter.llm.provider = "huggingface" # Specify the provider
|
| 18 |
-
interpreter.llm.model = "huggingface/gpt2" # Use
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Function to execute shell commands if detected in model output
|
| 21 |
def execute_shell_command(command):
|
|
@@ -28,7 +32,7 @@ def execute_shell_command(command):
|
|
| 28 |
def execute_task(task):
|
| 29 |
try:
|
| 30 |
# Get the model-generated response first
|
| 31 |
-
response = "".join([chunk for chunk in interpreter.chat(task, stream=True)])
|
| 32 |
except Exception as e:
|
| 33 |
return f"Error while interacting with the model: {str(e)}"
|
| 34 |
|
|
|
|
| 15 |
# Set the API key and model for the interpreter
|
| 16 |
interpreter.llm.api_key = api_key
|
| 17 |
interpreter.llm.provider = "huggingface" # Specify the provider
|
| 18 |
+
interpreter.llm.model = "huggingface/gpt2" # Use an existing Hugging Face model identifier
|
| 19 |
+
|
| 20 |
+
# Set context window and max tokens for the model
|
| 21 |
+
interpreter.context_window = 8000
|
| 22 |
+
interpreter.max_tokens = 1000
|
| 23 |
|
| 24 |
# Function to execute shell commands if detected in model output
|
| 25 |
def execute_shell_command(command):
|
|
|
|
| 32 |
def execute_task(task):
|
| 33 |
try:
|
| 34 |
# Get the model-generated response first
|
| 35 |
+
response = "".join([chunk if isinstance(chunk, str) else str(chunk) for chunk in interpreter.chat(task, stream=True)])
|
| 36 |
except Exception as e:
|
| 37 |
return f"Error while interacting with the model: {str(e)}"
|
| 38 |
|