Skip to content

Commit

Permalink
feat: add build package
Browse files Browse the repository at this point in the history
  • Loading branch information
imotai committed Sep 12, 2023
1 parent db8fc81 commit 65d27fb
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 43 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release_libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# .github/workflows/ci-cd.yml
on: workflow_dispatch
jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: self-hosted
#runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install dependencies
run: pip install -r requirements.txt

- name: build packages
run: |
TAG=${GITHUB_REF/refs\/tags\//}
VERSION=${TAG#*v}
bash build_package.sh ${VERSION}
- name: Publish Proto
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: proto/dist

- name: Publish Kernel
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: kernel/dist

- name: Publish Agent
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: agent/dist
- name: Publish Chat
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: chat/dist
8 changes: 3 additions & 5 deletions agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="octopus_agent",
version="0.1.2",
version="0.1.1",
description="Open source code interpreter agent for LLM",
author="imotai",
author_email="[email protected]",
Expand All @@ -33,14 +33,12 @@
install_requires=[
"octopus_proto",
"octopus_kernel",
"langchain>=0.0.227",
"langchain>=0.0.286",
"grpcio-tools>=1.57.0",
"grpc-google-iam-v1>=0.12.6",
"aiofiles",
"pydantic",
"python-dotenv",
"openai",
"aiosqlite",
"openai"
],
entry_points={
"console_scripts": [
Expand Down
11 changes: 2 additions & 9 deletions agent/src/octopus_agent/gpt_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
from langchain.tools import StructuredTool
from .tools import OctopusAPIMarkdownOutput
from typing import Any, Dict, List, Optional, Sequence, Union, Type
from pydantic import BaseModel, Field
from langchain.pydantic_v1 import BaseModel, Field
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)


class AskQuestionInput(BaseModel):
question: str = Field(description="the question")

Expand Down Expand Up @@ -58,12 +56,11 @@ class ExecutePythonCodeInput(BaseModel):
description="the saved filename list", default=[]
)


class ExecutePythonCodeTool(StructuredTool):
name = "execute_python_code"
description = """Execute arbitrary Python code Returns a Markdown format string including return code, result, stdout, stderr, error"""
args_schema: Type[BaseModel] = ExecutePythonCodeInput
octopus_api: OctopusAPIMarkdownOutput = None
octopus_api: Optional[OctopusAPIMarkdownOutput] = None

def _run(
self,
Expand All @@ -72,8 +69,6 @@ def _run(
saved_filenames: Optional[List[str]] = None,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
if not self.octopus_api:
self.octopus_api = OctopusAPIMarkdownOutput()
code = code
result = self.octopus_api.run(code)
return result
Expand All @@ -85,6 +80,4 @@ async def _arun(
saved_filenames: Optional[List[str]] = None,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
if not self.octopus_api:
self.octopus_api = OctopusAPIMarkdownOutput()
return await self.octopus_api.arun(code)
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ubuntu
RUN apt update
RUN apt install -y python3 python3-pip
RUN pip install -U octopus_agent octopus_kernel
5 changes: 5 additions & 0 deletions docker/Dockerfile_for_agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM octopus_base
WORKDIR /agent
VOLUME /agent
ADD start_agent.sh /agent/
CMD ["bash", "/agent/start_agent.sh"]
5 changes: 1 addition & 4 deletions docker/Dockerfile_for_kernel
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM python:3.11
ADD requirements_kernel.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN pip install octopus_proto octopus_kernel
FROM octopus_base
WORKDIR /kernel
VOLUME /kernel
ADD start_kernel.sh /kernel/
Expand Down
15 changes: 15 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
kernel:
env_file:
- kernel.env
image: octopus_kernel:latest
ports:
- '9527:9527'
agent:
image: octopus_agent:latest
env_file:
- agent.env
ports:
- '9528:9528'
depends_on:
- kernel
16 changes: 0 additions & 16 deletions docker/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docker/start_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# start_kernel.sh

echo "rpc_port=${rpc_port}" >.env
echo "rpc_host=127.0.0.1" >>.env
echo "rpc_host=0.0.0.0" >>.env
echo "admin_key=${admin_key}" >>.env
echo "llm_key=${llm_key}" >> .env
echo "max_file_size=20480000" >> .env
Expand Down
3 changes: 1 addition & 2 deletions docker/start_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
echo "config_root_path=/kernel" >.env
echo "workspace=${workspace}" >>.env
echo "rpc_port=${rpc_port}" >>.env
echo "rpc_host=127.0.0.1" >>.env
echo "rpc_host=0.0.0.0" >>.env
echo "rpc_key=${rpc_key}" >>.env

octopus_kernel_rpc_server
Binary file added images/octopus_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion kernel/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="octopus_kernel",
version="0.1.2",
version="0.1.3",
description="Open source code interpreter agent for LLM",
author="imotai",
author_email="[email protected]",
Expand Down
4 changes: 3 additions & 1 deletion kernel/tests/kernel_sdk_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def kernel_sdk():
endpoint = (
"localhost:9527" # Replace with the actual endpoint of your test gRPC server
)
return KernelSDK(endpoint, "ZCeI9cYtOCyLISoi488BgZHeBkHWuFUH")
#return KernelSDK(endpoint, "ZCeI9cYtOCyLISoi488BgZHeBkHWuFUH")
return KernelSDK(endpoint, "z7XRkTTBkXifyCAa5rAQfabeTxtFqrVz")



@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion proto/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="octopus_proto",
version="0.1.2",
version="0.1.3",
description="Open source code interpreter agent for LLM",
author="imotai",
author_email="[email protected]",
Expand Down
4 changes: 1 addition & 3 deletions start_sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ cd ${WORKDIR}/chat && pip install .
mkdir -p ${WORKDIR}/sandbox/kernel
mkdir -p ${WORKDIR}/sandbox/agent
cd ${WORKDIR}/sandbox/kernel
#KERNEL_RPC_KEY=`tr -dc A-Za-z0-9 </dev/urandom | head -c 32; echo ""`
KERNEL_RPC_KEY=ZCeI9cYtOCyLISoi488BgZHeBkHWuFUH
echo ${KERNEL_RPC_KEY}
echo "config_root_path=/tmp/kernel_config"> .env
Expand All @@ -24,7 +23,6 @@ echo "start kernel with endpoint 127.0.0.1:9527"
octopus_kernel_rpc_server > kernel_rpc.log 2>&1 &
sleep 2
cd ${WORKDIR}/sandbox/agent
#AGENT_RPC_KEY=`tr -dc A-Za-z0-9 </dev/urandom | head -c 32; echo ""`
AGENT_RPC_KEY=ZCeI9cYtOCyLISoi488BgZHeBkHWuFUH
echo "start agent with endpoint 127.0.0.1:9528"
echo "rpc_host=127.0.0.1">> .env
Expand All @@ -36,4 +34,4 @@ echo "verbose=True" >> .env
octopus_agent_rpc_server > agent_rpc.log 2>&1 &
sleep 2
echo "add a kernel"
octopus_agent_setup --kernel_endpoint=127.0.0.1:9527 --kernel_api_key=${KERNEL_RPC_KEY} --kernel_workspace=/tmp/ws1 --agent_endpoint=127.0.0.1:9528 --admin_key=${AGENT_RPC_KEY}
octopus_agent_setup --kernel_endpoint=127.0.0.1:9527 --kernel_api_key=${KERNEL_RPC_KEY} --agent_endpoint=127.0.0.1:9528 --admin_key=${AGENT_RPC_KEY}

0 comments on commit 65d27fb

Please sign in to comment.