Skip to content

Commit

Permalink
fixed formatting for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishnaM251 committed Jun 19, 2024
1 parent 7977a1d commit 2601fb3
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 11,607 deletions.
2 changes: 0 additions & 2 deletions memgpt/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ def __init__(
assert embedding_config is not None, "Must provide embedding_config field when creating an Agent from a Preset"

# if agent_state is also provided, override any preset values
# krishna
print("agent.py created_by type: ", type(created_by))
init_agent_state = AgentState(
name=name if name else create_random_username(),
user_id=created_by,
Expand Down
2 changes: 0 additions & 2 deletions memgpt/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,6 @@ def list(arg: Annotated[ListChoice, typer.Argument]):
table.field_names = ["Name", "LLM Model", "Embedding Model", "Embedding Dim", "Persona", "Human", "Data Source", "Create Time"]
agent_list = []
for agent in tqdm(client.list_agents().agents):
# krishna
print("agent: ", agent)
assert all([source is not None and isinstance(source, Source)] for source in agent.sources), "Source not null assertion failed"
source_names = [source.name for source in agent.sources if source is not None]
entry = [
Expand Down
26 changes: 0 additions & 26 deletions memgpt/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

import requests

# krishna1
from rich import print

from memgpt.agent import Agent
from memgpt.config import MemGPTConfig
from memgpt.constants import DEFAULT_PRESET
Expand Down Expand Up @@ -310,8 +307,6 @@ def __init__(

# agents
def list_agents(self):
# krishna2
print("list_agents headers: ", self.headers)
response = requests.get(f"{self.base_url}/api/agents", headers=self.headers)
return ListAgentsResponse(**response.json())

Expand Down Expand Up @@ -400,11 +395,7 @@ def get_agent_config(self, agent_id: Optional[uuid.UUID] = None, agent_name: Opt
params = {"agent_id": agent_id, "agent_name": agent_name}
response = requests.get(f"{self.base_url}/api/agents/config", params=params, headers=self.headers)
assert response.status_code == 200, f"Failed to get agent: {response.text}"
# krishna1
print("client response: ", response.json())
response_obj = GetAgentResponse(**response.json())
# krishna1
print("client: no immediate error in response → GetAgentResponse conversion?")
return self.get_agent_response_to_state(response_obj)

def update_agent(self, agent_state: AgentState):
Expand All @@ -424,21 +415,6 @@ def update_agent(self, agent_state: AgentState):
response = requests.post(f"{self.base_url}/api/agents/update", json=data, headers=self.headers)
assert response.status_code == 200, f"Failed to update agent: {response.text}"

# krishna
# def save_agent(self, agent: Optional[Agent] = None, metadata_preset: Optional[PresetWithMetadata] = None):
# # repeat same procedure of getting agent, update values as necessary
# # preset
# # created_by (UUID), first_message_verify_mono
# data = {}
# if agent:
# data["agent_id"] = int(agent.agent_state.id)
# else:
# data = dict(metadata_preset)
# # krishna2
# print("save_agent headers: ", self.headers)
# print("data: ", data)
# response = requests.post(f"{self.base_url}/api/agents/save", json=data, headers=self.headers)
# assert response.status_code == 200, f"Failed to save agent: {response.text}"
def save_agent(self, agent: Agent):
llm_config_model = LLMConfigModel(**agent.agent_state.llm_config.__dict__)
embedding_config_model = EmbeddingConfigModel(**agent.agent_state.embedding_config.__dict__)
Expand Down Expand Up @@ -938,8 +914,6 @@ def create_preset_from_file(
def get_preset(
self, preset_id: Optional[uuid.UUID] = None, preset_name: Optional[str] = None, user_id: Optional[uuid.UUID] = None
) -> PresetModel:
# krishna
print("client preset_name: ", preset_name)
return self.server.get_preset(preset_id=preset_id, preset_name=preset_name, user_id=user_id)

def delete_preset(self, preset_id: uuid.UUID) -> Preset:
Expand Down
3 changes: 0 additions & 3 deletions memgpt/server/rest_api/agents/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from fastapi.responses import JSONResponse
from pydantic import BaseModel, Field

# krishna1
from rich import print

from memgpt.models.pydantic_models import (
AgentStateModel,
EmbeddingConfigModel,
Expand Down
61 changes: 0 additions & 61 deletions memgpt/server/rest_api/agents/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
from fastapi import status as stat
from pydantic import BaseModel, Field

# krishna1
from rich import print

from memgpt.data_types import AgentState, LLMConfig
from memgpt.models.pydantic_models import (
AgentStateModel,
Expand Down Expand Up @@ -74,8 +71,6 @@ def list_agents(
"""
interface.clear()
agents_data = server.list_agents(user_id=user_id)
# krishna
print("index agents_data: ", agents_data["agents"][0])
return ListAgentsResponse(**agents_data)

@router.post("/agents/create", tags=["agents"], response_model=CreateAgentResponse)
Expand Down Expand Up @@ -175,8 +170,6 @@ def update_agent(
created_at=agent_state.created_at,
),
)
# krishna1
# print("update_agent value: ", updated_agent)
updated_agent = updated_agent[0]
updated_agent.llm_config.model = request.model
updated_agent.llm_config.context_window = request.context_window
Expand All @@ -188,60 +181,6 @@ def update_agent(
interface.clear()
server.update_agent(agent_state=updated_agent)

# krishna
# @router.post("/agents/save", tags=["agents"])
# def save_agent(
# request: Union[PresetWithMetadata, AgentIdRequest]= Body(...),
# user_id: uuid.UUID = Depends(get_current_user_with_server),
# ):
# """
# Two Cases:
# #1 - save_agent is called during `memgpt run`
# the Preset object must be saved and we do not have access to agent_id, so PresetWithMetadata is used
# #2 - save_agent is called in main.py during `run_agent_loop` (and likely other places in the future)
# the Agent object was previously instantiated and saved in storage, therefore AgentIdRequest is used
# """
# # krishna
# print("agent index request: ", request)

# # obtain agent_state
# interface.clear()
# if isinstance(request, AgentIdRequest) :
# agent_id = uuid.UUID(int=request.agent_id)
# agent_name = None
# else:
# agent_id = None
# agent_name = request.agent_name

# if not server.ms.get_agent(user_id=user_id, agent_name=agent_name, agent_id=agent_id):
# # agent does not exist
# raise HTTPException(status_code=404, detail=f"Agent {agent_name} / {request.agent_id} not found.")

# agent_state = server.get_agent_config(user_id=user_id, agent_name=agent_name, agent_id=agent_id)

# # generate configs
# llm_config = LLMConfigModel(**vars(agent_state.llm_config))
# embedding_config = EmbeddingConfigModel(**vars(agent_state.embedding_config))

# # create Agent object from the following (COPY :690 OF CLI.PY):
# # AgentState
# # configs
# # interface()
# # metadata (see client.py save_agent)

# interface.clear()
# memgpt_agent = Agent(
# interface=stream_interface(),
# name=agent_state.name,
# agent_state=agent_state,
# created_by=agent_state.user_id,
# preset=None if isinstance(request, AgentIdRequest) else request,
# llm_config=llm_config,
# embedding_config=embedding_config,
# first_message_verify_mono=False if isinstance(request, AgentIdRequest) else request.first_message_verify_mono
# )
# server.save_agent(memgpt_agent)

@router.post("/agents/save", tags=["agents"])
def save_agent(
request: AgentStateModel = Body(...),
Expand Down
3 changes: 0 additions & 3 deletions memgpt/server/rest_api/auth_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
def get_current_user(server: SyncServer, password: str, auth: HTTPAuthorizationCredentials = Depends(security)) -> uuid.UUID:
try:
api_key_or_password = auth.credentials
# krishna2
print("api_key_or_password: ", api_key_or_password)
print("password: ", password)
if api_key_or_password == password:
# user is admin so we just return the default uuid
return server.authenticate_user()
Expand Down
2 changes: 1 addition & 1 deletion memgpt/server/rest_api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from memgpt.server.rest_api.presets.index import setup_presets_index_router
from memgpt.server.rest_api.sources.index import setup_sources_index_router
from memgpt.server.rest_api.static_files import mount_static_files
from memgpt.server.rest_api.tools.index import setup_tools_index_router
from memgpt.server.rest_api.tools.index import setup_user_tools_index_router
from memgpt.server.rest_api.users.index import setup_users_index_router
from memgpt.server.server import SyncServer
from memgpt.settings import settings
Expand Down
11 changes: 0 additions & 11 deletions memgpt/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

from fastapi import HTTPException

# krishna1
from rich import print

import memgpt.constants as constants
import memgpt.presets.presets as presets
import memgpt.server.utils as server_utils
Expand Down Expand Up @@ -215,9 +212,6 @@ def __init__(

# Initialize the connection to the DB
self.config = MemGPTConfig.load()
# krishna
print("sync server init config: ", self.config)
print(f"server :: loading configuration from '{self.config.config_path}'")
assert self.config.persona is not None, "Persona must be set in the config"
assert self.config.human is not None, "Human must be set in the config"

Expand Down Expand Up @@ -1268,9 +1262,6 @@ def get_available_models(self) -> list:
raise

def update_agent(self, agent_state: AgentState):
# krishna1
print("server update_agent: ", agent_state.__dict__)
print("type of created_at: ", type(agent_state.created_at))
self.ms.update_agent(agent_state)

def update_agent_core_memory(self, user_id: uuid.UUID, agent_id: uuid.UUID, new_memory_contents: dict) -> dict:
Expand Down Expand Up @@ -1389,8 +1380,6 @@ def authenticate_user(self) -> uuid.UUID:

def api_key_to_user(self, api_key: str) -> uuid.UUID:
"""Decode an API key to a user"""
# krishna2
print("hitting server.py api_key_to_user")
user = self.ms.get_user_from_api_key(api_key=api_key)
if user is None:
raise HTTPException(status_code=403, detail="Invalid credentials")
Expand Down
Loading

0 comments on commit 2601fb3

Please sign in to comment.