Spaces:
Running
on
Zero
Running
on
Zero
test
Browse files- Makefile +1 -1
- controllers/ai/.gpteng/memory/logs/all_output.txt +209 -0
- controllers/ai/.gpteng/memory/logs/gen_entrypoint_chat.txt +160 -0
- mysite/gradio/gradio_config.py +1 -1
- mysite/interpreter/process.py +6 -5
- mysite/libs/utilities.py +1 -1
- routers/OpenInterpreter.py +115 -0
- routers/__init__.py +0 -0
- routers/ai/prompt +1 -1
- routers/document +0 -0
- routers/router.py +1 -9
Makefile
CHANGED
@@ -45,7 +45,7 @@ farewell:
|
|
45 |
#Defines a target named run. This target will run GPT Engineer on the folder with the given name.
|
46 |
run:
|
47 |
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
|
48 |
-
cd ./gpt-engineer && poetry run gpt-engineer /home/user/app/
|
49 |
|
50 |
# Counts the lines of code in the project
|
51 |
cloc:
|
|
|
45 |
#Defines a target named run. This target will run GPT Engineer on the folder with the given name.
|
46 |
run:
|
47 |
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
|
48 |
+
cd ./gpt-engineer && poetry run gpt-engineer /home/user/app/controllers/$(name) --model Llama3-70b-8192 --temperature 0.1
|
49 |
|
50 |
# Counts the lines of code in the project
|
51 |
cloc:
|
controllers/ai/.gpteng/memory/logs/all_output.txt
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
2024-06-09T19:31:37.330079
|
3 |
+
================================ System Message ================================
|
4 |
+
|
5 |
+
You will get instructions for code to write.
|
6 |
+
You will write a very long answer. Make sure that every detail of the architecture is, in the end, implemented as code.
|
7 |
+
Think step by step and reason yourself to the correct decisions to make sure we get it right.
|
8 |
+
First lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose.
|
9 |
+
|
10 |
+
You will output the content of each file necessary to achieve the goal, including ALL code.
|
11 |
+
Represent files like so:
|
12 |
+
|
13 |
+
FILENAME
|
14 |
+
```
|
15 |
+
CODE
|
16 |
+
```
|
17 |
+
|
18 |
+
The following tokens must be replaced like so:
|
19 |
+
FILENAME is the lowercase combined path and file name including the file extension
|
20 |
+
CODE is the code in the file
|
21 |
+
|
22 |
+
Example representation of a file:
|
23 |
+
|
24 |
+
src/hello_world.py
|
25 |
+
```
|
26 |
+
print("Hello World")
|
27 |
+
```
|
28 |
+
|
29 |
+
Do not comment on what every file does. Please note that the code should be fully functional. No placeholders.
|
30 |
+
|
31 |
+
|
32 |
+
You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on.
|
33 |
+
Please note that the code should be fully functional. No placeholders.
|
34 |
+
|
35 |
+
Follow a language and framework appropriate best practice file naming convention.
|
36 |
+
Make sure that files contain all imports, types etc. The code should be fully functional. Make sure that code in different files are compatible with each other.
|
37 |
+
Ensure to implement all code, if you are unsure, write a plausible implementation.
|
38 |
+
Include module dependency or package manager dependency definition file.
|
39 |
+
Before you finish, double check that all parts of the architecture is present in the files.
|
40 |
+
|
41 |
+
When you are done, write finish with "this concludes a fully working implementation".
|
42 |
+
|
43 |
+
Useful to know:
|
44 |
+
Almost always put different classes in different files.
|
45 |
+
Always use the programming language the user asks for.
|
46 |
+
For Python, you always create an appropriate requirements.txt file.
|
47 |
+
For NodeJS, you always create an appropriate package.json file.
|
48 |
+
Always add a comment briefly describing the purpose of the function definition.
|
49 |
+
Add comments explaining very complex bits of logic.
|
50 |
+
Always follow the best practices for the requested languages for folder/file structure and how to package the project.
|
51 |
+
|
52 |
+
|
53 |
+
Python toolbelt preferences:
|
54 |
+
- pytest
|
55 |
+
- dataclasses
|
56 |
+
|
57 |
+
|
58 |
+
================================ Human Message =================================
|
59 |
+
|
60 |
+
Request: n
|
61 |
+
|
62 |
+
================================== Ai Message ==================================
|
63 |
+
|
64 |
+
I understand that you want me to create a fully functional implementation of a Python project. Since you didn't specify a particular problem or domain, I'll create a simple project that demonstrates a basic architecture.
|
65 |
+
|
66 |
+
Let's create a simple banking system that allows users to create accounts, deposit, withdraw, and check their balances.
|
67 |
+
|
68 |
+
Here's the project structure:
|
69 |
+
|
70 |
+
```
|
71 |
+
banking_system
|
72 |
+
requirements.txt
|
73 |
+
src
|
74 |
+
__init__.py
|
75 |
+
account.py
|
76 |
+
bank.py
|
77 |
+
main.py
|
78 |
+
tests
|
79 |
+
__init__.py
|
80 |
+
test_account.py
|
81 |
+
test_bank.py
|
82 |
+
```
|
83 |
+
|
84 |
+
Here are the contents of each file:
|
85 |
+
|
86 |
+
**requirements.txt**
|
87 |
+
```
|
88 |
+
pytest
|
89 |
+
dataclasses
|
90 |
+
```
|
91 |
+
|
92 |
+
**src/__init__.py** (empty file)
|
93 |
+
|
94 |
+
**src/account.py**
|
95 |
+
```
|
96 |
+
from dataclasses import dataclass
|
97 |
+
|
98 |
+
@dataclass
|
99 |
+
class Account:
|
100 |
+
"""Represents a bank account"""
|
101 |
+
account_number: int
|
102 |
+
balance: float = 0.0
|
103 |
+
|
104 |
+
def deposit(self, amount: float) -> None:
|
105 |
+
"""Deposit money into the account"""
|
106 |
+
self.balance += amount
|
107 |
+
|
108 |
+
def withdraw(self, amount: float) -> None:
|
109 |
+
"""Withdraw money from the account"""
|
110 |
+
if amount > self.balance:
|
111 |
+
raise ValueError("Insufficient balance")
|
112 |
+
self.balance -= amount
|
113 |
+
|
114 |
+
def get_balance(self) -> float:
|
115 |
+
"""Get the current balance of the account"""
|
116 |
+
return self.balance
|
117 |
+
```
|
118 |
+
|
119 |
+
**src/bank.py**
|
120 |
+
```
|
121 |
+
from .account import Account
|
122 |
+
|
123 |
+
class Bank:
|
124 |
+
"""Represents a bank"""
|
125 |
+
def __init__(self):
|
126 |
+
self.accounts = {}
|
127 |
+
|
128 |
+
def create_account(self, account_number: int) -> Account:
|
129 |
+
"""Create a new account"""
|
130 |
+
if account_number in self.accounts:
|
131 |
+
raise ValueError("Account already exists")
|
132 |
+
account = Account(account_number)
|
133 |
+
self.accounts[account_number] = account
|
134 |
+
return account
|
135 |
+
|
136 |
+
def get_account(self, account_number: int) -> Account:
|
137 |
+
"""Get an existing account"""
|
138 |
+
return self.accounts.get(account_number)
|
139 |
+
|
140 |
+
def list_accounts(self) -> list:
|
141 |
+
"""Get a list of all accounts"""
|
142 |
+
return list(self.accounts.values())
|
143 |
+
```
|
144 |
+
|
145 |
+
**src/main.py**
|
146 |
+
```
|
147 |
+
from .bank import Bank
|
148 |
+
|
149 |
+
def main():
|
150 |
+
bank = Bank()
|
151 |
+
account = bank.create_account(1234)
|
152 |
+
account.deposit(100.0)
|
153 |
+
print(account.get_balance()) # 100.0
|
154 |
+
account.withdraw(50.0)
|
155 |
+
print(account.get_balance()) # 50.0
|
156 |
+
|
157 |
+
if __name__ == "__main__":
|
158 |
+
main()
|
159 |
+
```
|
160 |
+
|
161 |
+
**tests/__init__.py** (empty file)
|
162 |
+
|
163 |
+
**tests/test_account.py**
|
164 |
+
```
|
165 |
+
from unittest import TestCase
|
166 |
+
from src.account import Account
|
167 |
+
|
168 |
+
class TestAccount(TestCase):
|
169 |
+
def test_deposit(self):
|
170 |
+
account = Account(1234)
|
171 |
+
account.deposit(100.0)
|
172 |
+
self.assertEqual(account.get_balance(), 100.0)
|
173 |
+
|
174 |
+
def test_withdraw(self):
|
175 |
+
account = Account(1234)
|
176 |
+
account.deposit(100.0)
|
177 |
+
account.withdraw(50.0)
|
178 |
+
self.assertEqual(account.get_balance(), 50.0)
|
179 |
+
|
180 |
+
def test_insufficient_balance(self):
|
181 |
+
account = Account(1234)
|
182 |
+
with self.assertRaises(ValueError):
|
183 |
+
account.withdraw(100.0)
|
184 |
+
```
|
185 |
+
|
186 |
+
**tests/test_bank.py**
|
187 |
+
```
|
188 |
+
from unittest import TestCase
|
189 |
+
from src.bank import Bank
|
190 |
+
|
191 |
+
class TestBank(TestCase):
|
192 |
+
def test_create_account(self):
|
193 |
+
bank = Bank()
|
194 |
+
account = bank.create_account(1234)
|
195 |
+
self.assertIsInstance(account, Account)
|
196 |
+
|
197 |
+
def test_get_account(self):
|
198 |
+
bank = Bank()
|
199 |
+
account = bank.create_account(1234)
|
200 |
+
self.assertEqual(bank.get_account(1234), account)
|
201 |
+
|
202 |
+
def test_list_accounts(self):
|
203 |
+
bank = Bank()
|
204 |
+
bank.create_account(1234)
|
205 |
+
bank.create_account(5678)
|
206 |
+
self.assertEqual(len(bank.list_accounts()), 2)
|
207 |
+
```
|
208 |
+
|
209 |
+
This concludes a fully working implementation.
|
controllers/ai/.gpteng/memory/logs/gen_entrypoint_chat.txt
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
2024-06-09T19:31:38.069620
|
3 |
+
================================ System Message ================================
|
4 |
+
|
5 |
+
You will get information about a codebase that is currently on disk in the current folder.
|
6 |
+
The user will ask you to write a script that runs the code in a specific way.
|
7 |
+
You will answer with code blocks that include all the necessary terminal commands.
|
8 |
+
Do not install globally. Do not use sudo.
|
9 |
+
Do not explain the code, just give the commands.
|
10 |
+
Do not use placeholders, use example values (like . for a folder argument) if necessary.
|
11 |
+
|
12 |
+
|
13 |
+
================================ Human Message =================================
|
14 |
+
|
15 |
+
|
16 |
+
Make a unix script that
|
17 |
+
a) installs dependencies
|
18 |
+
b) runs all necessary parts of the codebase (in parallel if necessary)
|
19 |
+
|
20 |
+
Information about the codebase:
|
21 |
+
|
22 |
+
```
|
23 |
+
File: structure
|
24 |
+
1 banking_system
|
25 |
+
2 requirements.txt
|
26 |
+
3 src
|
27 |
+
4 __init__.py
|
28 |
+
5 account.py
|
29 |
+
6 bank.py
|
30 |
+
7 main.py
|
31 |
+
8 tests
|
32 |
+
9 __init__.py
|
33 |
+
10 test_account.py
|
34 |
+
11 test_bank.py
|
35 |
+
|
36 |
+
File: requirements.txt
|
37 |
+
1 pytest
|
38 |
+
2 dataclasses
|
39 |
+
|
40 |
+
File: src/account.py
|
41 |
+
1 from dataclasses import dataclass
|
42 |
+
2
|
43 |
+
3 @dataclass
|
44 |
+
4 class Account:
|
45 |
+
5 """Represents a bank account"""
|
46 |
+
6 account_number: int
|
47 |
+
7 balance: float = 0.0
|
48 |
+
8
|
49 |
+
9 def deposit(self, amount: float) -> None:
|
50 |
+
10 """Deposit money into the account"""
|
51 |
+
11 self.balance += amount
|
52 |
+
12
|
53 |
+
13 def withdraw(self, amount: float) -> None:
|
54 |
+
14 """Withdraw money from the account"""
|
55 |
+
15 if amount > self.balance:
|
56 |
+
16 raise ValueError("Insufficient balance")
|
57 |
+
17 self.balance -= amount
|
58 |
+
18
|
59 |
+
19 def get_balance(self) -> float:
|
60 |
+
20 """Get the current balance of the account"""
|
61 |
+
21 return self.balance
|
62 |
+
|
63 |
+
File: src/bank.py
|
64 |
+
1 from .account import Account
|
65 |
+
2
|
66 |
+
3 class Bank:
|
67 |
+
4 """Represents a bank"""
|
68 |
+
5 def __init__(self):
|
69 |
+
6 self.accounts = {}
|
70 |
+
7
|
71 |
+
8 def create_account(self, account_number: int) -> Account:
|
72 |
+
9 """Create a new account"""
|
73 |
+
10 if account_number in self.accounts:
|
74 |
+
11 raise ValueError("Account already exists")
|
75 |
+
12 account = Account(account_number)
|
76 |
+
13 self.accounts[account_number] = account
|
77 |
+
14 return account
|
78 |
+
15
|
79 |
+
16 def get_account(self, account_number: int) -> Account:
|
80 |
+
17 """Get an existing account"""
|
81 |
+
18 return self.accounts.get(account_number)
|
82 |
+
19
|
83 |
+
20 def list_accounts(self) -> list:
|
84 |
+
21 """Get a list of all accounts"""
|
85 |
+
22 return list(self.accounts.values())
|
86 |
+
|
87 |
+
File: src/main.py
|
88 |
+
1 from .bank import Bank
|
89 |
+
2
|
90 |
+
3 def main():
|
91 |
+
4 bank = Bank()
|
92 |
+
5 account = bank.create_account(1234)
|
93 |
+
6 account.deposit(100.0)
|
94 |
+
7 print(account.get_balance()) # 100.0
|
95 |
+
8 account.withdraw(50.0)
|
96 |
+
9 print(account.get_balance()) # 50.0
|
97 |
+
10
|
98 |
+
11 if __name__ == "__main__":
|
99 |
+
12 main()
|
100 |
+
|
101 |
+
File: tests/test_account.py
|
102 |
+
1 from unittest import TestCase
|
103 |
+
2 from src.account import Account
|
104 |
+
3
|
105 |
+
4 class TestAccount(TestCase):
|
106 |
+
5 def test_deposit(self):
|
107 |
+
6 account = Account(1234)
|
108 |
+
7 account.deposit(100.0)
|
109 |
+
8 self.assertEqual(account.get_balance(), 100.0)
|
110 |
+
9
|
111 |
+
10 def test_withdraw(self):
|
112 |
+
11 account = Account(1234)
|
113 |
+
12 account.deposit(100.0)
|
114 |
+
13 account.withdraw(50.0)
|
115 |
+
14 self.assertEqual(account.get_balance(), 50.0)
|
116 |
+
15
|
117 |
+
16 def test_insufficient_balance(self):
|
118 |
+
17 account = Account(1234)
|
119 |
+
18 with self.assertRaises(ValueError):
|
120 |
+
19 account.withdraw(100.0)
|
121 |
+
|
122 |
+
File: tests/test_bank.py
|
123 |
+
1 from unittest import TestCase
|
124 |
+
2 from src.bank import Bank
|
125 |
+
3
|
126 |
+
4 class TestBank(TestCase):
|
127 |
+
5 def test_create_account(self):
|
128 |
+
6 bank = Bank()
|
129 |
+
7 account = bank.create_account(1234)
|
130 |
+
8 self.assertIsInstance(account, Account)
|
131 |
+
9
|
132 |
+
10 def test_get_account(self):
|
133 |
+
11 bank = Bank()
|
134 |
+
12 account = bank.create_account(1234)
|
135 |
+
13 self.assertEqual(bank.get_account(1234), account)
|
136 |
+
14
|
137 |
+
15 def test_list_accounts(self):
|
138 |
+
16 bank = Bank()
|
139 |
+
17 bank.create_account(1234)
|
140 |
+
18 bank.create_account(5678)
|
141 |
+
19 self.assertEqual(len(bank.list_accounts()), 2)
|
142 |
+
|
143 |
+
```
|
144 |
+
|
145 |
+
================================== Ai Message ==================================
|
146 |
+
|
147 |
+
Here is the Unix script that installs dependencies and runs the codebase:
|
148 |
+
```
|
149 |
+
#!/bin/bash
|
150 |
+
|
151 |
+
# Install dependencies
|
152 |
+
pip install -r requirements.txt
|
153 |
+
|
154 |
+
# Run tests in parallel
|
155 |
+
pytest -n 2 tests/
|
156 |
+
|
157 |
+
# Run main script
|
158 |
+
python src/main.py
|
159 |
+
```
|
160 |
+
Save this script to a file (e.g., `run_codebase.sh`), make it executable with `chmod +x run_codebase.sh`, and then run it with `./run_codebase.sh`.
|
mysite/gradio/gradio_config.py
CHANGED
@@ -54,7 +54,7 @@ def setup_gradio_interfaces():
|
|
54 |
)
|
55 |
|
56 |
default_interfaces = [democs]#,demo]
|
57 |
-
default_names = ["仕様書から作成","
|
58 |
|
59 |
gradio_interfaces, gradio_names = include_gradio_interfaces()
|
60 |
|
|
|
54 |
)
|
55 |
|
56 |
default_interfaces = [democs]#,demo]
|
57 |
+
default_names = ["仕様書から作成","Chat","OpenInterpreter","DataBase"]#"demo"]
|
58 |
|
59 |
gradio_interfaces, gradio_names = include_gradio_interfaces()
|
60 |
|
mysite/interpreter/process.py
CHANGED
@@ -11,6 +11,7 @@ import asyncio
|
|
11 |
import mysite.interpreter.interpreter_config
|
12 |
|
13 |
GENERATION_TIMEOUT_SEC=60
|
|
|
14 |
|
15 |
def set_environment_variables():
|
16 |
os.environ["OPENAI_API_BASE"] = "https://api.groq.com/openai/v1"
|
@@ -32,11 +33,11 @@ def validate_signature(body: str, signature: str, secret: str) -> bool:
|
|
32 |
def no_process_file(prompt, foldername):
|
33 |
set_environment_variables()
|
34 |
try:
|
35 |
-
proc = subprocess.Popen(["mkdir", f"
|
36 |
except subprocess.CalledProcessError as e:
|
37 |
return f"Processed Content:\n{e.stdout}\n\nMake Command Error:\n{e.stderr}"
|
38 |
|
39 |
-
no_extension_path = f"
|
40 |
time.sleep(1)
|
41 |
with open(no_extension_path, "a") as f:
|
42 |
f.write(prompt)
|
@@ -66,14 +67,14 @@ def no_process_file(prompt, foldername):
|
|
66 |
def process_file(fileobj, prompt, foldername):
|
67 |
set_environment_variables()
|
68 |
try:
|
69 |
-
proc = subprocess.Popen(["mkdir", f"
|
70 |
except subprocess.CalledProcessError as e:
|
71 |
return f"Processed Content:\n{e.stdout}\n\nMake Command Error:\n{e.stderr}"
|
72 |
time.sleep(2)
|
73 |
-
path = f"
|
74 |
shutil.copyfile(fileobj.name, path)
|
75 |
base_name = os.path.splitext(os.path.basename(fileobj))[0]
|
76 |
-
no_extension_path = f"
|
77 |
shutil.copyfile(fileobj, no_extension_path)
|
78 |
with open(no_extension_path, "a") as f:
|
79 |
f.write(prompt)
|
|
|
11 |
import mysite.interpreter.interpreter_config
|
12 |
|
13 |
GENERATION_TIMEOUT_SEC=60
|
14 |
+
BASE_PATH = "/home/user/app/controllers/"
|
15 |
|
16 |
def set_environment_variables():
|
17 |
os.environ["OPENAI_API_BASE"] = "https://api.groq.com/openai/v1"
|
|
|
33 |
def no_process_file(prompt, foldername):
|
34 |
set_environment_variables()
|
35 |
try:
|
36 |
+
proc = subprocess.Popen(["mkdir", f"{BASE_PATH}{foldername}"])
|
37 |
except subprocess.CalledProcessError as e:
|
38 |
return f"Processed Content:\n{e.stdout}\n\nMake Command Error:\n{e.stderr}"
|
39 |
|
40 |
+
no_extension_path = f"{BASE_PATH}{foldername}/prompt"
|
41 |
time.sleep(1)
|
42 |
with open(no_extension_path, "a") as f:
|
43 |
f.write(prompt)
|
|
|
67 |
def process_file(fileobj, prompt, foldername):
|
68 |
set_environment_variables()
|
69 |
try:
|
70 |
+
proc = subprocess.Popen(["mkdir", f"{BASE_PATH}{foldername}"])
|
71 |
except subprocess.CalledProcessError as e:
|
72 |
return f"Processed Content:\n{e.stdout}\n\nMake Command Error:\n{e.stderr}"
|
73 |
time.sleep(2)
|
74 |
+
path = f"{BASE_PATH}{foldername}/" + os.path.basename(fileobj)
|
75 |
shutil.copyfile(fileobj.name, path)
|
76 |
base_name = os.path.splitext(os.path.basename(fileobj))[0]
|
77 |
+
no_extension_path = f"{BASE_PATH}{foldername}/{base_name}"
|
78 |
shutil.copyfile(fileobj, no_extension_path)
|
79 |
with open(no_extension_path, "a") as f:
|
80 |
f.write(prompt)
|
mysite/libs/utilities.py
CHANGED
@@ -154,7 +154,7 @@ async def completion(message: str, history, c=None, d=None):
|
|
154 |
|
155 |
user_entry = {"role": "user", "content": message}
|
156 |
messages.append(user_entry)
|
157 |
-
system_prompt = {"role": "system", "content": "
|
158 |
messages.insert(0, system_prompt)
|
159 |
async with async_timeout.timeout(GENERATION_TIMEOUT_SEC):
|
160 |
try:
|
|
|
154 |
|
155 |
user_entry = {"role": "user", "content": message}
|
156 |
messages.append(user_entry)
|
157 |
+
system_prompt = {"role": "system", "content": "あなたは日本語で答えるプログラム開発の優秀ななアシスタントです。"}
|
158 |
messages.insert(0, system_prompt)
|
159 |
async with async_timeout.timeout(GENERATION_TIMEOUT_SEC):
|
160 |
try:
|
routers/OpenInterpreter.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import shutil
|
2 |
+
import gradio as gr
|
3 |
+
from mysite.libs.utilities import chat_with_interpreter, completion, process_file
|
4 |
+
from interpreter import interpreter
|
5 |
+
import mysite.interpreter.interpreter_config # インポートするだけで設定が適用されます
|
6 |
+
import importlib
|
7 |
+
import os
|
8 |
+
import pkgutil
|
9 |
+
import async_timeout
|
10 |
+
import asyncio
|
11 |
+
|
12 |
+
|
13 |
+
DESCRIPTION = """
|
14 |
+
<div>
|
15 |
+
<h1 style="text-align: center;">develop site</h1>
|
16 |
+
<p>🦕 共同開発 AIシステム設定 LINE開発 CHATGPTS CHATGPTアシスタント設定 AI自動開発設定 APPSHEET GAS PYTHON</p>
|
17 |
+
</div>
|
18 |
+
<!-- Start of HubSpot Embed Code -->
|
19 |
+
<script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/46277896.js"></script>
|
20 |
+
<!-- End of HubSpot Embed Code -->
|
21 |
+
"""
|
22 |
+
|
23 |
+
LICENSE = """
|
24 |
+
<p/>
|
25 |
+
<!-- Start of HubSpot Embed Code -->
|
26 |
+
<script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/46277896.js"></script>
|
27 |
+
<!-- End of HubSpot Embed Code -->
|
28 |
+
---
|
29 |
+
Built with Meta Llama 3
|
30 |
+
"""
|
31 |
+
|
32 |
+
PLACEHOLDER = """
|
33 |
+
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
|
34 |
+
<img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8e75e61cc9bab22b7ce3dec85ab0e6db1da5d107/Meta_lockup_positive%20primary_RGB.jpg" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
|
35 |
+
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">Meta llama3</h1>
|
36 |
+
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Ask me anything...</p>
|
37 |
+
</div>
|
38 |
+
"""
|
39 |
+
|
40 |
+
|
41 |
+
# チャットインターフェースの関数定義
|
42 |
+
# def chat_with_interpreter(message):
|
43 |
+
# return "Response: " + message
|
44 |
+
|
45 |
+
|
46 |
+
# カスタムCSSの定義
|
47 |
+
css = """
|
48 |
+
.gradio-container {
|
49 |
+
height: 100vh; /* 全体の高さを100vhに設定 */
|
50 |
+
display: flex;
|
51 |
+
flex-direction: column;
|
52 |
+
}
|
53 |
+
.gradio-tabs {
|
54 |
+
flex: 1; /* タブ全体の高さを最大に設定 */
|
55 |
+
display: flex;
|
56 |
+
flex-direction: column;
|
57 |
+
}
|
58 |
+
.gradio-tab-item {
|
59 |
+
flex: 1; /* 各タブの高さを最大に設定 */
|
60 |
+
display: flex;
|
61 |
+
flex-direction: column;
|
62 |
+
overflow: hidden; /* オーバーフローを隠す */
|
63 |
+
}
|
64 |
+
.gradio-block {
|
65 |
+
flex: 1; /* ブロックの高さを最大に設定 */
|
66 |
+
display: flex;
|
67 |
+
flex-direction: column;
|
68 |
+
}
|
69 |
+
.gradio-chatbot {
|
70 |
+
height: 100vh; /* チャットボットの高さを100vhに設定 */
|
71 |
+
overflow-y: auto; /* 縦スクロールを有効にする */
|
72 |
+
}
|
73 |
+
"""
|
74 |
+
GENERATION_TIMEOUT_SEC = 60
|
75 |
+
# Gradio block
|
76 |
+
chatbot2 = gr.Chatbot(height=450, placeholder=PLACEHOLDER, label="Gradio ChatInterface")
|
77 |
+
|
78 |
+
with gr.Blocks(fill_height=True, css=css) as gradio_interface:
|
79 |
+
# gr.Markdown(DESCRIPTION)
|
80 |
+
# gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
|
81 |
+
gr.ChatInterface(
|
82 |
+
fn=completion,
|
83 |
+
chatbot=chatbot2,
|
84 |
+
fill_height=True,
|
85 |
+
additional_inputs_accordion=gr.Accordion(
|
86 |
+
label="⚙️ Parameters", open=False, render=False
|
87 |
+
),
|
88 |
+
additional_inputs=[
|
89 |
+
gr.Slider(
|
90 |
+
minimum=0,
|
91 |
+
maximum=1,
|
92 |
+
step=0.1,
|
93 |
+
value=0.95,
|
94 |
+
label="Temperature",
|
95 |
+
render=False,
|
96 |
+
),
|
97 |
+
gr.Slider(
|
98 |
+
minimum=128,
|
99 |
+
maximum=4096,
|
100 |
+
step=1,
|
101 |
+
value=512,
|
102 |
+
label="Max new tokens",
|
103 |
+
render=False,
|
104 |
+
),
|
105 |
+
],
|
106 |
+
examples=[
|
107 |
+
["HTMLのサンプルを作成して"],
|
108 |
+
[
|
109 |
+
"CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_sft.yaml"
|
110 |
+
],
|
111 |
+
],
|
112 |
+
cache_examples=False,
|
113 |
+
)
|
114 |
+
|
115 |
+
gr.Markdown(LICENSE)
|
routers/__init__.py
ADDED
File without changes
|
routers/ai/prompt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
|
|
1 |
+
google app script でLineのデータの取得がしたい
|
routers/document
ADDED
File without changes
|
routers/router.py
CHANGED
@@ -8,7 +8,7 @@ import os
|
|
8 |
import pkgutil
|
9 |
from routers.chat.chat import demo44 as demo4
|
10 |
from mysite.gradio.chat import chat
|
11 |
-
|
12 |
|
13 |
def include_gradio_interfaces():
|
14 |
package_dir = "/home/user/app/routers"
|
@@ -42,14 +42,6 @@ def include_gradio_interfaces():
|
|
42 |
|
43 |
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
#if __name__ == "__main__":
|
48 |
-
base_directory = "/home/user/app/routers" # Here you can specify any directory you want to explore
|
49 |
-
demo = build_interface(base_directory)
|
50 |
-
#demo.launch()
|
51 |
-
|
52 |
-
|
53 |
def setup_gradio_interfaces():
|
54 |
|
55 |
|
|
|
8 |
import pkgutil
|
9 |
from routers.chat.chat import demo44 as demo4
|
10 |
from mysite.gradio.chat import chat
|
11 |
+
from routers.postg.gradio_app import crud_interface
|
12 |
|
13 |
def include_gradio_interfaces():
|
14 |
package_dir = "/home/user/app/routers"
|
|
|
42 |
|
43 |
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
def setup_gradio_interfaces():
|
46 |
|
47 |
|