Skip to content

Commit

Permalink
Chatgpt Rework, Agent Memory Hotfixes (#275)
Browse files Browse the repository at this point in the history
* Rework ChatGPT Provider

* Agent Memory Hotfixes
  • Loading branch information
Josh-XT authored May 9, 2023
1 parent 150f81c commit 5788f3f
Show file tree
Hide file tree
Showing 6 changed files with 574 additions and 161 deletions.
13 changes: 5 additions & 8 deletions API-Tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,27 +205,24 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'response': '\"AI technology continues to evolve at a rapid pace, bringing new '\n",
" 'opportunities for innovation and growth across industries. From '\n",
" 'healthcare to finance, AI is transforming the way we live and '\n",
" 'work. As we continue to develop and refine these technologies, '\n",
" \"it's important to prioritize ethical considerations and ensure \"\n",
" 'their responsible use.\" #AIinnovation #ethicsinTech'}\n"
"{'response': '\"AI technology has come so far over the years, but there\\'s '\n",
" \"still plenty we don't know about how our brains work. \"\n",
" '#artificialintelligence\"'}\n"
]
}
],
"source": [
"# Test POST /api/agent/{agent_name}/chat\n",
"# Chat with the agent\n",
"data = {\"prompt\": \"Write a tweet about AI.\"}\n",
"response = requests.post(f\"{base_uri}/api/agent/huggingface/chat\", json=data)\n",
"response = requests.post(f\"{base_uri}/api/agent/huggingchat/chat\", json=data)\n",
"pprint(response.json())\n"
]
},
Expand Down
2 changes: 1 addition & 1 deletion Config/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def __init__(self, agent_name=None):
self.USE_LONG_TERM_MEMORY_ONLY = os.getenv(
"USE_LONG_TERM_MEMORY_ONLY", "false"
).lower()
self.memories = Memories(self.agent_name)
# Yaml Memory
self.memory_file = f"agents/{self.AGENT_NAME}.yaml"
self._create_parent_directories(self.memory_file)
self.memory = self.load_memory()
self.agent_instances = {}
self.commands = self.load_commands()
self.memories = Memories(self.AGENT_NAME, self)

def _load_agent_config_keys(self, keys):
for key in keys:
Expand Down
5 changes: 2 additions & 3 deletions Memories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import secrets
from typing import List, Dict
from chromadb.utils import embedding_functions
from Config.Agent import Agent
import spacy
from spacy.cli import download

Expand All @@ -16,9 +15,9 @@


class Memories:
def __init__(self, AGENT_NAME: str = "Agent-LLM"):
def __init__(self, AGENT_NAME: str = "Agent-LLM", CFG=None):
self.AGENT_NAME = AGENT_NAME
self.CFG = Agent(self.AGENT_NAME)
self.CFG = CFG
self.nlp = nlp
if self.CFG.AI_PROVIDER == "openai":
self.embedding_function = embedding_functions.OpenAIEmbeddingFunction(
Expand Down
Loading

0 comments on commit 5788f3f

Please sign in to comment.