Skip to content

chatbot-rag-app: polishes source file style and formatting #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example-apps/chatbot-rag-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
frontend/build
frontend/node_modules
api/__pycache__
api/.env
.venv
venv
.DS_Store
.DS_Store
.env
9 changes: 5 additions & 4 deletions example-apps/chatbot-rag-app/api/app.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 4 additions & 7 deletions example-apps/chatbot-rag-app/api/chat.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 2 additions & 2 deletions example-apps/chatbot-rag-app/api/elasticsearch_client.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
15 changes: 7 additions & 8 deletions example-apps/chatbot-rag-app/api/llm_integrations.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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())
Expand Down
Loading