Onurcan Genç commited on
Commit ·
d555fd5
1
Parent(s): 4d1930d
33333
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import argparse
|
| 2 |
-
import gradio as gr
|
| 3 |
import torch
|
| 4 |
from transformers import pipeline
|
|
|
|
| 5 |
|
| 6 |
# Load the model
|
| 7 |
generator = pipeline("text-generation", model="gpt-neo-2.7B")
|
|
@@ -10,9 +10,13 @@ generator = pipeline("text-generation", model="gpt-neo-2.7B")
|
|
| 10 |
def generate_text(prompt):
|
| 11 |
return generator(prompt, max_length=100, do_sample=True)[0]["generated_text"]
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# CLI interface using argparse
|
| 14 |
def cli_interface():
|
| 15 |
-
parser = argparse.ArgumentParser(description="Command-line interaction with the text generation model.")
|
| 16 |
parser.add_argument("--task", type=str, help="The prompt or command to generate text for")
|
| 17 |
args = parser.parse_args()
|
| 18 |
|
|
@@ -23,11 +27,19 @@ def cli_interface():
|
|
| 23 |
result = generate_text(task)
|
| 24 |
print(result)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
if __name__ == "__main__":
|
| 27 |
cli_interface()
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import argparse
|
|
|
|
| 2 |
import torch
|
| 3 |
from transformers import pipeline
|
| 4 |
+
from interpreter import interpreter
|
| 5 |
|
| 6 |
# Load the model
|
| 7 |
generator = pipeline("text-generation", model="gpt-neo-2.7B")
|
|
|
|
| 10 |
def generate_text(prompt):
|
| 11 |
return generator(prompt, max_length=100, do_sample=True)[0]["generated_text"]
|
| 12 |
|
| 13 |
+
# Define a function to handle input using OpenInterpreter
|
| 14 |
+
def generate_interpreter_response(prompt):
|
| 15 |
+
return interpreter.chat(prompt)
|
| 16 |
+
|
| 17 |
# CLI interface using argparse
|
| 18 |
def cli_interface():
|
| 19 |
+
parser = argparse.ArgumentParser(description="Command-line interaction with the text generation model and OpenInterpreter.")
|
| 20 |
parser.add_argument("--task", type=str, help="The prompt or command to generate text for")
|
| 21 |
args = parser.parse_args()
|
| 22 |
|
|
|
|
| 27 |
result = generate_text(task)
|
| 28 |
print(result)
|
| 29 |
|
| 30 |
+
# Process task using OpenInterpreter
|
| 31 |
+
response = generate_interpreter_response(task)
|
| 32 |
+
print("OpenInterpreter Response:", response)
|
| 33 |
+
|
| 34 |
if __name__ == "__main__":
|
| 35 |
cli_interface()
|
| 36 |
|
| 37 |
+
# Additional information about the OpenInterpreter project
|
| 38 |
+
# OpenInterpreter allows LLMs to execute code (including Python, JavaScript, Shell commands, and more) in a local environment.
|
| 39 |
+
# It provides a natural-language interface to your computer's general-purpose capabilities, such as creating and editing files,
|
| 40 |
+
# controlling a web browser, and analyzing large datasets.
|
| 41 |
+
# To get started, install OpenInterpreter using:
|
| 42 |
+
# pip install open-interpreter
|
| 43 |
+
# After installation, start the interpreter with the command:
|
| 44 |
+
# $ interpreter
|
| 45 |
+
# For more information, visit: https://github.com/OpenInterpreter
|