Skip to content

Commit

Permalink
Revert "cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 85d9fba, reversing
changes made to a7e06d0.
  • Loading branch information
vivi committed Oct 25, 2023
1 parent 85d9fba commit 6cd2a00
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 734 deletions.
66 changes: 48 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ Memory-GPT (or MemGPT in short) is a system that intelligently manages different

## Running MemGPT locally

Install dependencies:
Install MemGPT:

```sh
pip install -r requirements.txt
pip install pymemgpt
```

To update the package, run
```sh
pip install pymemgpt -U
```

Add your OpenAI API key to your environment:
Expand All @@ -89,12 +94,37 @@ export OPENAI_API_KEY=YOUR_API_KEY
set OPENAI_API_KEY=YOUR_API_KEY
```

To run MemGPT for as a conversation agent in CLI mode, simply run `main.py`:
To run MemGPT for as a conversation agent in CLI mode, simply run `memgpt`:

```sh
python3 main.py
memgpt
```

<details>
<summary><strong>Debugging command not found</strong></summary>

If you get `command not found` (Linux/MacOS), or a `CommandNotFoundException` (Windows), the directory where pip installs scripts is not in your PATH. You can either add that directory to your path (`pip show pip | grep Scripts`) or instead just run:
```sh
python -m memgpt
```
</details>

<details>
<summary><strong>Building from source</strong></summary>

Clone this repo: `git clone https://github.com/cpacker/MemGPT.git`

Using poetry:
1. Install poetry: `pip install poetry`
2. Run `poetry install`
3. Run `poetry run memgpt`

Using pip:
1. Run `pip install -e .`
2. Run `python3 main.py`
</details>


If you're using Azure OpenAI, set these variables instead:

```sh
Expand All @@ -105,31 +135,31 @@ export AZURE_OPENAI_VERSION = ...
export AZURE_OPENAI_DEPLOYMENT = ...

# then use the --use_azure_openai flag
python main.py --use_azure_openai
memgpt --use_azure_openai
```

To create a new starter user or starter persona (that MemGPT gets initialized with), create a new `.txt` file in [/memgpt/humans/examples](/memgpt/humans/examples) or [/memgpt/personas/examples](/memgpt/personas/examples), then use the `--persona` or `--human` flag when running `main.py`. For example:

To create a new starter user or starter persona (that MemGPT gets initialized with), create a new `.txt` file in `~/.memgpt/humans` or `~/.memgpt/personas`, then use the `--persona` or `--human` flag when running `main.py`. For example:
```sh
# assuming you created a new file /memgpt/humans/examples/me.txt
python main.py
# assuming you created a new file ~/.memgpt/humans/me.txt
memgpt
# Select me.txt during configuration process
```
-- OR --
```sh
# assuming you created a new file /memgpt/humans/examples/me.txt
python main.py --human me.txt
# assuming you created a new file ~/.memgpt/humans/me.txt
memgpt --human me.txt
```
You can also specify any of the starter users in [/memgpt/humans/examples](/memgpt/humans/examples) or any of the starter personas in [/memgpt/personas/examples](/memgpt/personas/examples).

### GPT-3.5 support
You can run MemGPT with GPT-3.5 as the LLM instead of GPT-4:
```sh
python main.py
memgpt
# Select gpt-3.5 during configuration process
```
-- OR --
```sh
python main.py --model gpt-3.5-turbo
memgpt --model gpt-3.5-turbo
```

**Note that this is experimental gpt-3.5-turbo support. It's quite buggy compared to gpt-4, but it should be runnable.**
Expand Down Expand Up @@ -210,7 +240,7 @@ id | name | age
To talk to this database, run:

```sh
python main.py --archival_storage_sqldb=memgpt/personas/examples/sqldb/test.db
memgpt --archival_storage_sqldb=memgpt/personas/examples/sqldb/test.db
```

And then you can input the path to your database, and your query.
Expand All @@ -233,15 +263,15 @@ To run our example where you can search over the SEC 10-K filings of Uber, Lyft,

2. In the root `MemGPT` directory, run
```bash
python3 main.py --archival_storage_files="memgpt/personas/examples/preload_archival/*.txt" --persona=memgpt_doc --human=basic
memgpt --archival_storage_files="memgpt/personas/examples/preload_archival/*.txt" --persona=memgpt_doc --human=basic
```

If you would like to load your own local files into MemGPT's archival memory, run the command above but replace `--archival_storage_files="memgpt/personas/examples/preload_archival/*.txt"` with your own file glob expression (enclosed in quotes).
#### Enhance with embeddings search
In the root `MemGPT` directory, run
```bash
python3 main.py --archival_storage_files_compute_embeddings="<GLOB_PATTERN>" --persona=memgpt_doc --human=basic
memgpt main.py --archival_storage_files_compute_embeddings="<GLOB_PATTERN>" --persona=memgpt_doc --human=basic
```
This will generate embeddings, stick them into a FAISS index, and write the index to a directory, and then output:
Expand All @@ -252,7 +282,7 @@ This will generate embeddings, stick them into a FAISS index, and write the inde

