Spaces:
Sleeping
Sleeping
update
Browse files
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:f44953968fac540f03d40a83a363a2fe6003c62e5cc084f782fdb68a5e047492
|
3 |
+
size 1662976
|
controllers/gra_02_openInterpreter/OpenInterpreter.py
CHANGED
@@ -5,28 +5,6 @@ import mysite.interpreter.interpreter_config # インポートするだけで
|
|
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):
|
@@ -36,21 +14,11 @@ def format_response(chunk, full_response):
|
|
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 |
-
|
46 |
-
|
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 |
|
|
|
5 |
import duckdb
|
6 |
#from logger import logger
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
def format_response(chunk, full_response):
|
|
|
14 |
if chunk.get("end", False):
|
15 |
full_response += "\n"
|
16 |
|
17 |
+
# Code
|
18 |
if chunk["type"] == "code":
|
|
|
|
|
|
|
19 |
if chunk.get("start", False):
|
20 |
+
full_response += "```python\n"
|
21 |
+
full_response += chunk.get("content", "").replace("`", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
if chunk.get("end", False):
|
23 |
full_response += "\n```\n"
|
24 |
|