# 200 Error code

**URL:** <https://community.sambanova.ai/t/200-error-code/729>\
**Category:** Discussion\
**Tags:** dev\
**Created:** [December 5, 2024, 3:35am UTC](https://community.sambanova.ai/t/200-error-code/729 "2024-12-05T03:35:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MigMan](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@MigMan](https://community.sambanova.ai/u/MigMan)\
**Post date:** [December 5, 2024, 3:35am UTC](https://community.sambanova.ai/t/200-error-code/729/1 "2024-12-05T03:35:02Z")

</div>

this is what is being passed: [{‘role’: ‘user’, ‘content’: ‘You are to follow these instructions: Your role is to run both c++, an python code given to you\n Question: `cpp\n#include <iostream>\n\n// Function to calculate the sum of two numbers\nint calculateSum(int a, int b) {\n return a + b;\n}\n\nvoid test_calculateSum_positiveNumbers() {\n int result = calculateSum(2, 3);\n std::cout << "Test calculateSum with positive numbers: " << (result == 5 ? "Passed" : "Failed") << std::endl;\n}\n\nvoid test_calculateSum_negativeNumbers() {\n int result = calculateSum(-2, -3);\n std::cout << "Test calculateSum with negative numbers: " << (result == -5 ? "Passed" : "Failed") << std::endl;\n}\n\nvoid test_calculateSum_mixedNumbers() {\n int result = calculateSum(-2, 3);\n std::cout << "Test calculateSum with mixed numbers: " << (result == 1 ? "Passed" : "Failed") << std::endl;\n}\n\nvoid test_calculateSum_zero() {\n int result = calculateSum(0, 0);\n std::cout << "Test calculateSum with zeros: " << (result == 0 ? "Passed" : "Failed") << std::endl;\n}\n\nvoid test_calculateSum_largeNumbers() {\n int result = calculateSum(2000, 3000);\n std::cout << "Test calculateSum with large numbers: " << (result == 5000 ? "Passed" : "Failed") << std::endl;\n}\n\nint main() {\n test_calculateSum_positiveNumbers();\n test_calculateSum_negativeNumbers();\n test_calculateSum_mixedNumbers();\n test_calculateSum_zero();\n test_calculateSum_largeNumbers();\n\n return 0;\n}\n`’}]  
\<Response [200]\>  
{‘error’: {‘code’: None, ‘message’: ‘unexpected\_error’, ‘param’: None, ‘type’: ‘unexpected\_error’}}

Using Sambanova for function calling but keep receiving an unknown error.

my code:

def generate(self, question):  
final\_instruction = self.instruct + f"\n Question: {question}"  
print(“Final Instruction:”, final\_instruction)  
if self.functionCaller:  
response = self.llm.invoke(final\_instruction)  
message =“”  
print(f"Tool outputs{response.tool\_calls}“)  
for tool\_call in response.tool\_calls:  
selected\_tool = self.tools[tool\_call[“name”]]  
tool\_output = selected\_tool.invoke(tool\_call[“args”])  
print(f"Tool output: {tool\_output}”)  
message = message + tool\_output  
return message  
else:  
print(final\_instruction)  
response = self.llm.invoke(final\_instruction)  
return response

Tools:  
from langchain\_core.tools import StructuredTool, Tool, ToolException, tool  
from pydantic import BaseModel, Field  
import os  
import subprocess  
import tempfile  
import json  
import re

class CodeInput(BaseModel):  
code : str = Field(…, description=“This is code either c code or python code”)

C\_INCLUDE\_TO\_PACKAGE = {  
# Add mappings if needed for non-standard headers  
‘boost/’: ‘libboost-all-dev’,  
}

def find\_c\_dependencies(code: str):  
includes = re.findall(r’#include\s\*\<"["\>]', code)  
needed\_packages = set()  
for inc in includes:  
for key, pkg in C\_INCLUDE\_TO\_PACKAGE.items():  
if key in inc:  
needed\_packages.add(pkg)  
return needed\_packages

def install\_dependencies(packages):  
if not packages:  
return

```
pass

```

def uninstall\_dependencies(packages):

```
pass

```

@tool  
def run\_c(c\_code: CodeInput):  
“”"  
Runs given C++ code. Detects which libraries the code uses,  
installs them before compilation, and then cleans up after.  
“”"  
packages = find\_c\_dependencies(c\_code.code)  
install\_dependencies(packages)

```
# Use .cpp extension to ensure code is compiled as C++
filep = tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.cpp', prefix='test')
executable = filep.name.replace('.cpp', '')
try:
    with open(filep.name, 'w') as file:
        file.write(c_code.code)

    compile_process = subprocess.run(['g++', filep.name, '-o', executable, '-std=c++17'],
                                     capture_output=True, text=True)
    if compile_process.returncode != 0:
        raise Exception(f"Compilation failed:\n{compile_process.stderr}")

    run_process = subprocess.run([executable], capture_output=True, text=True)
    if run_process.returncode != 0:
        raise Exception(f"Execution failed:\n{run_process.stderr}")

    return run_process.stdout
finally:
    if os.path.exists(filep.name):
        os.unlink(filep.name)
    if os.path.exists(executable):
        os.unlink(executable)
    uninstall_dependencies(packages)

```

@tool  
def run\_py(py\_code: CodeInput):  
“”"  
Runs given Python code  
“”"  
filep = tempfile.NamedTemporaryFile(delete=False, mode=‘w’, suffix=‘.py’, prefix=‘test’)  
try:  
with open(filep.name, ‘w’) as file:  
file.write(py\_code.code)  
executable = filep.name  
run\_process = subprocess.run([“python3”, executable], capture\_output=True, text=True)  
if run\_process.returncode != 0:  
raise Exception(f"Execution failed:\n{run\_process.stderr}")  
return run\_process.stdout  
finally:  
os.unlink(executable)

---

<div class="post-metadata">

**Author:** ![prajwal.balapure](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@prajwal.balapure](https://community.sambanova.ai/u/prajwal.balapure)\
**Post date:** [December 5, 2024, 4:56am UTC](https://community.sambanova.ai/t/200-error-code/729/2 "2024-12-05T04:56:14Z")

</div>

Hi,

Thank you for the details provided. We will proceed with reviewing the issue thoroughly and offer a comprehensive solution to help resolve the problem efficiently. Please feel free to share any further details or questions you may have in the meantime.

Thanks,  
Prajwal

---

<div class="post-metadata">

**Author:** ![MigMan](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@MigMan](https://community.sambanova.ai/u/MigMan)\
**Post date:** [December 5, 2024, 4:18pm UTC](https://community.sambanova.ai/t/200-error-code/729/3 "2024-12-05T16:18:43Z")

</div>

I think this may be with my usage rates. I ran the code this morning twice. The first run I was able to get to the 5th call in my agentic system, but the second time I did not. Specifically at responses[“resultC”] = node2.generate(responses[“unitC”].content).  
node 2 is a tool calling agent

```
responses["translation"] = node1.generate(code)
responses["run"] = node2.generate(responses["translation"])
responses["unitC"] = node3.generate(code)

responses["unitPy"] = node1.generate(responses["unitC"].content)
responses["resultC"] = node2.generate(responses["unitC"].content)
responses["resultP"] = node2.generate(responses["unitPy"].content)

```

---

<div class="post-metadata">

**Author:** ![MigMan](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@MigMan](https://community.sambanova.ai/u/MigMan)\
**Post date:** [December 5, 2024, 5:13pm UTC](https://community.sambanova.ai/t/200-error-code/729/5 "2024-12-05T17:13:00Z")

</div>

put a two minute sleep on each request did not fix the problem

I am also using this as the llm  
from langchain\_community.chat\_models.sambanova import ChatSambaNovaCloud
