Skip to content

Commit

Permalink
Fix tests (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyiilluu committed Jul 13, 2023
1 parent a4eecdd commit 6a2fbdb
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions autochain/memory/redis_memory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pickle
from typing import Any, Optional
from typing import Any, Optional, Dict

from autochain.agent.message import (
ChatMessageHistory,
Expand Down Expand Up @@ -39,7 +39,7 @@ def load_memory(
return default
return pickle.loads(pickled)

def load_conversation(self, **kwargs: dict[str, Any]) -> ChatMessageHistory:
def load_conversation(self, **kwargs: Dict[str, Any]) -> ChatMessageHistory:
"""Return chat message history."""
redis_key = self.redis_key_prefix + f":{ChatMessageHistory.__name__}"
return ChatMessageHistory(messages=self.load_memory(redis_key, []))
Expand Down
1 change: 0 additions & 1 deletion autochain/tools/internal_search/pinecone_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def _format_output(query_response: QueryResponse) -> str:
response: QueryResponse = self.index.query(
vector=encoding, top_k=top_k, include_values=include_values
)

return _format_output(response)

def add_docs(self, docs: List[PineconeDoc], **kwargs):
Expand Down
6 changes: 0 additions & 6 deletions overrides/main.html

This file was deleted.

Empty file added test_utils/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class MockIndex:
kv = {}
def __init__(self):
self.kv = {}

def upsert(self, id_vectors, *args, **kwargs):
for id, vector in id_vectors:
Expand Down
3 changes: 3 additions & 0 deletions tests/agent/test_conversational_agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from unittest import mock

import pytest
Expand Down Expand Up @@ -84,6 +85,7 @@ def openai_response_fixture():


def test_should_answer_prompt(openai_should_answer_fixture):
os.environ["OPENAI_API_KEY"] = "mock_api_key"
agent = ConversationalAgent.from_llm_and_tools(llm=ChatOpenAI(), tools=[])

inputs = {"history": "good user query"}
Expand All @@ -97,6 +99,7 @@ def test_should_answer_prompt(openai_should_answer_fixture):


def test_plan(openai_response_fixture):
os.environ["OPENAI_API_KEY"] = "mock_api_key"
agent = ConversationalAgent.from_llm_and_tools(
llm=ChatOpenAI(), tools=[HandOffToAgent()]
)
Expand Down
3 changes: 2 additions & 1 deletion tests/memory/test_long_term_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from autochain.memory.long_term_memory import LongTermMemory
from autochain.tools.internal_search.chromadb_tool import ChromaDoc, ChromaDBSearch
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from tests.common.pinecone_mocks import (
from test_utils.pinecone_mocks import (
DummyEncoder,
pinecone_index_fixture
)


Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_pinecone_tool.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from autochain.tools.internal_search.pinecone_tool import PineconeSearch, PineconeDoc
from tests.common.pinecone_mocks import (
from test_utils.pinecone_mocks import (
DummyEncoder,
pinecone_index_fixture,
)
Expand Down

0 comments on commit 6a2fbdb

Please sign in to comment.