Giter VIP home page Giter VIP logo

codebox-api's Introduction

Hi there πŸ‘‹

πŸ‘¨β€πŸ’» I'm Dominic and like working with AI.

Projects:

Coming soon:

  • autocodr - automatic coding using LLM Agents

πŸ“« How to reach me: @shroominic or [email protected]

codebox-api's People

Contributors

astelmach01 avatar goudete avatar juananpe avatar preritdas avatar shroominic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

codebox-api's Issues

Example API key error

When running the example in the readme using codeboxapi 0.0.9, Python 3.11.4:

import codeboxapi as cb

cb.set_api_key("sk-xxxxxx")
# or put your api key inside the .env file
# CODEBOX_API_KEY=your-api-key

# create and startup
codebox = CodeBox()
codebox.start()

# check if it's running
print(codebox.status() == "running")

# run some code
result = codebox.run("print('Hello, World!')")

# print the result
print(result)

codebox.stop()

I'm getting the following error:

AttributeError: partially initialized module 'codeboxapi' has no attribute 'set_api_key' (most likely due to a circular import)

Additionally CodeBox is not referenced before.

AttributeError: Replace __dict__ access in CIMultiDictProxy with items() method

This code:

headers=response.headers.__dict__,

is yielding the following error:
AttributeError: 'multidict._multidict.CIMultiDictProxy' object has no attribute '__dict__'

You can reproduce the error setting CODEBOX_API_KEY to anything but a correct key (even an empty value) in the .env file.

It seems that response.headers is an instance of the CIMultiDictProxy class and that class doesn't have a __dict__ attribute because it is not a standard Python dictionary.

My suggestion would be to replace this line:
headers=response.headers.__dict__,
with the equivalent
headers=dict(response.headers.items()),

Instructions for setting up LocalBox

Could you kindly provide the detailed instructions for using LocalBox for testing purposes? Currently, it requires WebSockets too which I am not sure why and how to setup?

localbox 8888 port exit

How can i use localbox to do a server and provide API.I got the question, when i start the localbox in the container, after some runs
, it will exit, and the 8888 port will be closed, how can I keep the 8888 port alive

KeyError: 'id'

Hello,
I've encountered a KeyError: 'id' when attempting to get access to openai gpt4. Below is a brief description of the issue

Traceback (most recent call last): File "D:\Research\GPT4\process.py", line 101, in <module> main() File "D:\Research\GPT4\process.py", line 93, in main process_prompt(lines[i]) File "D:\Research\GPT4\process.py", line 70, in process_prompt result = call_gpt4_api(line) File "D:\Research\GPT4\process.py", line 42, in call_gpt4_api with CodeInterpreterSession(verbose=True) as session: File "C:\Users\DELL\anaconda3\envs\gpt\lib\site-packages\codeinterpreterapi\session.py", line 481, in __enter__ self.start() File "C:\Users\DELL\anaconda3\envs\gpt\lib\site-packages\codeinterpreterapi\session.py", line 89, in start status = SessionStatus.from_codebox_status(self.codebox.start()) File "C:\Users\DELL\anaconda3\envs\gpt\lib\site-packages\codeboxapi\box\localbox.py", line 107, in start self._connect() File "C:\Users\DELL\anaconda3\envs\gpt\lib\site-packages\codeboxapi\box\localbox.py", line 116, in _connect self.kernel_id = response.json()["id"]

404 Error with API

I am currently getting a 404 error with any Codebox endpoint. I tried accessing the endpoints through the browser as well, and other devices, and theyre all returning 404. I set my key in the env file and it is being recognized when I print it. Below is the error log:

Traceback (most recent call last): [1] File "/Users/salvatorenoto/Documents/Official/fileunit/fileunit-official/api/index.py", line 29, in run_interpreter [1] await session.astart() [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeinterpreterapi/session.py", line 32, in astart [1] await self.codebox.astart() [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeboxapi/box/codebox.py", line 34, in astart [1] return await self.astatus() [1] ^^^^^^^^^^^^^^^^^^^^ [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeboxapi/box/codebox.py", line 75, in astatus [1] ** await self.acodebox_request( [1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeboxapi/box/codebox.py", line 58, in acodebox_request [1] return await abase_request( [1] ^^^^^^^^^^^^^^^^^^^^ [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeboxapi/utils.py", line 87, in abase_request [1] return await handle_response_async(response) [1] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/codeboxapi/utils.py", line 51, in handle_response_async [1] raise Exception(f"Error: {response.status} {await response.text()}") [1] Exception: Error: 404 {"detail":"Codebox not found"}

Also tested with HTTPie:
Screenshot 2023-08-01 at 9 35 08 PM

How to get image of kernel execution?

Is there a parameter for the kernel to set --matplotlib=inline, so that the image is not directly output, like this.
kernel_process = subprocess. Popen(
[
sys.executable,
launch_kernel_script_path,
"--IPKernelApp.connection_file",
kernel_connection_file,
"--matplotlib=inline",
"--quiet",
],
cwd='workspace/'
)
image

CodeBoxOutput is not completed

Let's say python code as fllowing:

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

data = pd.read_csv('/mnt/data/train_data.csv')


data['label'].value_counts().plot(kind='bar')
plt.show()


X = data.drop('label', axis=1)
y = data['label']


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)


dt_model = DecisionTreeClassifier()
dt_model.fit(X_train, y_train)


y_pred = dt_model.predict(X_test)


print("accuracy: ", accuracy_score(y_test, y_pred))

This code snippet will generate 2 outputs: plt.show() and print(οΌ‰. According to this code,codebox-api will return on first output (plt.show()),and it seems the remaining code will not be executed.

So how can I get codebox-api to return both outputs(image/png and text)?

#edit1 typo

Start the codebox with the requirements.txt

Thanks for sharing your project but I found that when run LLM it always installing some package at first and consuming unnecessary tokens, is it possible to start the codebox (localbox is oke) with pre-defined list of packages in requirements.txt file for example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.