ruff linting

This commit is contained in:
Alex 2023-09-27 18:01:40 +01:00
parent b8acb860aa
commit 852de8bdfc
4 changed files with 23 additions and 16 deletions

View File

@ -329,17 +329,20 @@ def api_answer():
else: else:
# create new conversation # create new conversation
# generate summary # generate summary
messages_summary = [{"role": "assistant", "content": "Summarise following conversation in no more than 3 " messages_summary = [
"words, respond ONLY with the summary, use the same " {"role": "assistant", "content": "Summarise following conversation in no more than 3 words, "
"language as the system \n\nUser: " + question + "\n\n" + "respond ONLY with the summary, use the same language as the system \n\n"
"AI: " + "User: " + question + "\n\n" + "AI: " + result["answer"]},
result["answer"]},
{"role": "user", "content": "Summarise following conversation in no more than 3 words, " {"role": "user", "content": "Summarise following conversation in no more than 3 words, "
"respond ONLY with the summary, use the same language as the " "respond ONLY with the summary, use the same language as the system"}
"system"}] ]
completion = llm.gen(model=gpt_model, engine=settings.AZURE_DEPLOYMENT_NAME, completion = llm.gen(
messages=messages_summary, max_tokens=30) model=gpt_model,
engine=settings.AZURE_DEPLOYMENT_NAME,
messages=messages_summary,
max_tokens=30
)
conversation_id = conversations_collection.insert_one( conversation_id = conversations_collection.insert_one(
{"user": "local", {"user": "local",
"date": datetime.datetime.utcnow(), "date": datetime.datetime.utcnow(),

View File

@ -1,7 +1,6 @@
import os import os
import datetime import datetime
from flask import Blueprint, request, jsonify, send_from_directory from flask import Blueprint, request, send_from_directory
import requests
from pymongo import MongoClient from pymongo import MongoClient
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename

View File

@ -1,5 +1,4 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
import json
class BaseLLM(ABC): class BaseLLM(ABC):

View File

@ -33,11 +33,17 @@ class BaseVectorStore(ABC):
if embeddings_name == "openai_text-embedding-ada-002": if embeddings_name == "openai_text-embedding-ada-002":
if self.is_azure_configured(): if self.is_azure_configured():
os.environ["OPENAI_API_TYPE"] = "azure" 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: 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": 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: else:
embedding_instance = embeddings_factory[embeddings_name]() embedding_instance = embeddings_factory[embeddings_name]()