If you want to reuse these embeddings, run
```bash
python3 main.py --archival_storage_faiss_path="<DIRECTORY_WITH_EMBEDDINGS>" --persona=memgpt_doc --human=basic
memgpt --archival_storage_faiss_path="<DIRECTORY_WITH_EMBEDDINGS>" --persona=memgpt_doc --human=basic
```


Expand Down Expand Up @@ -284,7 +314,7 @@ MemGPT also enables you to chat with docs -- try running this example to talk to
3. In the root `MemGPT` directory, run
```bash
python3 main.py --archival_storage_faiss_path=<ARCHIVAL_STORAGE_FAISS_PATH> --persona=memgpt_doc --human=basic
memgpt --archival_storage_faiss_path=<ARCHIVAL_STORAGE_FAISS_PATH> --persona=memgpt_doc --human=basic
```
where `ARCHIVAL_STORAGE_FAISS_PATH` is the directory where `all_docs.jsonl` and `all_docs.index` are located.
If you downloaded from Hugging Face, it will be `memgpt/personas/docqa/llamaindex-api-docs`.
Expand Down
14 changes: 6 additions & 8 deletions memgpt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import memgpt.interface as interface
from memgpt.personas.personas import get_persona_text
from memgpt.humans.humans import get_human_text
from memgpt.constants import MEMGPT_DIR

model_choices = [
questionary.Choice("gpt-4"),
Expand All @@ -23,14 +22,15 @@
value="gpt-3.5-turbo",
),
]
memgpt_dir = os.path.join(os.path.expanduser("~"), ".memgpt")


class Config:
personas_dir = os.path.join("memgpt", "personas", "examples")
custom_personas_dir = os.path.join(MEMGPT_DIR, "personas")
custom_personas_dir = os.path.join(memgpt_dir, "personas")
humans_dir = os.path.join("memgpt", "humans", "examples")
custom_humans_dir = os.path.join(MEMGPT_DIR, "humans")
configs_dir = os.path.join(MEMGPT_DIR, "configs")
custom_humans_dir = os.path.join(memgpt_dir, "humans")
configs_dir = os.path.join(memgpt_dir, "configs")

def __init__(self):
os.makedirs(Config.custom_personas_dir, exist_ok=True)
Expand Down Expand Up @@ -247,8 +247,7 @@ def get_memgpt_personas():
+ Config.get_persona_choices(
[p for p in custom_personas_in_examples + default_personas],
get_persona_text,
None,
# Config.personas_dir,
Config.personas_dir,
)
+ [
questionary.Separator(),
Expand All @@ -275,8 +274,7 @@ def get_user_personas():
+ Config.get_persona_choices(
[p for p in custom_personas_in_examples + default_personas],
get_human_text,
None,
# Config.humans_dir,
Config.humans_dir,
)
+ [
questionary.Separator(),
Expand Down
20 changes: 6 additions & 14 deletions memgpt/constants.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import os

MEMGPT_DIR = os.path.join(os.path.expanduser("~"), ".memgpt")

DEFAULT_MEMGPT_MODEL = "gpt-4"
DEFAULT_MEMGPT_MODEL = 'gpt-4'

FIRST_MESSAGE_ATTEMPTS = 10

INITIAL_BOOT_MESSAGE = "Boot sequence complete. Persona activated."
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT = (
"Bootup sequence complete. Persona activated. Testing messaging functionality."
)
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT = "Bootup sequence complete. Persona activated. Testing messaging functionality."
STARTUP_QUOTES = [
"I think, therefore I am.",
"All those moments will be lost in time, like tears in rain.",
Expand All @@ -18,7 +12,7 @@
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG = STARTUP_QUOTES[2]

# Constants to do with summarization / conversation length window
MESSAGE_SUMMARY_WARNING_TOKENS = 7000 # the number of tokens consumed in a call before a system warning goes to the agent
MESSAGE_SUMMARY_WARNING_TOKENS = 7000 # the number of tokens consumed in a call before a system warning goes to the agent
MESSAGE_SUMMARY_WARNING_STR = f"Warning: the conversation history will soon reach its maximum length and be trimmed. Make sure to save any important information from the conversation to your memory before it is removed."

# Default memory limits
Expand All @@ -27,13 +21,11 @@

MAX_PAUSE_HEARTBEATS = 360 # in min

MESSAGE_CHATGPT_FUNCTION_MODEL = "gpt-3.5-turbo"
MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE = (
"You are a helpful assistant. Keep your responses short and concise."
)
MESSAGE_CHATGPT_FUNCTION_MODEL = 'gpt-3.5-turbo'
MESSAGE_CHATGPT_FUNCTION_SYSTEM_MESSAGE = 'You are a helpful assistant. Keep your responses short and concise.'

#### Functions related

REQ_HEARTBEAT_MESSAGE = "request_heartbeat == true"
FUNC_FAILED_HEARTBEAT_MESSAGE = "Function call failed"
FUNCTION_PARAM_DESCRIPTION_REQ_HEARTBEAT = "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."
FUNCTION_PARAM_DESCRIPTION_REQ_HEARTBEAT = "Request an immediate heartbeat after function execution. Set to 'true' if you want to send a follow-up message or run a follow-up function."
Loading

0 comments on commit 6cd2a00

Please sign in to comment.