diff --git a/application/api/answer/routes.py b/application/api/answer/routes.py index 8f64a8f9..ae9ef71f 100644 --- a/application/api/answer/routes.py +++ b/application/api/answer/routes.py @@ -329,17 +329,20 @@ def api_answer(): else: # create new conversation # generate summary - messages_summary = [{"role": "assistant", "content": "Summarise following conversation in no more than 3 " - "words, respond ONLY with the summary, use the same " - "language as the system \n\nUser: " + question + "\n\n" + - "AI: " + - result["answer"]}, - {"role": "user", "content": "Summarise following conversation in no more than 3 words, " - "respond ONLY with the summary, use the same language as the " - "system"}] + messages_summary = [ + {"role": "assistant", "content": "Summarise following conversation in no more than 3 words, " + "respond ONLY with the summary, use the same language as the system \n\n" + "User: " + question + "\n\n" + "AI: " + result["answer"]}, + {"role": "user", "content": "Summarise following conversation in no more than 3 words, " + "respond ONLY with the summary, use the same language as the system"} + ] - completion = llm.gen(model=gpt_model, engine=settings.AZURE_DEPLOYMENT_NAME, - messages=messages_summary, max_tokens=30) + completion = llm.gen( + model=gpt_model, + engine=settings.AZURE_DEPLOYMENT_NAME, + messages=messages_summary, + max_tokens=30 + ) conversation_id = conversations_collection.insert_one( {"user": "local", "date": datetime.datetime.utcnow(), diff --git a/application/api/internal/routes.py b/application/api/internal/routes.py index 13c44724..ca6da174 100644 --- a/application/api/internal/routes.py +++ b/application/api/internal/routes.py @@ -1,7 +1,6 @@ import os import datetime -from flask import Blueprint, request, jsonify, send_from_directory -import requests +from flask import Blueprint, request, send_from_directory from pymongo import MongoClient from werkzeug.utils import secure_filename diff --git a/application/llm/base.py b/application/llm/base.py index 16c91303..e08a3b09 100644 --- a/application/llm/base.py +++ b/application/llm/base.py @@ -1,5 +1,4 @@ from abc import ABC, abstractmethod -import json class BaseLLM(ABC): diff --git a/application/vectorstore/base.py b/application/vectorstore/base.py index cf3623e4..ad481744 100644 --- a/application/vectorstore/base.py +++ b/application/vectorstore/base.py @@ -33,11 +33,17 @@ class BaseVectorStore(ABC): if embeddings_name == "openai_text-embedding-ada-002": if self.is_azure_configured(): os.environ["OPENAI_API_TYPE"] = "azure" - embedding_instance = embeddings_factory[embeddings_name](model=settings.AZURE_EMBEDDINGS_DEPLOYMENT_NAME) + embedding_instance = embeddings_factory[embeddings_name]( + model=settings.AZURE_EMBEDDINGS_DEPLOYMENT_NAME + ) else: - embedding_instance = embeddings_factory[embeddings_name](openai_api_key=embeddings_key) + embedding_instance = embeddings_factory[embeddings_name]( + openai_api_key=embeddings_key + ) elif embeddings_name == "cohere_medium": - embedding_instance = embeddings_factory[embeddings_name](cohere_api_key=embeddings_key) + embedding_instance = embeddings_factory[embeddings_name]( + cohere_api_key=embeddings_key + ) else: embedding_instance = embeddings_factory[embeddings_name]()