Skip to content

Commit

Permalink
Fix all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
bmquinn committed Feb 2, 2024
1 parent b4bc082 commit a6578c3
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ deps-python:
cover-python: deps-python
cd chat && export SKIP_WEAVIATE_SETUP=True && coverage run -m unittest -v && coverage report
style-python: deps-python
cd chat && ruff check .
cd chat && ruff check .
test-python: deps-python
cd chat && export SKIP_WEAVIATE_SETUP=True && PYTHONPATH=. && python -m unittest discover -v
cd chat && export SKIP_WEAVIATE_SETUP=True && PYTHONPATH=src:test && python -m unittest discover -v
python-version:
cd chat && python --version
build: .aws-sam/build.toml
Expand Down
2 changes: 0 additions & 2 deletions chat/dependencies/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
boto3~=1.34.13
langchain~=0.0.208
nbformat~=5.9.0
openai~=0.27.8
pandas~=2.0.2
pyjwt~=2.6.0
python-dotenv~=1.0.0
tiktoken~=0.4.0
Expand Down
10 changes: 5 additions & 5 deletions chat/src/event_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from dataclasses import dataclass, field
from langchain.chains.qa_with_sources import load_qa_with_sources_chain
from langchain.prompts import PromptTemplate
from .setup import (
from setup import (
weaviate_client,
weaviate_vector_store,
openai_chat_client,
)
from typing import List
from .handlers.streaming_socket_callback_handler import StreamingSocketCallbackHandler
from .helpers.apitoken import ApiToken
from .helpers.prompts import document_template, prompt_template
from .websocket import Websocket
from handlers.streaming_socket_callback_handler import StreamingSocketCallbackHandler
from helpers.apitoken import ApiToken
from helpers.prompts import document_template, prompt_template
from websocket import Websocket


CHAIN_TYPE = "stuff"
Expand Down
2 changes: 1 addition & 1 deletion chat/src/handlers/streaming_socket_callback_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain.callbacks.base import BaseCallbackHandler
from ..websocket import Websocket
from websocket import Websocket
import os

class StreamingSocketCallbackHandler(BaseCallbackHandler):
Expand Down
2 changes: 0 additions & 2 deletions chat/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Runtime Dependencies
boto3~=1.34.13
langchain~=0.0.208
nbformat~=5.9.0
openai~=0.27.8
pandas~=2.0.2
pyjwt~=2.6.0
python-dotenv~=1.0.0
tiktoken~=0.4.0
Expand Down
2 changes: 1 addition & 1 deletion chat/src/websocket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from .setup import websocket_client
from setup import websocket_client

class Websocket:
def __init__(self, client=None, endpoint_url=None, connection_id=None, ref=None):
Expand Down
10 changes: 8 additions & 2 deletions chat/test/handlers/test_streaming_socket_callback_handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# ruff: noqa: E402
import sys
sys.path.append('./src')

from unittest import TestCase
from src.handlers.streaming_socket_callback_handler import (
from handlers.streaming_socket_callback_handler import (
StreamingSocketCallbackHandler,
)
from src.websocket import Websocket
from websocket import Websocket



class MockClient:
def post_to_connection(self, Data, ConnectionId):
Expand Down
8 changes: 7 additions & 1 deletion chat/test/helpers/test_apitoken.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# ruff: noqa: E402
import os
from src.helpers.apitoken import ApiToken
import sys
sys.path.append('./src')

from helpers.apitoken import ApiToken
from test.fixtures.apitoken import SUPER_TOKEN, TEST_SECRET, TEST_TOKEN
from unittest import mock, TestCase




@mock.patch.dict(os.environ, {"API_TOKEN_SECRET": TEST_SECRET})
class TestFunction(TestCase):
def test_empty_token(self):
Expand Down
13 changes: 9 additions & 4 deletions chat/test/helpers/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from unittest import TestCase, mock
from src.helpers.metrics import count_tokens, token_usage
from src.event_config import EventConfig

# ruff: noqa: E402
import json
import os
import sys
sys.path.append('./src')

from unittest import TestCase, mock
from helpers.metrics import count_tokens, token_usage
from event_config import EventConfig



@mock.patch.dict(
os.environ,
Expand Down
6 changes: 5 additions & 1 deletion chat/test/helpers/test_prompts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ruff: noqa: E402
import sys
sys.path.append('./src')

from helpers.prompts import prompt_template, document_template
from unittest import TestCase
from src.helpers.prompts import prompt_template, document_template


class TestPromptTemplate(TestCase):
Expand Down
7 changes: 5 additions & 2 deletions chat/test/test_event_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# ruff: noqa: E402
import json
import os
from unittest import TestCase, mock
import sys
sys.path.append('./src')

from src.event_config import EventConfig
from event_config import EventConfig
from unittest import TestCase, mock


class TestEventConfigWithoutAzureResource(TestCase):
Expand Down
6 changes: 5 additions & 1 deletion chat/test/test_websocket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# ruff: noqa: E402
import sys
sys.path.append('./src')

from unittest import TestCase
from websocket import Websocket

from src.websocket import Websocket

class MockClient:
def post_to_connection(self, Data, ConnectionId):
Expand Down

0 comments on commit a6578c3

Please sign in to comment.