Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
aba9a92
feat: container providers can bind additional contracts
thirdgerb Oct 5, 2024
3ddc9c6
feat: Storage contract add FileStorage that contains abspath
thirdgerb Oct 5, 2024
86e9a03
dev: make workspace based on file storage that it can detect root pat…
thirdgerb Oct 5, 2024
2a82717
dev: poetry add streamlit package
thirdgerb Oct 5, 2024
521b4c0
dev: test streamlit about it's basic features
thirdgerb Oct 5, 2024
1f8b447
dev: aifunc streamlit app test
thirdgerb Oct 5, 2024
537bcb3
dev: add streamlit config to app directory
thirdgerb Oct 5, 2024
9868ef3
refact: move ghostos/app to root directory, and remove poetry.lock
thirdgerb Oct 7, 2024
512b35f
dev: container add global static container
thirdgerb Oct 7, 2024
c566639
feat: fix poetry dependencies and add streamlit-react-jsonschema
thirdgerb Oct 7, 2024
cabfd3b
feat: modification about container
thirdgerb Oct 7, 2024
5379578
feat: container add get_bound and Contracts
thirdgerb Oct 7, 2024
fb752a7
refact: define a open-box ready app directory
thirdgerb Oct 7, 2024
2ae428d
dev: more streamlit tests, and prepare remove ghostos.demo later
thirdgerb Oct 7, 2024
e2f0092
del: remove miss-committing test code
thirdgerb Oct 7, 2024
05ee928
dev: rename ghostos_apps.py to ghostos_bootstrap.py
thirdgerb Oct 8, 2024
89f99f7
dev: refact the structure for better open-box usage yet another time
thirdgerb Oct 8, 2024
56aedce
refact: move clear_runtime script from ghostos.demo to ghostos.scripts
thirdgerb Oct 8, 2024
632046a
refact: rename ghostos.__init__ to ghostos.bootstrap, remove streamli…
thirdgerb Oct 8, 2024
50e1ecc
dev: setup streamlit app skeleton
thirdgerb Oct 8, 2024
7f225f7
dev: prepare app structure
thirdgerb Oct 9, 2024
393427f
dev: add EntityFactory to application root providers
thirdgerb Oct 9, 2024
2d38521
fix: fix container bootstrap provider even it is override by other re…
thirdgerb Oct 9, 2024
4e70bd7
feat: huge modification about AIFunc
thirdgerb Oct 9, 2024
0fd1375
dev: rename AIFuncManager to AIFuncExecutor
thirdgerb Oct 10, 2024
0555b9c
dev: Modules add iter_modules method
thirdgerb Oct 10, 2024
802155f
dev: configs add save method
thirdgerb Oct 10, 2024
29275e4
dev: fulfill aifunc repository develop but not test yet
thirdgerb Oct 10, 2024
e5c4563
refact: rename Message.pack to Message.chunk
thirdgerb Oct 10, 2024
104525a
dev: messenger comments and modifications
thirdgerb Oct 10, 2024
3d73b5d
refact: rename processes and tasks for less confusing
thirdgerb Oct 11, 2024
484ce28
dev: try to implement duplex stream connection
thirdgerb Oct 11, 2024
bb86cd5
dev: add userinfo class but not decide to use it yet
thirdgerb Oct 11, 2024
891856d
dev: pool add new function and submit return future
thirdgerb Oct 11, 2024
f608ef4
feat: develop stream receiver and test them, fix a ton of issues
thirdgerb Oct 12, 2024
1273cd7
refact: rename GhostProcess to session process, make myself busy looking
thirdgerb Oct 12, 2024
4bd7475
dev: AIFunc refaction raw test passed. aifunc streamlit app is next t…
thirdgerb Oct 13, 2024
1f4e745
fix: fix AIFuncExecutor destroy parent container.
thirdgerb Oct 13, 2024
c18ab99
test: test more features about streamlit
thirdgerb Oct 13, 2024
b7d08cd
fix: aifunc debug and fix some. far not enough
thirdgerb Oct 13, 2024
40429d3
dev: add abstract class designings
thirdgerb Oct 14, 2024
84ccc40
feat: enrich identifier
thirdgerb Oct 14, 2024
620f030
refact: refact ghostos.abc to ghostos.common, in case of conflict to …
thirdgerb Oct 14, 2024
21399b4
fix: fix invalid identifier name
thirdgerb Oct 14, 2024
781b4ea
dev: message redesign for streaming and receiving
thirdgerb Oct 16, 2024
0dc8883
dev: develop new stream and receiver, replace old one later
thirdgerb Oct 18, 2024
9704ca1
feat: move workspace from ghosts to contracts
thirdgerb Oct 18, 2024
03908b3
dev: add translation for i18n usage. but not fit the gettext now. tod…
thirdgerb Oct 18, 2024
fb64a75
dev: aifunc related developments
thirdgerb Oct 19, 2024
0dff7ac
feat: develop aifunc streamlit pages, in purpose of working through a…
thirdgerb Oct 20, 2024
da06415
test: test about asyncio
thirdgerb Oct 24, 2024
47c3e47
dev: use dqueue for transport receiver
thirdgerb Oct 24, 2024
4516451
dev: save current work about realtime agent, in case reset --hard HEA…
thirdgerb Oct 25, 2024
df9c87c
dev: add some logger helper for me
thirdgerb Oct 26, 2024
e8f7769
dev: save realtime agent implementations
thirdgerb Oct 26, 2024
9ea4765
dev: save new ghost pattern, not affordable lose it
thirdgerb Oct 26, 2024
9d42ac7
dev: map my thoughts and reduce them
thirdgerb Oct 29, 2024
8319686
dev: map recent devlopment, reduce them later. due to personal issues…
thirdgerb Nov 5, 2024
e4cc3d1
dev: saving processing mass refactoring
thirdgerb Nov 8, 2024
5e7f599
dev: refact moss make it simpler
thirdgerb Nov 9, 2024
c0e30a2
dev: seperate moss injected prompters
thirdgerb Nov 10, 2024
192b61b
dev: update prompter with test
thirdgerb Nov 10, 2024
ab65fd4
dev: fix aifunc imported libraries
thirdgerb Nov 10, 2024
68807d1
dev: fix llms test case
thirdgerb Nov 10, 2024
689c47e
dev: update moss agent in new pattern
thirdgerb Nov 11, 2024
2aa5d0c
dev: update messages catch up to changes
thirdgerb Nov 11, 2024
0e1809a
dev: implements llm changes
thirdgerb Nov 11, 2024
857250d
dev: update messenger and llm to recent refact
thirdgerb Nov 11, 2024
d850ea7
dev: update threads related code
thirdgerb Nov 11, 2024
bf2e0e1
dev: update tasks and test baseline
thirdgerb Nov 11, 2024
8d79eef
fix: fix all the test cases
thirdgerb Nov 11, 2024
94bdf8c
dev: define subclass of prompter for flexibilities
thirdgerb Nov 12, 2024
4b11cee
dev: new session implementaion
thirdgerb Nov 12, 2024
ed42ca2
dev: implements ghostos, start test in two days
thirdgerb Nov 13, 2024
ad7fb83
dev: implements variable message
thirdgerb Nov 14, 2024
4909c7a
dev: implements subtasks, close to test
thirdgerb Nov 14, 2024
b4f6524
dev: make sure root container can run
thirdgerb Nov 14, 2024
e15fd88
dev: remove v1 designing of ghost by great courage
thirdgerb Nov 15, 2024
98d50e4
test: test about moss runtime gc and success with joy
thirdgerb Nov 15, 2024
160d2d4
dev: save prompt in yaml pattern
thirdgerb Nov 15, 2024
61b9687
dev: update session with system log
thirdgerb Nov 15, 2024
4c5cf55
dev: streamlit app test run and parse args
thirdgerb Nov 16, 2024
c121347
dev: refact streamlit app structure, ready for script testing
thirdgerb Nov 16, 2024
ebba182
dev: complete streamlit aifunc script for agent talk test
thirdgerb Nov 16, 2024
72d0c50
dev: container inherit none singleton provider from parent so that pa…
thirdgerb Nov 17, 2024
b0a41fc
dev: ghost driver add get providers
thirdgerb Nov 17, 2024
2f4f8db
dev: implement simplest chatbot with thought, prepering for testing
thirdgerb Nov 17, 2024
ec8e0e6
fix: fix import errors
thirdgerb Nov 17, 2024
e7fa71b
dev: import llmlite is super slow, check it later
thirdgerb Nov 17, 2024
3387bdb
dev: add run console script
thirdgerb Nov 17, 2024
7a796e2
dev: script debug test pass through and fix some bugs. left small det…
thirdgerb Nov 17, 2024
2e62d13
fix: fix stream and messenger duplicated complete message, and logs
thirdgerb Nov 18, 2024
074a0b9
dev: run console app success, bugs to fix later
thirdgerb Nov 18, 2024
8e6c4bf
dev: console app is successfully running
thirdgerb Nov 18, 2024
263f70a
dev: create memory abstract class designing
thirdgerb Nov 18, 2024
5dd1ad5
dev: console app add background run. streamlit app to go
thirdgerb Nov 18, 2024
6972ae5
dev: create streamlit ghost chat script and page. fulfill it tommorow
thirdgerb Nov 18, 2024
25aabda
dev: ghost chat is near complete, message renderer to go
thirdgerb Nov 19, 2024
b3484f9
dev: prepare for final streaming rendering
thirdgerb Nov 20, 2024
a72143e
dev: complete basic chat page, very simple but ok to run
thirdgerb Nov 21, 2024
e144063
dev: achieve moss agent but so many bugs to fix:
thirdgerb Nov 22, 2024
7307d3e
dev: the streamlitapp baseline test is complete, fix styling and stre…
thirdgerb Nov 24, 2024
266c307
dev: add instruction to conversation and streamlit app page
thirdgerb Nov 24, 2024
dc2690c
fix: fix unittests
thirdgerb Nov 24, 2024
dae1c32
dev: implements sphero gpt, some bugs occur
thirdgerb Nov 24, 2024
e3f31a4
dev: fix sphero gpt bugs from session and conversation. more tests to go
thirdgerb Nov 26, 2024
d8cd989
fix: fix messenger and parser bugs. messages designing is too complex…
thirdgerb Nov 26, 2024
bb13171
dev: implements vision of gpt-4o
thirdgerb Nov 27, 2024
57c4d48
dev: add image upload and paste
thirdgerb Nov 27, 2024
91449d4
dev: shell add thread mutex when checking closed conversation
thirdgerb Nov 28, 2024
861366d
dev: optimize close logic a little. I'm still not familiar to python …
thirdgerb Nov 28, 2024
0cf1215
fix: fix missing charactor
thirdgerb Nov 28, 2024
640a976
dev: move sphero dependencies to sphero group
thirdgerb Nov 28, 2024
d502c0b
dev: add audio messages
thirdgerb Nov 30, 2024
e819917
fix: fix methods forgot to delete
thirdgerb Nov 30, 2024
b1a3780
dev: save realtime developing code
thirdgerb Dec 2, 2024
708d029
fix: fix sphero gpt command lines with indent spaces error
thirdgerb Dec 2, 2024
6d6737e
dev: save realtime development, test tomorrow
thirdgerb Dec 4, 2024
a451a3f
dev: first test round of openai realtime
thirdgerb Dec 5, 2024
a742efd
fix: fix message bug
thirdgerb Dec 6, 2024
2b65afb
fix: fix streamlit message rendering
thirdgerb Dec 6, 2024
9fcb4fa
feat: add force create conversation
thirdgerb Dec 6, 2024
88247ff
dev: optimize streamlit message outputs
thirdgerb Dec 6, 2024
4bdea68
dev: optimize streamlit app message render
thirdgerb Dec 6, 2024
5ed26fc
dev: complete new sphero shell interface
thirdgerb Dec 7, 2024
6d1115e
feat: complete sphero v2
thirdgerb Dec 8, 2024
46d9700
dev: save development of sphero gpt tests
thirdgerb Dec 9, 2024
3c91d45
fix: fix some spherogpt test bugs
thirdgerb Dec 9, 2024
cd0ecd5
dev: update spherogpt and fix bugs. continue realtime developing later
thirdgerb Dec 9, 2024
5cfe72c
fix: hotfix for truncate thread
thirdgerb Dec 11, 2024
15bc37a
dev: complete realtime but fight with openai realtime beta bugs
thirdgerb Dec 17, 2024
5b66b08
dev: realtime api pass baseline tests
thirdgerb Dec 17, 2024
eb94644
dev: prepare docs and ready to test as package
thirdgerb Dec 19, 2024
ec60922
dev: add dist to ignore
thirdgerb Dec 19, 2024
4dde9ad
dev: clear ghostos demo directory
thirdgerb Dec 19, 2024
4c271ed
dev: test package scripts
thirdgerb Dec 19, 2024
f360c9a
dev: fix scripts
thirdgerb Dec 19, 2024
6a678ef
dev: add intend to clear runtime
thirdgerb Dec 19, 2024
da26f85
dev: implement ghostos config
thirdgerb Dec 20, 2024
5a36628
dev: test default truncate and use it on streamlit web ui
thirdgerb Dec 20, 2024
0fcf1fd
dev: openai realtime tests, near end
thirdgerb Dec 20, 2024
19117c0
dev: passed sphero gpt realtime tests
thirdgerb Dec 20, 2024
cff47a7
dev: test and fix realtime bugs
thirdgerb Dec 21, 2024
bdf6dd9
dev: preparing beta version docs
thirdgerb Dec 22, 2024
758f82a
dev: update zh-cn docs
thirdgerb Dec 22, 2024
3c437a7
dev: upgrade first version docs
thirdgerb Dec 22, 2024
26cd2fa
fix: fix image links
thirdgerb Dec 22, 2024
f656129
dev: fix docs image url
thirdgerb Dec 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ide
.idea/
dist
debug.log
.DS_Store
*.thread.yml
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -103,7 +105,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
Expand Down Expand Up @@ -163,4 +165,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.vscode/
.vscode/
327 changes: 143 additions & 184 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Releases

