Spaces:
Running
on
Zero
Running
on
Zero
aaaaaaa
Browse files- ccccc.txt +0 -0
- chat_history.db +2 -2
- controllers/gra_02_openInterpreter/OpenInterpreter.py +37 -3
ccccc.txt
ADDED
File without changes
|
chat_history.db
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e5b1c00709344baaaf62b270c72c860e1ff6f73786f70ddb82689ad9ee77d341
|
3 |
+
size 1658880
|
controllers/gra_02_openInterpreter/OpenInterpreter.py
CHANGED
@@ -5,6 +5,30 @@ import mysite.interpreter.interpreter_config # インポートするだけで
|
|
5 |
import duckdb
|
6 |
#from logger import logger
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def format_response(chunk, full_response):
|
9 |
# Message
|
10 |
if chunk["type"] == "message":
|
@@ -12,11 +36,21 @@ def format_response(chunk, full_response):
|
|
12 |
if chunk.get("end", False):
|
13 |
full_response += "\n"
|
14 |
|
15 |
-
#
|
16 |
if chunk["type"] == "code":
|
|
|
|
|
|
|
17 |
if chunk.get("start", False):
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
if chunk.get("end", False):
|
21 |
full_response += "\n```\n"
|
22 |
|
|
|
5 |
import duckdb
|
6 |
#from logger import logger
|
7 |
|
8 |
+
def detect_language(code: str) -> str:
|
9 |
+
"""
|
10 |
+
簡易的な言語判別関数。
|
11 |
+
Python、Bash、HTML、CSSを判別する。
|
12 |
+
"""
|
13 |
+
python_keywords = ['import ', 'def ', 'class ', 'print(']
|
14 |
+
bash_keywords = ['ls ', 'cd ', 'mkdir ', 'echo ']
|
15 |
+
html_keywords = ['<html>', '<head>', '<body>']
|
16 |
+
css_keywords = ['width:', 'height:', 'color:']
|
17 |
+
|
18 |
+
if any(kw in code for kw in python_keywords):
|
19 |
+
return 'python'
|
20 |
+
elif any(kw in code for kw in bash_keywords):
|
21 |
+
return 'bash'
|
22 |
+
elif any(kw in code for kw in html_keywords):
|
23 |
+
return 'html'
|
24 |
+
elif any(kw in code for kw in css_keywords):
|
25 |
+
return 'css'
|
26 |
+
else:
|
27 |
+
return '' # 言語指定なし
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
def format_response(chunk, full_response):
|
33 |
# Message
|
34 |
if chunk["type"] == "message":
|
|
|
36 |
if chunk.get("end", False):
|
37 |
full_response += "\n"
|
38 |
|
39 |
+
# コードブロックの処理
|
40 |
if chunk["type"] == "code":
|
41 |
+
content = chunk.get("content", "")
|
42 |
+
language = detect_language(content)
|
43 |
+
|
44 |
if chunk.get("start", False):
|
45 |
+
if language:
|
46 |
+
full_response += f"```{language}\n"
|
47 |
+
else:
|
48 |
+
full_response += "```\n"
|
49 |
+
|
50 |
+
# バッククオートを削除
|
51 |
+
content = content.replace("`", "")
|
52 |
+
full_response += content
|
53 |
+
|
54 |
if chunk.get("end", False):
|
55 |
full_response += "\n```\n"
|
56 |
|