You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""You are a coding assistant. Ensure any code you provide can be executed with all required imports and variables defined. Structure your answer: 1) a prefix describing the code solution, 2) the imports, 3) the functioning code block.
29
+
\n Here is the user question:""",
30
+
),
31
+
("placeholder", "{messages}"),
32
+
]
33
+
)
34
+
35
+
# Define the data model
36
+
classcode(BaseModel):
37
+
"""Code output"""
38
+
39
+
prefix: str=Field(description="Description of the problem and approach")
error_message= [("user", f"Your solution failed the import test. Here is the error: {e}. Reflect on this error and your prior attempt to solve the problem. (1) State what you think went wrong with the prior solution and (2) try to solve this problem again. Return the FULL SOLUTION. Use the code tool to structure the output with a prefix, imports, and code block:")]
129
+
messages+=error_message
130
+
return {
131
+
"generation": code_solution,
132
+
"messages": messages,
133
+
"iterations": iterations,
134
+
"error": "yes",
135
+
}
136
+
137
+
# Check execution
138
+
try:
139
+
combined_code=f"{imports}\n{code}"
140
+
# Use a shared scope for exec
141
+
global_scope= {}
142
+
exec(combined_code, global_scope)
143
+
exceptExceptionase:
144
+
print("---CODE BLOCK CHECK: FAILED---")
145
+
error_message= [("user", f"Your solution failed the code execution test: {e}) Reflect on this error and your prior attempt to solve the problem. (1) State what you think went wrong with the prior solution and (2) try to solve this problem again. Return the FULL SOLUTION. Use the code tool to structure the output with a prefix, imports, and code block:")]
# from langchain_experimental.utilities import PythonREPL
3
+
# from langchain_community.tools.ddg_search.tool import DuckDuckGoSearchRun
4
+
# from langchain_core.tools import Tool
5
+
# from langchain_groq import ChatGroq
6
+
7
+
# # Create the Python REPL tool
8
+
# python_repl = PythonREPL()
9
+
# python_repl_tool = Tool(
10
+
# name="python_repl",
11
+
# description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.",
12
+
# func=python_repl.run,
13
+
# )
14
+
15
+
# # Create the DuckDuckGo search tool
16
+
# duckduckgo_search = DuckDuckGoSearchRun()
17
+
# duckduckgo_search_tool = Tool(
18
+
# name="duckduckgo_search",
19
+
# description="A wrapper around DuckDuckGo Search. Useful for when you need to answer questions about current events. Input should be a search query.",
description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.",
73
+
func=python_repl.run,
74
+
)
75
+
76
+
# Create the DuckDuckGo search tool
77
+
duckduckgo_search=DuckDuckGoSearchRun()
78
+
duckduckgo_search_tool=Tool(
79
+
name="duckduckgo_search",
80
+
description="A wrapper around DuckDuckGo Search. Useful for when you need to answer questions about current events and internet Search related queries. Input should be a search query.",
description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.",
12
+
func=python_repl.run,
13
+
)
14
+
15
+
# Create the DuckDuckGo search tool
16
+
duckduckgo_search=DuckDuckGoSearchRun()
17
+
duckduckgo_search_tool=Tool(
18
+
name="duckduckgo_search",
19
+
description="A wrapper around DuckDuckGo Search. Useful for when you need to answer questions about current events. Input should be a search query.",
0 commit comments