From 671b9f481edc3d7ecf5c27d9ed9b2efd6714c237 Mon Sep 17 00:00:00 2001 From: T0xan <96002702+Touxan@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:23:12 +0100 Subject: [PATCH] Update gpt.py --- bunkoer/utils/gpt.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/bunkoer/utils/gpt.py b/bunkoer/utils/gpt.py index ce9e273..a964770 100644 --- a/bunkoer/utils/gpt.py +++ b/bunkoer/utils/gpt.py @@ -2,14 +2,6 @@ import json import os -from langchain.llms.openai import OpenAI -from langchain.embeddings.openai import OpenAIEmbeddings -from langchain.document_loaders.csv_loader import CSVLoader -from langchain.chains import RetrievalQA -from langchain.vectorstores import FAISS -from langchain.chat_models import ChatOpenAI - - def send_gpt_request(input_message, model, temperature, max_tokens): API_KEY = os.environ.get('OPENAI_API_KEY') API_ENDPOINT = "https://api.openai.com/v1/chat/completions" @@ -41,29 +33,3 @@ def send_gpt_request(input_message, model, temperature, max_tokens): else: raise Exception(f"[ERROR] Gpt request : {response.status_code}: {response.text}") -def embeding(temperature, model_name, user_input, base_file): - if os.path.isfile(base_file): - try: - loader = CSVLoader(file_path=base_file, encoding="utf-8") - data = loader.load() - except: - loader = CSVLoader(file_path=base_file, encoding="cp1252") - data = loader.load() - - embeddings = OpenAIEmbeddings() - vectors = FAISS.from_documents(data, embeddings) - llm = ChatOpenAI(temperature=temperature, model_name=model_name) - qa = RetrievalQA.from_chain_type(llm=llm, - chain_type="stuff", - retriever=vectors.as_retriever(), - verbose=True) - - def conversational_chat(query): - result = qa.run(query) - answer = result - return answer - - response_text = conversational_chat(user_input) - return response_text - else: - return "Error the file is empty"