# v0.1.0-beta

2024-12-22 beta version.
File renamed without changes.
3 changes: 0 additions & 3 deletions docs/README.md

This file was deleted.

Binary file added docs/assets/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ask_sphero_spin_gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ioc_container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/meta-agent-cycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/moss_achitecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/streamlit_chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
206 changes: 206 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# GhostOS

> The AI `Ghosts` wonder in the `Shells`.

* [中文文档](/en/README.md)
* [Documents](/en/README.md)
* [Discord Server](https://discord.gg/NG6VKwd5jV)

(This document is translated from zh-cn to english by [Moonshot](https://moonshot.cn/))

## Example

Using Python code [SpheroBoltGPT](https://github.com/ghost-in-moss/GhostOS/tree/main/ghostos/demo/sphero/bolt_gpt.py),
an intelligent robot with a [SpheroBolt](https://sphero.com/products/sphero-bolt) as its body is defined.
If you have a SpheroBolt, running `ghostos web ghostos.demo.sphero.bolt_gpt` can start this robot.

![SpheroBoltGPT](assets/ask_sphero_spin_gif.gif)

The demo initially implements the following features:

1. Real-time voice conversation.
2. Control of body movements and drawing graphics on an 8x8 LED matrix.
3. Learning skills that include actions and animations through natural language dialogue.
4. Expressing emotions through movements during conversation.

## Introduce

`GhostOS` is an AI Agent framework designed to replace `JSON Schema `
with a Turing-complete code interaction interface ([Moss Protocol](/en/concepts/moss_protocol.md)),
becoming the core method for interaction between LLM and Agent system capabilities. For more details:
[MOSS: Enabling Code-Driven Evolution and Context Management for AI Agents](https://arxiv.org/abs/2409.16120)

The expected objects called through code
include `tools`, `personality`, `agent swarm`, `workflows`, `thinking`, `planning`, `knowledge`, and `memory`.
This allows a Meta-Agent to become an intelligent entity capable of continuous learning and growth through code
generation and project management.

And such an intelligent agent implemented with a code repository can also be shared and installed in the form of a
repository.

`GhostOS` Still in the early experimental developing, the current version mainly implements out-of-the-box capabilities,
including:

- [x] Turn a python file into an web agent
- [x] Agent web UI built by [Streamlit Web](https://streamlit.io/)
- [x] Support llms like `OpenAI`, `Moonshot`
- [x] Support [OpenAI vision](https://platform.openai.com/docs/guides/vision)
- [x] Support [OpenAI Realtime Beta](https://platform.openai.com/docs/guides/realtime)

## Quick Start

> `GhostOS` remains a beta AI project, strongly recommending installation in containers such as Docker rather than
> running locally.

Install `GhostOS` package:

```bash
pip install ghostos
```

Initialize `workspace` (directory `app` as default), The runtime files of the current version will be stored in the
directory.

```bash
ghostos init
```

Configure the model. Default to use OpenAI `gpt-4o`, requiring the environment variable `OPENAI_API_KEY`.
Or you can use configuration ui by streamlit:

```bash
ghostos config
```

Then test the default agent:

```bash
# run an agent with python filename or modulename
ghostos web ghostos.demo.agents.jojo
```

Or turn a local Python file into an Agent,
that can be instructed to call functions or methods within the file through natural language conversations.

```bash
ghostos web [my_path_file_path]
```

Install the extra dependencies for realtime:

```bash
# install realtime dependencies: pyaudio and websockets
pip install ghostos[realtime]

# install spherov2 if you have sphero bolt
pip install ghostos[sphero]
```

ou can create a local Python file and define your own Agents. For more details

* [Chatbot](/en/usages/chatbot.md): simplest chatbot
* [MossAgent](/en/usages/moss_agent.md): an agent that can interact with the python module

## Use In Python

```python
from ghostos.bootstrap import make_app_container, get_ghostos
from ghostos.ghosts.chatbot import Chatbot

# create your own root ioc container.
# register or replace the dependencies by IoC service providers.
container = make_app_container(...)

# fetch the GhostOS instance.
ghostos = get_ghostos(container)

# Create a shell instance, which managing sessions that keep AI Ghost inside it.
# and initialize the shell level dependency providers.
shell = ghostos.create_shell("your robot shell")
# Shell can handle parallel ghosts running, and communicate them through an EventBus.
# So the Multi-Agent swarm in GhostOS is asynchronous.
shell.background_run() # Optional

# need an instance implements `ghostos.abcd.Ghost` interface.
my_chatbot: Chatbot = ...

# use Shell to create a synchronous conversation channel with the Ghost.
conversation = shell.sync(my_chatbot)

# use the conversation channel to talk
event, receiver = conversation.talk("hello?")
with receiver:
for chunk in receiver.recv():
print(chunk.content)
```

## Developing Features

* [ ] Out-of-the-box Agent capability libraries.
* [ ] Variable type messaging and Streamlit rendering.
* [ ] Asynchronous Multi-Agent.
* [ ] Long-term task planning and execution.
* [ ] Atomic thinking capabilities.
* [ ] Automated execution and management of tree-based projects.
* [ ] Configurable components of the framework.
* [ ] Experiments with toy-level embodied intelligence.

> GhostOS, as a personal project, currently lacks the energy to focus on improving documentation, storage modules,
> stability, or security issues.
>
> The project's iteration will be centered on validating three directions for a long time:
> code-driven embodied intelligence, code-based thinking capabilities, and code-based learning.
> I will also aim to optimize out-of-the-box agent abilities.

# So What is GhostOS?

The GhostOS project is developed by the author for exploring AI applications. The basic idea is as follows:

AI Agent technology has two parallel evolutionary paths:
one is the perfection of the model's own capabilities, and the other is the evolution of the Agent engineering
framework.
The productivity level of the Agent framework determines the feasibility of AI models in practical application
scenarios.

GhostOS reflects the capabilities of an Agent from code into prompts, providing them to AI models,
and the code generated by the models runs directly in the environment.
Expecting the large language model do everything through a Turing-complete programming language interface,
including computation, tool invocation, body control, personality switching, thinking paradigms, state scheduling,
Multi-Agent, memory and recall, and other actions.

This will have stronger interaction capabilities and lower overhead than methods based on JSON schema.
The conversation data generated in this process can be used for post-training or reinforcement learning of the model,
thereby continuously optimizing the code generation.

The AI Agent itself is also defined by code.
Therefore, a Meta-Agent can develop other Agents just like a normal programming task.

Ideally, the Meta-Agent can write code, write its own tools, define memories and chain of thoughts with data structures,
and develop other Agents for itself.

![meta-agent-cycle](assets/meta-agent-cycle.png)

Furthermore, most complex tasks with rigorous steps can be described using tree or graph data structures.
Constructing a nested graph or tree using methods like JSON is very difficult,
while using programming languages is the most efficient.

models can consolidate the results learned from conversations into nodes in the code,
and then plan them into trees or graphs, thereby executing sufficiently complex tasks.

In this way, an AI Agent can store the knowledge and capabilities learned from natural language in the form of files and
code,
thereby evolving itself. This is a path of evolution beyond model iteration.

Based on this idea,
GhostOS aims to turn an Agent swarm into a project constructed through code.
The Agents continuously precipitate new knowledge and capabilities in the form of code, enriching the project.
The Agent project can be copied, shared, or deployed in the form of repositories,

In this new form of productivity, interacting purely through code is the most critical step.

The author's ultimate goal is not `GhostOS` itself,
but to verify and promote the code interaction design and applications.
The hope is that one day, agents, paradigms, bodies, and tools for AI Agents can all be designed based on the same
programming language protocols,
achieving cross-project universality.

2 changes: 2 additions & 0 deletions docs/en/_navbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* [Chinese](/zh-cn/)
* [En](/en/)
23 changes: 23 additions & 0 deletions docs/en/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
* [Home](/en/)
* Getting Started
* [Installation](/en/getting_started/installation.md)
* [Configuration](/en/getting_started/configuration.md)
* [Chat](/en/getting_started/chat_with_ghost.md)
* [Scripts](/en/getting_started/scripts.md)
* Concepts
* [Design](/en/concepts/abcd.md)
* [Moss Protocol](/en/concepts/moss_protocol.md)
* [IoC Container](/en/concepts/ioc_container.md)
* [EntityMeta](/en/concepts/entity_meta.md)
* [Prompter](/en/concepts/prompter.md)
* Usages
* [Ghost](/en/usages/ghost.md)
* [Chatbot](/en/usages/chatbot.md)
* [MossAgent](/en/usages/moss_agent.md)
* [Libraries](/en/libraries/libraries.md)
* Frameworks
* [Messages](/en/frameworks/messages.md)
* [LLMs](/en/frameworks/llms.md)
* [EventBus](/en/frameworks/eventbus.md)
* [Tasks](/en/frameworks/tasks.md)
* [Threads](/en/frameworks/threads.md)
47 changes: 47 additions & 0 deletions docs/en/concepts/abcd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Abstract Class Design

The abstract design of GhostOS adheres to the principle of interface-oriented programming.
All modules are designed using abstract classes, and implementations are assembled through
the [IoC Container](/en/concepts/ioc_container.md)

![architecture](../../assets/architecture.png)

The basic interrelationships of these abstractions and their usage logic are as follows:

```python
from ghostos.abcd import GhostOS, Shell, Conversation, Ghost
from ghostos.container import Container
from ghostos.bootstrap import make_app_container, get_ghostos

# create your own root ioc container.
# register or replace the dependencies by IoC service providers.
container: Container = make_app_container(...)

# fetch the GhostOS instance.
ghostos: GhostOS = get_ghostos(container)

# Create a shell instance, which managing sessions that keep AI Ghost inside it.
# and initialize the shell level dependency providers.
shell: Shell = ghostos.create_shell("your robot shell")
# Shell can handle parallel ghosts running, and communicate them through an EventBus.
# So the Multi-Agent swarm in GhostOS is asynchronous.
shell.background_run() # Optional

# need an instance implements `ghostos.abcd.Ghost` interface.
my_chatbot: Ghost = ...

# use Shell to create a synchronous conversation channel with the Ghost.
conversation: Conversation = shell.sync(my_chatbot)

# use the conversation channel to talk
event, receiver = conversation.talk("hello?")
with receiver:
for chunk in receiver.recv():
print(chunk.content)

```

For detailed content, please check the source code. [ghostos.abcd.concepts](https://github.com/ghost-in-moss/GhostOS/tree/main/ghostos/abcd/concepts.py)

> Abstract design-related introductions can be quite complex;
> only complete the documentation when I have the energy (T_T).
16 changes: 16 additions & 0 deletions docs/en/concepts/entity_meta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Entity Meta

A code-driven AI Agent needs to store various data during its operation, a
nd also be able to restore variables in subsequent operations.
Considering a distributed system or an interruptible Agent, these data need a long-term storage solution.

`GhostOS`, based on `pickle` and `pydantic`, has
implemented [EntityMeta](https://github.com/ghost-in-moss/GhostOS/tree/main/ghostos/entity.py).

It aims to:

1. Serialize and deserialize the vast majority of accessible Python data structures
2. Provide a universal container and API for data manipulation
3. Ensure data readability as much as possible.

More technical details can be seen in the code.
Loading