Spaces:
Runtime error
Runtime error
Joshua Sundance Bailey
commited on
Commit
·
f642d16
1
Parent(s):
bc3a159
messagesplaceholder; no-cache; timeout=30
Browse files
langchain-streamlit-demo/python_coder.py
CHANGED
|
@@ -10,6 +10,7 @@ from langchain.agents.tools import Tool
|
|
| 10 |
from langchain.llms.base import BaseLLM
|
| 11 |
from langchain.memory import ConversationBufferMemory
|
| 12 |
from langchain.prompts import ChatPromptTemplate
|
|
|
|
| 13 |
from langchain.pydantic_v1 import BaseModel, validator, Field, ValidationError
|
| 14 |
|
| 15 |
|
|
@@ -29,7 +30,7 @@ def format_black(filepath: str):
|
|
| 29 |
stderr=subprocess.STDOUT,
|
| 30 |
text=True,
|
| 31 |
shell=True,
|
| 32 |
-
timeout=
|
| 33 |
check=False,
|
| 34 |
)
|
| 35 |
|
|
@@ -37,19 +38,19 @@ def format_black(filepath: str):
|
|
| 37 |
def format_ruff(filepath: str):
|
| 38 |
"""Run ruff format on a file."""
|
| 39 |
subprocess.run( # nosec
|
| 40 |
-
f"ruff check --fix {filepath}",
|
| 41 |
shell=True,
|
| 42 |
text=True,
|
| 43 |
-
timeout=
|
| 44 |
universal_newlines=True,
|
| 45 |
check=False,
|
| 46 |
)
|
| 47 |
|
| 48 |
subprocess.run( # nosec
|
| 49 |
-
f"ruff format {filepath}",
|
| 50 |
stderr=subprocess.STDOUT,
|
| 51 |
shell=True,
|
| 52 |
-
timeout=
|
| 53 |
text=True,
|
| 54 |
check=False,
|
| 55 |
)
|
|
@@ -58,10 +59,10 @@ def format_ruff(filepath: str):
|
|
| 58 |
def check_ruff(filepath: str):
|
| 59 |
"""Run ruff check on a file."""
|
| 60 |
subprocess.check_output( # nosec
|
| 61 |
-
f"ruff check {filepath}",
|
| 62 |
stderr=subprocess.STDOUT,
|
| 63 |
shell=True,
|
| 64 |
-
timeout=
|
| 65 |
text=True,
|
| 66 |
)
|
| 67 |
|
|
@@ -75,7 +76,7 @@ def check_mypy(filepath: str, strict: bool = True, follow_imports: str = "skip")
|
|
| 75 |
stderr=subprocess.STDOUT,
|
| 76 |
shell=True,
|
| 77 |
text=True,
|
| 78 |
-
timeout=
|
| 79 |
)
|
| 80 |
|
| 81 |
|
|
@@ -148,6 +149,7 @@ prompt = ChatPromptTemplate.from_messages(
|
|
| 148 |
"Provide complete, end-to-end Python code to meet the user's description/requirements. "
|
| 149 |
"Always `check` your code. When you're done, you must ALWAYS use the `submit` tool.",
|
| 150 |
),
|
|
|
|
| 151 |
(
|
| 152 |
"human",
|
| 153 |
": {input}",
|
|
|
|
| 10 |
from langchain.llms.base import BaseLLM
|
| 11 |
from langchain.memory import ConversationBufferMemory
|
| 12 |
from langchain.prompts import ChatPromptTemplate
|
| 13 |
+
from langchain.prompts import MessagesPlaceholder
|
| 14 |
from langchain.pydantic_v1 import BaseModel, validator, Field, ValidationError
|
| 15 |
|
| 16 |
|
|
|
|
| 30 |
stderr=subprocess.STDOUT,
|
| 31 |
text=True,
|
| 32 |
shell=True,
|
| 33 |
+
timeout=30,
|
| 34 |
check=False,
|
| 35 |
)
|
| 36 |
|
|
|
|
| 38 |
def format_ruff(filepath: str):
|
| 39 |
"""Run ruff format on a file."""
|
| 40 |
subprocess.run( # nosec
|
| 41 |
+
f"ruff check --no-cache --fix {filepath}",
|
| 42 |
shell=True,
|
| 43 |
text=True,
|
| 44 |
+
timeout=30,
|
| 45 |
universal_newlines=True,
|
| 46 |
check=False,
|
| 47 |
)
|
| 48 |
|
| 49 |
subprocess.run( # nosec
|
| 50 |
+
f"ruff format --no-cache {filepath}",
|
| 51 |
stderr=subprocess.STDOUT,
|
| 52 |
shell=True,
|
| 53 |
+
timeout=30,
|
| 54 |
text=True,
|
| 55 |
check=False,
|
| 56 |
)
|
|
|
|
| 59 |
def check_ruff(filepath: str):
|
| 60 |
"""Run ruff check on a file."""
|
| 61 |
subprocess.check_output( # nosec
|
| 62 |
+
f"ruff check --no-cache {filepath}",
|
| 63 |
stderr=subprocess.STDOUT,
|
| 64 |
shell=True,
|
| 65 |
+
timeout=30,
|
| 66 |
text=True,
|
| 67 |
)
|
| 68 |
|
|
|
|
| 76 |
stderr=subprocess.STDOUT,
|
| 77 |
shell=True,
|
| 78 |
text=True,
|
| 79 |
+
timeout=30,
|
| 80 |
)
|
| 81 |
|
| 82 |
|
|
|
|
| 149 |
"Provide complete, end-to-end Python code to meet the user's description/requirements. "
|
| 150 |
"Always `check` your code. When you're done, you must ALWAYS use the `submit` tool.",
|
| 151 |
),
|
| 152 |
+
MessagesPlaceholder(variable_name="chat_history"),
|
| 153 |
(
|
| 154 |
"human",
|
| 155 |
": {input}",
|