Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update OpenAI assistants example to use memgpt server #1012

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions examples/openai_client_assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"""
This script provides an example of how you can use OpenAI's python client with a MemGPT server.

Before running this example, make sure you start the OpenAI-compatible REST server:
cd memgpt/server/rest_api/openai_assistants
poetry run uvicorn assistants:app --reload --port 8080
Before running this example, make sure you start the OpenAI-compatible REST server with `memgpt server`.
"""


def main():
client = OpenAI(base_url="http://127.0.0.1:8080/v1")
client = OpenAI(base_url="http://localhost:8283/v1")

# create assistant (creates a memgpt preset)
assistant = client.beta.assistants.create(
Expand Down Expand Up @@ -41,7 +39,7 @@
messages = client.beta.threads.messages.list(thread_id=thread.id)

# Print all messages from the thread
for msg in messages.messages:

Check failure on line 42 in examples/openai_client_assistants.py

View workflow job for this annotation

GitHub Actions / Pyright types check (3.11)

Cannot access member "messages" for type "SyncCursorPage[ThreadMessage]"   Member "messages" is unknown (reportAttributeAccessIssue)
role = msg["role"]
content = msg["content"][0]
print(f"{role.capitalize()}: {content}")
Expand Down
8 changes: 0 additions & 8 deletions memgpt/server/rest_api/openai_assistants/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
from memgpt.data_types import LLMConfig, EmbeddingConfig, Message
from memgpt.constants import DEFAULT_PRESET

"""
Basic REST API sitting on top of the internal MemGPT python server (SyncServer)

Start the server with:
cd memgpt/server/rest_api/openai_assistants
poetry run uvicorn assistants:app --reload --port 8080
"""

router = APIRouter()


Expand Down
Loading