Fixed response/JSON

This commit is contained in:
2024-01-08 00:28:20 +01:00
parent b7a0e5478c
commit 54a41046ce
4 changed files with 23 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ from langchain.embeddings import OpenAIEmbeddings
from vectData import get_specific_data, modify_similar_data, insert_data, preparing_articles, calculate_cosine_similarity,get_titles_links_embeddings
from scrapingsingle import num_tokens_from_string, slice_text_at_2k_tokens
import json
from json_repair import repair_json
load_dotenv()
@@ -16,7 +17,6 @@ embeddings = OpenAIEmbeddings()
print(f"Checking for similar!")
def find_and_group_similar_articles(eps=0.5, min_samples=2, threshold=0.95):
try:
titles, links, embeddings = get_titles_links_embeddings()
@@ -142,7 +142,6 @@ def processing_similar():
else:
user_message = rf"Here are 3 texts {text1} {text2} and {text3}, combine the following texts into a cohesive news remove any non-news related to both texts and provide the cleaned data as a JSON only with single 'content' field."
if l == 4:
print("4")
a_one = articles[0][0]
a_two = articles[1][0]
a_three = articles[2][0]
@@ -220,6 +219,8 @@ def processing_similar():
])
generated_text = completion.choices[0].message.content
generated_text = repair_json(generated_text)
response_data = json.loads(generated_text)
title = a_one
text = response_data["content"]