Skip to content

Commit d4d492e

Browse files
chatbot-rag-app: polishes source file style and formatting (#363)
This applies some linting found in another project. Signed-off-by: Adrian Cole <[email protected]>
1 parent 7b538f1 commit d4d492e

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

Diff for: example-apps/chatbot-rag-app/.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
frontend/build
22
frontend/node_modules
33
api/__pycache__
4-
api/.env
54
.venv
65
venv
7-
.DS_Store
6+
.DS_Store
7+
.env

Diff for: example-apps/chatbot-rag-app/api/app.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from flask import Flask, jsonify, request, Response
2-
from flask_cors import CORS
3-
from uuid import uuid4
4-
from chat import ask_question
51
import os
62
import sys
3+
from uuid import uuid4
4+
5+
from chat import ask_question
6+
from flask import Flask, Response, jsonify, request
7+
from flask_cors import CORS
78

89
app = Flask(__name__, static_folder="../frontend/build", static_url_path="/")
910
CORS(app)

Diff for: example-apps/chatbot-rag-app/api/chat.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import json
22
import os
33

4-
from elasticsearch import Elasticsearch
4+
from elasticsearch_client import (
5+
elasticsearch_client,
6+
get_elasticsearch_chat_message_history,
7+
)
58
from flask import current_app, render_template, stream_with_context
69
from langchain_elasticsearch import (
7-
ElasticsearchChatMessageHistory,
810
ElasticsearchStore,
911
SparseVectorStrategy,
1012
)
11-
from langchain_openai import ChatOpenAI
1213
from llm_integrations import get_llm
13-
from elasticsearch_client import (
14-
elasticsearch_client,
15-
get_elasticsearch_chat_message_history,
16-
)
1714

1815
INDEX = os.getenv("ES_INDEX", "workplace-app-docs")
1916
INDEX_CHAT_HISTORY = os.getenv(

Diff for: example-apps/chatbot-rag-app/api/elasticsearch_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import os
2+
13
from elasticsearch import Elasticsearch
24
from langchain_elasticsearch import ElasticsearchChatMessageHistory
35

4-
import os
5-
66
ELASTICSEARCH_URL = os.getenv("ELASTICSEARCH_URL")
77
ELASTICSEARCH_USER = os.getenv("ELASTICSEARCH_USER")
88
ELASTICSEARCH_PASSWORD = os.getenv("ELASTICSEARCH_PASSWORD")

Diff for: example-apps/chatbot-rag-app/api/llm_integrations.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from langchain_openai import AzureChatOpenAI
2-
from langchain_openai import ChatOpenAI
3-
from langchain_google_vertexai import ChatVertexAI
4-
from langchain_cohere import ChatCohere
5-
from langchain_mistralai import ChatMistralAI
6-
from langchain_aws import ChatBedrock
7-
81
import os
2+
93
import vertexai
4+
from langchain_aws import ChatBedrock
5+
from langchain_cohere import ChatCohere
6+
from langchain_google_vertexai import ChatVertexAI
7+
from langchain_mistralai import ChatMistralAI
8+
from langchain_openai import AzureChatOpenAI, ChatOpenAI
109

1110
LLM_TYPE = os.getenv("LLM_TYPE", "openai")
1211

@@ -79,7 +78,7 @@ def init_cohere_chat(temperature):
7978

8079

8180
def get_llm(temperature=0):
82-
if not LLM_TYPE in MAP_LLM_TYPE_TO_CHAT_MODEL:
81+
if LLM_TYPE not in MAP_LLM_TYPE_TO_CHAT_MODEL:
8382
raise Exception(
8483
"LLM type not found. Please set LLM_TYPE to one of: "
8584
+ ", ".join(MAP_LLM_TYPE_TO_CHAT_MODEL.keys())

0 commit comments

Comments
 (0)