diff --git a/example-apps/chatbot-rag-app/.gitignore b/example-apps/chatbot-rag-app/.gitignore index 07f30e71..180c13f0 100644 --- a/example-apps/chatbot-rag-app/.gitignore +++ b/example-apps/chatbot-rag-app/.gitignore @@ -1,7 +1,7 @@ frontend/build frontend/node_modules api/__pycache__ -api/.env .venv venv -.DS_Store \ No newline at end of file +.DS_Store +.env diff --git a/example-apps/chatbot-rag-app/api/app.py b/example-apps/chatbot-rag-app/api/app.py index fcc12896..826b6349 100644 --- a/example-apps/chatbot-rag-app/api/app.py +++ b/example-apps/chatbot-rag-app/api/app.py @@ -1,9 +1,10 @@ -from flask import Flask, jsonify, request, Response -from flask_cors import CORS -from uuid import uuid4 -from chat import ask_question import os import sys +from uuid import uuid4 + +from chat import ask_question +from flask import Flask, Response, jsonify, request +from flask_cors import CORS app = Flask(__name__, static_folder="../frontend/build", static_url_path="/") CORS(app) diff --git a/example-apps/chatbot-rag-app/api/chat.py b/example-apps/chatbot-rag-app/api/chat.py index a548ae87..c5916783 100644 --- a/example-apps/chatbot-rag-app/api/chat.py +++ b/example-apps/chatbot-rag-app/api/chat.py @@ -1,19 +1,16 @@ import json import os -from elasticsearch import Elasticsearch +from elasticsearch_client import ( + elasticsearch_client, + get_elasticsearch_chat_message_history, +) from flask import current_app, render_template, stream_with_context from langchain_elasticsearch import ( - ElasticsearchChatMessageHistory, ElasticsearchStore, SparseVectorStrategy, ) -from langchain_openai import ChatOpenAI from llm_integrations import get_llm -from elasticsearch_client import ( - elasticsearch_client, - get_elasticsearch_chat_message_history, -) INDEX = os.getenv("ES_INDEX", "workplace-app-docs") INDEX_CHAT_HISTORY = os.getenv( diff --git a/example-apps/chatbot-rag-app/api/elasticsearch_client.py b/example-apps/chatbot-rag-app/api/elasticsearch_client.py index 8ce11d0e..68a3b914 100644 --- a/example-apps/chatbot-rag-app/api/elasticsearch_client.py +++ b/example-apps/chatbot-rag-app/api/elasticsearch_client.py @@ -1,8 +1,8 @@ +import os + from elasticsearch import Elasticsearch from langchain_elasticsearch import ElasticsearchChatMessageHistory -import os - ELASTICSEARCH_URL = os.getenv("ELASTICSEARCH_URL") ELASTICSEARCH_USER = os.getenv("ELASTICSEARCH_USER") ELASTICSEARCH_PASSWORD = os.getenv("ELASTICSEARCH_PASSWORD") diff --git a/example-apps/chatbot-rag-app/api/llm_integrations.py b/example-apps/chatbot-rag-app/api/llm_integrations.py index d760339a..ac34f1be 100644 --- a/example-apps/chatbot-rag-app/api/llm_integrations.py +++ b/example-apps/chatbot-rag-app/api/llm_integrations.py @@ -1,12 +1,11 @@ -from langchain_openai import AzureChatOpenAI -from langchain_openai import ChatOpenAI -from langchain_google_vertexai import ChatVertexAI -from langchain_cohere import ChatCohere -from langchain_mistralai import ChatMistralAI -from langchain_aws import ChatBedrock - import os + import vertexai +from langchain_aws import ChatBedrock +from langchain_cohere import ChatCohere +from langchain_google_vertexai import ChatVertexAI +from langchain_mistralai import ChatMistralAI +from langchain_openai import AzureChatOpenAI, ChatOpenAI LLM_TYPE = os.getenv("LLM_TYPE", "openai") @@ -79,7 +78,7 @@ def init_cohere_chat(temperature): def get_llm(temperature=0): - if not LLM_TYPE in MAP_LLM_TYPE_TO_CHAT_MODEL: + if LLM_TYPE not in MAP_LLM_TYPE_TO_CHAT_MODEL: raise Exception( "LLM type not found. Please set LLM_TYPE to one of: " + ", ".join(MAP_LLM_TYPE_TO_CHAT_MODEL.keys())