diff --git a/edenai_apis/apis/openai/helpers.py b/edenai_apis/apis/openai/helpers.py index d9918534..5e2a01d9 100644 --- a/edenai_apis/apis/openai/helpers.py +++ b/edenai_apis/apis/openai/helpers.py @@ -7,25 +7,6 @@ from edenai_apis.utils.languages import get_language_name_from_code -def format_example_fn(x: List[List[str]]) -> str: - examples_formated = "" - for example in x: - examples_formated += "Text: {text}\nText Classification: {label}\n\n".format( - text=example[0].replace("\n", " ").strip(), - label=example[1].replace("\n", " ").strip(), - ) - return examples_formated - - -def format_texts_fn(x: List[str]) -> str: - texts_formated = "" - for text in x: - texts_formated += "Text: {text}\n-----\n".format( - text=text.replace("\n", " ").strip() - ) - return texts_formated - - def construct_classification_instruction( texts: list, labels: list, examples: list ) -> str: @@ -66,7 +47,6 @@ def formatted_text_classification(data): def construct_anonymization_context(text: str) -> str: - output_template = '{{"redactedText" : "...", "entities": [{{content: entity, label: category, confidence_score: confidence score, offset: start_offset}}]}}' prompt = f"""Please analyze the following text and identify any personal and sensitive information contained within it. For each instance of personal information, please provide a category and a confidence score. Categories could include, but should not be limited to, names, addresses, phone numbers, email addresses, social security numbers, enterprise name, any private information and credit card numbers. Use a confidence score between 0 and 1 to indicate how certain you are that the identified information is actually personal information. The text is included between three backticks. @@ -74,8 +54,6 @@ def construct_anonymization_context(text: str) -> str: The category must be one of the following: "name", "address", "phonenumber", "email", "social security number", "organization", "credit card number", "other". - Your output should be a json that looks like this : {output_template} - The text: ```{text}``` @@ -83,7 +61,6 @@ def construct_anonymization_context(text: str) -> str: """ return prompt - def construct_keyword_extraction_context(text: str) -> str: output_template = '{"items":[{"keyword": ... , "importance": ...}]}' prompt = f""" @@ -104,31 +81,39 @@ def construct_keyword_extraction_context(text: str) -> str: def construct_translation_context( text: str, source_language: str, target_language: str ) -> str: - prompt = f"Translate the following text from {get_language_name_from_code(source_language)} to {get_language_name_from_code(target_language)}:. text:\n###{text}###\ntranslation:" - return prompt + return f""" + Translate the following text from {get_language_name_from_code(source_language)} to {get_language_name_from_code(target_language)} + The text is written between three backticks. + Text: + ```{text}``` + Your Output: +""" def construct_language_detection_context(text: str) -> str: - prompt = "Detect the ISO 639-1 language (only the code) of this text.\n\n Text: ###{data}###\ISO 639-1:".format( - data=text - ) - return prompt + return f""" +Analyze the following text and determine the ISO 639-1 language code: +Please provide only the ISO 639-1 code as the output. +The text is written between three backticks. +```{text}``` +""" def construct_sentiment_analysis_context(text: str) -> str: - prompt = ( - f"Label the text below with one of these sentiments 'Positive','Negative','Neutral'.\n\nThe text is delimited by triple backticks text:\n ```" - + text - + "```\n\nYour label:" - ) - return prompt + return f""" + Analyze the following text and label it with one of these sentiments 'Postive', 'Negative', 'Neutral'. + The text is written between three backticks. + ```{text}``` +""" def construct_topic_extraction_context(text: str) -> str: - prompt = "What is the main taxonomy of the text below. text:###{data}###put the result in this line:\n\n".format( - data=text - ) - return prompt + return f""" + Analyze the following text and identify its main taxonomy. + The text is written between three backticks. + + ```{text}``` + """ def get_openapi_response(response: Response): @@ -183,16 +168,23 @@ def construct_ner_instruction(text: str) -> str: """ This function takes a text as input and returns a string that contains the instruction. """ - return f"""Please extract named entities, their types and a confidence score from the text below. The confidence score between 0 and 1. - -The text is delimited by triple backticks text. - -The output should be a json formatted like follows : {{"items":[{{"entity":"entity","category":"categrory","importance":score}}]}}\n - -The input text: + example_output = [ + {"Entity": "Barack Obama", "Type": "Person", "Confidence": 0.98}, + {"Entity": "44th President", "Type": "Position", "Confidence": 0.95}, + {"Entity": "United States", "Type": "Country", "Confidence": 0.99}, + ] + return f"""Please extract named entities, their types, and assign a confidence score between 0 and 1 from the following text. The text is enclosed within triple backticks. + +Input Text: ```{text}``` -Your output:" +For example, if the input text is: +```Barack Obama was the 44th President of the United States.``` + +Your output should be in the following format: +``` + {example_output} +``` """ @@ -425,6 +417,7 @@ def convert_tts_audio_rate(audio_rate: int) -> float: else: return ((audio_rate - 0) / (100 - 0)) * (4 - 1) + 1 + def finish_unterminated_json(json_string: str, end_brackets: str) -> str: """ take a cut json_string and try to terminate it diff --git a/edenai_apis/apis/openai/info.json b/edenai_apis/apis/openai/info.json index 70d97f8c..a1c92ea7 100644 --- a/edenai_apis/apis/openai/info.json +++ b/edenai_apis/apis/openai/info.json @@ -128,13 +128,12 @@ ], "allow_null_language": true, "models": [ - "text-davinci-003", - "text-davinci-002", - "text-curie-001", - "text-babbage-001", - "text-ada-001" + "gpt-4", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k" ], - "default_model": "text-davinci-003" + "default_model": "gpt-3.5-turbo-1106" }, "version": "v3.0.0" }, diff --git a/edenai_apis/apis/openai/openai_text_api.py b/edenai_apis/apis/openai/openai_text_api.py index ec74f23c..18a24ed0 100644 --- a/edenai_apis/apis/openai/openai_text_api.py +++ b/edenai_apis/apis/openai/openai_text_api.py @@ -82,23 +82,28 @@ class OpenaiTextApi(TextInterface): def text__summarize( self, text: str, output_sentences: int, language: str, model: str ) -> ResponseType[SummarizeDataClass]: - if not model: - model = self.model - - url = f"{self.url}/engines/{model}/completions" + url = f"{self.url}/chat/completions" + prompt = f"{text}\n\nTl;dr" + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as a PII system that takes a text input containing personally identifiable information (PII) and generates an anonymized version of the text, + """, + }, + ) + # Build the request payload = { - "prompt": text + "\n\nTl;dr", - "max_tokens": self.max_tokens, - "temperature": 0.0, - "frequency_penalty": 0.0, - "presence_penalty": 0.0, + "model": model, + "messages": messages, } response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) standardized_response = SummarizeDataClass( - result=original_response["choices"][0]["text"] + result=original_response["choices"][0]["message"]["content"] ) result = ResponseType[SummarizeDataClass]( @@ -212,11 +217,7 @@ def text__question_answer( examples: List[List[str]], model: Optional[str], ) -> ResponseType[QuestionAnswerDataClass]: - if not model: - model = self.model - url = f"{self.url}/completions" - # With search get the top document with the question & construct the context document = self.text__search(texts, question).model_dump() context = document["standardized_response"]["items"][0]["document"] @@ -234,7 +235,7 @@ def text__question_answer( + "\nA:" ] payload = { - "model": model, + "model": self.model, "prompt": prompts, "max_tokens": 100, "temperature": temperature, @@ -258,27 +259,29 @@ def text__question_answer( def text__anonymization( self, text: str, language: str ) -> ResponseType[AnonymizationDataClass]: - url = f"{self.url}/completions" prompt = construct_anonymization_context(text) + json_output = '{{"redactedText" : "...", "entities": [{{content: entity, label: category, confidence_score: confidence score, offset: start_offset}}]}}' + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as a PII system that takes a text input containing personally identifiable information (PII) and generates an anonymized version of the text, + you return a JSON object in this format : {json_output}""", + }, + ) + # Build the request payload = { - "prompt": prompt, - "model": self.model, - "max_tokens": 2048, - "temperature": 0.0, - "frequency_penalty": 0.0, - "presence_penalty": 0.0, + "response_format": {"type": "json_object"}, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } + url = f"{self.url}/chat/completions" response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) - - data = ( - original_response["choices"][0]["text"] - .replace("\n\n", " ") - .replace("\n", "") - .strip() - ) + pii_data = original_response["choices"][0]["message"]["content"] try: - data_dict = json.loads(rf"{data}") + data_dict = json.loads(rf"{pii_data}") except json.JSONDecodeError: raise ProviderException("An error occurred while parsing the response.") new_text = text @@ -373,23 +376,37 @@ def text__keyword_extraction( def text__sentiment_analysis( self, language: str, text: str ) -> ResponseType[SentimentAnalysisDataClass]: - url = f"{self.url}/completions" + url = f"{self.url}/chat/completions" prompt = construct_sentiment_analysis_context(text) + json_output = {"general_sentiment":"Positive", "general_sentiment_rate": 0.8} + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as sentiment analysis model capable of analyzing text data and providing a generalized sentiment label. + you return a JSON object in this format : {json_output}""", + }, + ) + # Build the request payload = { - "prompt": prompt, - "model": self.model, - "temperature": 0, - "logprobs": 1, + "response_format": {"type": "json_object"}, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) + sentiments_content = original_response["choices"][0]["message"]["content"] + try: + sentiments = json.loads(sentiments_content) + except (KeyError, json.JSONDecodeError) as exc: + raise ProviderException( + "An error occurred while parsing the response." + ) from exc - # Create output response - # Get score - score = np.exp(original_response["choices"][0]["logprobs"]["token_logprobs"][0]) standarize = SentimentAnalysisDataClass( - general_sentiment=original_response["choices"][0]["text"][1:], - general_sentiment_rate=float(score), + general_sentiment=sentiments['general_sentiment'], + general_sentiment_rate=sentiments['general_sentiment_rate'], ) return ResponseType[SentimentAnalysisDataClass]( @@ -399,29 +416,35 @@ def text__sentiment_analysis( def text__topic_extraction( self, language: str, text: str ) -> ResponseType[TopicExtractionDataClass]: - url = f"{self.url}/completions" - + url = f"{self.url}/chat/completions" prompt = construct_topic_extraction_context(text) + json_output = {"items":[{"category":"categrory","importance": 0.9}]} + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as a taxonomy extractor model to automatically identify and categorize hierarchical relationships within a given body of text. + you return a JSON object in this format : {json_output}""", + }, + ) + # Build the request payload = { - "prompt": prompt, - "max_tokens": self.max_tokens, - "model": self.model, - "logprobs": 1, - "temperature": 0, + "response_format": {"type": "json_object"}, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) - - # Create output response - # Get score - score = np.exp(original_response["choices"][0]["logprobs"]["token_logprobs"][0]) - categories: Sequence[ExtractedTopic] = [] - categories.append( - ExtractedTopic( - category=original_response["choices"][0]["text"], - importance=float(score), - ) - ) + topics_data = original_response["choices"][0]["message"]["content"] + try: + categories_data = json.loads(topics_data) + except (KeyError, json.JSONDecodeError) as exc: + raise ProviderException( + "An error occurred while parsing the response." + ) from exc + categories = categories_data.get('items', []) + standarized_response = TopicExtractionDataClass(items=categories) return ResponseType[TopicExtractionDataClass]( @@ -629,27 +652,34 @@ def text__spell_check( def text__named_entity_recognition( self, language: str, text: str ) -> ResponseType[NamedEntityRecognitionDataClass]: - url = f"{self.url}/completions" - + url = f"{self.url}/chat/completions" prompt = construct_ner_instruction(text) - + json_output = {"items":[{"entity":"entity","category":"categrory","importance":"score"}]} + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as a Named Entity Recognition model that indentify and classify named entities within a given text. + you return a JSON object in this format : {json_output}""", + }, + ) + # Build the request payload = { - "n": 1, - "model": self.model, - "max_tokens": 500, - "temperature": 0.0, - "prompt": prompt, + "response_format": {"type": "json_object"}, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) - + entities_data = original_response["choices"][0]["message"]["content"] try: - original_items = json.loads(original_response["choices"][0]["text"]) + original_items = json.loads(entities_data) except (KeyError, json.JSONDecodeError) as exc: raise ProviderException( "An error occurred while parsing the response." ) from exc - + return ResponseType[NamedEntityRecognitionDataClass]( original_response=original_response, standardized_response=NamedEntityRecognitionDataClass( diff --git a/edenai_apis/apis/openai/openai_translation_api.py b/edenai_apis/apis/openai/openai_translation_api.py index de728d36..264b42fe 100644 --- a/edenai_apis/apis/openai/openai_translation_api.py +++ b/edenai_apis/apis/openai/openai_translation_api.py @@ -1,17 +1,14 @@ -from typing import Sequence -import numpy as np import requests - +import json from edenai_apis.features import TranslationInterface from edenai_apis.features.translation.automatic_translation import ( AutomaticTranslationDataClass, ) from edenai_apis.features.translation.language_detection import ( LanguageDetectionDataClass, - InfosLanguageDetectionDataClass, ) -from edenai_apis.utils.languages import get_language_name_from_code +from edenai_apis.utils.exception import ProviderException from edenai_apis.utils.types import ResponseType from .helpers import ( get_openapi_response, @@ -24,55 +21,62 @@ class OpenaiTranslationApi(TranslationInterface): def translation__language_detection( self, text: str ) -> ResponseType[LanguageDetectionDataClass]: - url = f"{self.url}/completions" + url = f"{self.url}/chat/completions" prompt = construct_language_detection_context(text) + json_output = {"items" : [{"language" : "isocode", "display_name": "language display name", "confidence" : 0.8}]} + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as language detection model capable of automatically identifying the language of a given text. + you return a JSON object in this format : {json_output}""", + }, + ) + # Build the request payload = { - "prompt": prompt, - "max_tokens": self.max_tokens, - "model": self.model, - "temperature": 0, - "logprobs": 1, + "response_format": {"type": "json_object"}, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } - response = requests.post( - url, json=payload, headers=self.headers - ) + response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) - - items: Sequence[InfosLanguageDetectionDataClass] = [] - - score = np.exp(original_response["choices"][0]["logprobs"]["token_logprobs"][0]) - # replace are necessary to keep only language code - isocode = original_response["choices"][0]["text"].replace(" ", "") - items.append( - InfosLanguageDetectionDataClass( - language=isocode, - display_name=get_language_name_from_code(isocode=isocode), - confidence=float(score), - ) - ) - + languages = original_response["choices"][0]["message"]["content"] + try: + data = json.loads(languages) + except (KeyError, json.JSONDecodeError) as exc: + raise ProviderException( + "An error occurred while parsing the response." + ) from exc return ResponseType[LanguageDetectionDataClass]( original_response=original_response, - standardized_response=LanguageDetectionDataClass(items=items), + standardized_response=LanguageDetectionDataClass(items=data.get('items')), ) def translation__automatic_translation( self, source_language: str, target_language: str, text: str ) -> ResponseType[AutomaticTranslationDataClass]: - url = f"{self.url}/completions" + url = f"{self.url}/chat/completions" prompt = construct_translation_context(text, source_language, target_language) + messages = [{"role": "user", "content": prompt}] + messages.insert( + 0, + { + "role": "system", + "content": f"""Act as an automatic translation model capable of translating text from one language to another with high accuracy and fluency.""", + }, + ) + # Build the request payload = { - "prompt": prompt, - "max_tokens": self.max_tokens, - "model": self.model, + "model": "gpt-3.5-turbo-1106", + "messages": messages, } - response = requests.post( - url, json=payload, headers=self.headers - ) + response = requests.post(url, json=payload, headers=self.headers) original_response = get_openapi_response(response) + translation = original_response["choices"][0]["message"]["content"] standardized = AutomaticTranslationDataClass( - text=original_response["choices"][0]["text"] + text=translation ) return ResponseType[AutomaticTranslationDataClass]( diff --git a/edenai_apis/apis/openai/outputs/text/anonymization_output.json b/edenai_apis/apis/openai/outputs/text/anonymization_output.json index 42c33013..0fb60159 100644 --- a/edenai_apis/apis/openai/outputs/text/anonymization_output.json +++ b/edenai_apis/apis/openai/outputs/text/anonymization_output.json @@ -1,22 +1,25 @@ { "original_response": { - "id": "cmpl-8AdGWNiwBiXJjFfaAoafs1cWyCugW", - "object": "text_completion", - "created": 1697544908, - "model": "gpt-3.5-turbo-instruct", + "id": "chatcmpl-8NjwRrJrVd7t3mdcuICmpBeH05bDF", + "object": "chat.completion", + "created": 1700668835, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": "\n{\n \"redactedText\": \"The phone number of Luc is the ** ** ** ** ** **.\",\n \"entities\": [\n {\n \"content\": \"Luc\",\n \"label\": \"name\",\n \"confidence_score\": 1.0,\n \"offset\": 20\n },\n {\n \"content\": \"06 21 32 43 54\",\n \"label\": \"phonenumber\",\n \"confidence_score\": 1.0,\n \"offset\": 31\n }\n ]\n}", "index": 0, - "logprobs": null, + "message": { + "role": "assistant", + "content": "{\n \"redactedText\": \"The phone number of *** is the ** ** ** ** ** ** ** **.\",\n \"entities\": [\n {\n \"content\": \"Luc\",\n \"label\": \"name\",\n \"confidence_score\": 0.9,\n \"offset\": 20\n },\n {\n \"content\": \"06 21 32 43 54\",\n \"label\": \"phonenumber\",\n \"confidence_score\": 0.95,\n \"offset\": 32\n }\n ]\n}" + }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 259, - "completion_tokens": 110, - "total_tokens": 369 - } + "prompt_tokens": 298, + "completion_tokens": 111, + "total_tokens": 409 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { "result": "The phone number of *** is the **************.", @@ -28,7 +31,7 @@ "subcategory": "Name", "original_label": "name", "content": "Luc", - "confidence_score": 1.0 + "confidence_score": 0.9 }, { "offset": 31, @@ -37,7 +40,7 @@ "subcategory": "Phone", "original_label": "phonenumber", "content": "06 21 32 43 54", - "confidence_score": 1.0 + "confidence_score": 0.95 } ] } diff --git a/edenai_apis/apis/openai/outputs/text/named_entity_recognition_output.json b/edenai_apis/apis/openai/outputs/text/named_entity_recognition_output.json index 1d1432ee..fe52696e 100644 --- a/edenai_apis/apis/openai/outputs/text/named_entity_recognition_output.json +++ b/edenai_apis/apis/openai/outputs/text/named_entity_recognition_output.json @@ -1,89 +1,67 @@ { "original_response": { - "id": "cmpl-834JQRc4TvAuTEpzNSg3VEX1hy3T7", - "object": "text_completion", - "created": 1695742252, - "model": "gpt-3.5-turbo-instruct", + "id": "chatcmpl-8NkPf4JnTvVpdnWYEUWNWZHWxhflP", + "object": "chat.completion", + "created": 1700670647, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": "\n{\"items\":[{\"entity\":\"Barack Hussein Obama\",\"category\":\"person\",\"importance\":1},{\"entity\":\"American\",\"category\":\"nationality\",\"importance\":0.9},{\"entity\":\"politician\",\"category\":\"occupation\",\"importance\":0.8},{\"entity\":\"44th\",\"category\":\"ordinal number\",\"importance\":0.7},{\"entity\":\"United States\",\"category\":\"country\",\"importance\":1},{\"entity\":\"2009\",\"category\":\"year\",\"importance\":0.6},{\"entity\":\"2017\",\"category\":\"year\",\"importance\":0.6},{\"entity\":\"Democratic Party\",\"category\":\"political party\",\"importance\":0.9},{\"entity\":\"African-American\",\"category\":\"ethnicity\",\"importance\":0.9},{\"entity\":\"U.S. senator\",\"category\":\"occupation\",\"importance\":0.8},{\"entity\":\"Illinois\",\"category\":\"state\",\"importance\":0.9},{\"entity\":\"1997\",\"category\":\"year\",\"importance\":0.6},{\"entity\":\"2004\",\"category\":\"year\",\"importance\":0.6}]}", "index": 0, - "logprobs": null, + "message": { + "role": "assistant", + "content": "{\n \"items\": [\n {\"entity\": \"Barack Hussein Obama\", \"category\": \"Person\", \"importance\": \"0.98\"},\n {\"entity\": \"American\", \"category\": \"Nationality\", \"importance\": \"0.85\"},\n {\"entity\": \"44th president\", \"category\": \"Position\", \"importance\": \"0.95\"},\n {\"entity\": \"United States\", \"category\": \"Country\", \"importance\": \"0.99\"},\n {\"entity\": \"Democratic Party\", \"category\": \"Organization\", \"importance\": \"0.90\"},\n {\"entity\": \"African-American\", \"category\": \"Ethnicity\", \"importance\": \"0.85\"},\n {\"entity\": \"U.S. senator\", \"category\": \"Position\", \"importance\": \"0.90\"},\n {\"entity\": \"Illinois\", \"category\": \"State\", \"importance\": \"0.93\"}\n ]\n}" + }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 158, - "completion_tokens": 217, - "total_tokens": 375 - } + "prompt_tokens": 296, + "completion_tokens": 201, + "total_tokens": 497 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { "items": [ { "entity": "Barack Hussein Obama", - "category": "person", - "importance": 1.0 + "category": "Person", + "importance": 0.98 }, { "entity": "American", - "category": "nationality", - "importance": 0.9 - }, - { - "entity": "politician", - "category": "occupation", - "importance": 0.8 + "category": "Nationality", + "importance": 0.85 }, { - "entity": "44th", - "category": "ordinal number", - "importance": 0.7 + "entity": "44th president", + "category": "Position", + "importance": 0.95 }, { "entity": "United States", - "category": "country", - "importance": 1.0 - }, - { - "entity": "2009", - "category": "year", - "importance": 0.6 - }, - { - "entity": "2017", - "category": "year", - "importance": 0.6 + "category": "Country", + "importance": 0.99 }, { "entity": "Democratic Party", - "category": "political party", + "category": "Organization", "importance": 0.9 }, { "entity": "African-American", - "category": "ethnicity", - "importance": 0.9 + "category": "Ethnicity", + "importance": 0.85 }, { "entity": "U.S. senator", - "category": "occupation", - "importance": 0.8 - }, - { - "entity": "Illinois", - "category": "state", + "category": "Position", "importance": 0.9 }, { - "entity": "1997", - "category": "year", - "importance": 0.6 - }, - { - "entity": "2004", - "category": "year", - "importance": 0.6 + "entity": "Illinois", + "category": "State", + "importance": 0.93 } ] } diff --git a/edenai_apis/apis/openai/outputs/text/sentiment_analysis_output.json b/edenai_apis/apis/openai/outputs/text/sentiment_analysis_output.json index d93c7f31..84006479 100644 --- a/edenai_apis/apis/openai/outputs/text/sentiment_analysis_output.json +++ b/edenai_apis/apis/openai/outputs/text/sentiment_analysis_output.json @@ -1,65 +1,29 @@ { "original_response": { - "id": "cmpl-6gxZYNBxcodhbnirO0aNqgImAYhCn", - "object": "text_completion", - "created": 1675696792, - "model": "text-davinci-003", + "id": "chatcmpl-8Nzz5JLVfwVd9kHUfamhLja0TEwrC", + "object": "chat.completion", + "created": 1700730503, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": " Neutral", "index": 0, - "logprobs": { - "tokens": [ - " Neutral", - "<|endoftext|>", - " \u00a7\u00a7", - " FILE", - " READ" - ], - "token_logprobs": [ - -0.00073687645, - -1.6282536e-05, - -0.06840639, - -0.0008294575, - -1.2257966 - ], - "top_logprobs": [ - { - " Neutral": -0.00073687645 - }, - { - "<|endoftext|>": -1.6282536e-05 - }, - { - " \u00a7\u00a7": -0.06840639 - }, - { - " FILE": -0.0008294575 - }, - { - " READ": -1.2257966 - } - ], - "text_offset": [ - 669, - 677, - 677, - 677, - 677 - ] + "message": { + "role": "assistant", + "content": "{\n \"general_sentiment\": \"Negative\",\n \"general_sentiment_rate\": 0.3\n}" }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 139, - "completion_tokens": 1, - "total_tokens": 140 - } + "prompt_tokens": 208, + "completion_tokens": 23, + "total_tokens": 231 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { - "general_sentiment": "Neutral", - "general_sentiment_rate": 1.0, + "general_sentiment": "Negative", + "general_sentiment_rate": 0.3, "items": [] } } \ No newline at end of file diff --git a/edenai_apis/apis/openai/outputs/text/summarize_output.json b/edenai_apis/apis/openai/outputs/text/summarize_output.json index 54e2ecbf..bac266e1 100644 --- a/edenai_apis/apis/openai/outputs/text/summarize_output.json +++ b/edenai_apis/apis/openai/outputs/text/summarize_output.json @@ -1,25 +1,27 @@ { "original_response": { - "warning": "This model version is deprecated. Migrate before January 4, 2024 to avoid disruption of service. Learn more https://platform.openai.com/docs/deprecations", - "id": "cmpl-834N5nr5EmRqFNESdR1LKC8tVWvRb", - "object": "text_completion", - "created": 1695742479, - "model": "text-davinci-003", + "id": "chatcmpl-8O2HUflyeTJc0V8gqfdhxnPFiAqGA", + "object": "chat.completion", + "created": 1700739332, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": ": Barack Obama was the 44th president of the United States, the first African-American president, and a member of the Democratic Party. He previously served as a U.S. senator from Illinois and an Illinois state senator.", "index": 0, - "logprobs": null, + "message": { + "role": "assistant", + "content": "Castle is an American series produced by ABC Studios and first released in 2009. It has a total of four seasons and 63 episodes, with the fourth season set to be released soon. The show stars Nathan Fillion and has been a popular success." + }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 77, - "completion_tokens": 46, - "total_tokens": 123 - } + "prompt_tokens": 109, + "completion_tokens": 52, + "total_tokens": 161 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { - "result": ": Barack Obama was the 44th president of the United States, the first African-American president, and a member of the Democratic Party. He previously served as a U.S. senator from Illinois and an Illinois state senator." + "result": "Castle is an American series produced by ABC Studios and first released in 2009. It has a total of four seasons and 63 episodes, with the fourth season set to be released soon. The show stars Nathan Fillion and has been a popular success." } } \ No newline at end of file diff --git a/edenai_apis/apis/openai/outputs/text/topic_extraction_output.json b/edenai_apis/apis/openai/outputs/text/topic_extraction_output.json index ae3e49d1..42910d64 100644 --- a/edenai_apis/apis/openai/outputs/text/topic_extraction_output.json +++ b/edenai_apis/apis/openai/outputs/text/topic_extraction_output.json @@ -1,67 +1,39 @@ { "original_response": { - "id": "cmpl-6gxkaG86y8XvjK1yt5mfFwnj3xoBZ", - "object": "text_completion", - "created": 1675697476, - "model": "text-davinci-003", + "id": "chatcmpl-8NkjsJ2cb7KGBXzcc8KQIuBaJCfeL", + "object": "chat.completion", + "created": 1700671900, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": "Entertainment", "index": 0, - "logprobs": { - "tokens": [ - "Enter", - "tainment", - "<|endoftext|>", - "PR", - "ODUCT" - ], - "token_logprobs": [ - -0.19650418, - -0.00012143587, - -0.0875351, - -9.552297, - -0.9571661 - ], - "top_logprobs": [ - { - "Enter": -0.19650418 - }, - { - "tainment": -0.00012143587 - }, - { - "<|endoftext|>": -0.0875351 - }, - { - " \u00a7\u00a7": -0.34399268 - }, - { - "ODUCT": -0.9571661 - } - ], - "text_offset": [ - 181, - 186, - 194, - 194, - 194 - ] + "message": { + "role": "assistant", + "content": "\n{\n \"items\": [\n {\n \"category\": \"Entertainment\",\n \"importance\": 0.9\n },\n {\n \"category\": \"Film Industry\",\n \"importance\": 0.8\n },\n {\n \"category\": \"Television\",\n \"importance\": 0.7\n }\n ]\n}" }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 43, - "completion_tokens": 2, - "total_tokens": 45 - } + "prompt_tokens": 112, + "completion_tokens": 76, + "total_tokens": 188 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { "items": [ { "category": "Entertainment", - "importance": 0.82 + "importance": 0.9 + }, + { + "category": "Film Industry", + "importance": 0.8 + }, + { + "category": "Television", + "importance": 0.7 } ] } diff --git a/edenai_apis/apis/openai/outputs/translation/automatic_translation_output.json b/edenai_apis/apis/openai/outputs/translation/automatic_translation_output.json index 8bdfb5c7..67263445 100644 --- a/edenai_apis/apis/openai/outputs/translation/automatic_translation_output.json +++ b/edenai_apis/apis/openai/outputs/translation/automatic_translation_output.json @@ -1,24 +1,27 @@ { "original_response": { - "id": "cmpl-834OeugMnbwFsjBD2LxNb9HeJQcXk", - "object": "text_completion", - "created": 1695742576, - "model": "gpt-3.5-turbo-instruct", + "id": "chatcmpl-8O2Cg7YCvk3hub78dnCBb6ZYhp7vT", + "object": "chat.completion", + "created": 1700739034, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": " Artificial intelligence, also known as intelligent machines, refers to the intelligence exhibited by machines created by humans. Usually, artificial intelligence refers to the technology that attempts to replicate human intelligence through computer programs. The term also refers to the research of whether such intelligent systems can be realized and how they can be realized. At the same time, with advances in fields such as medicine, neuroscience, robotics, and statistics, it is believed that many human professions may gradually be replaced by it.", "index": 0, - "logprobs": null, + "message": { + "role": "assistant", + "content": "```Artificial intelligence, also known as machine intelligence, refers to the intelligence exhibited by machines created by humans. Usually, artificial intelligence refers to the technology that presents human intelligence through ordinary computer programs. The term also refers to the research on whether such intelligent systems can be realized and how to achieve them. At the same time, with advancements in fields such as medicine, neuroscience, robotics, and statistics, it is commonly predicted that many human professions will gradually be replaced by artificial intelligence.```" + }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 220, - "completion_tokens": 94, - "total_tokens": 314 - } + "prompt_tokens": 270, + "completion_tokens": 97, + "total_tokens": 367 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { - "text": " Artificial intelligence, also known as intelligent machines, refers to the intelligence exhibited by machines created by humans. Usually, artificial intelligence refers to the technology that attempts to replicate human intelligence through computer programs. The term also refers to the research of whether such intelligent systems can be realized and how they can be realized. At the same time, with advances in fields such as medicine, neuroscience, robotics, and statistics, it is believed that many human professions may gradually be replaced by it." + "text": "```Artificial intelligence, also known as machine intelligence, refers to the intelligence exhibited by machines created by humans. Usually, artificial intelligence refers to the technology that presents human intelligence through ordinary computer programs. The term also refers to the research on whether such intelligent systems can be realized and how to achieve them. At the same time, with advancements in fields such as medicine, neuroscience, robotics, and statistics, it is commonly predicted that many human professions will gradually be replaced by artificial intelligence.```" } } \ No newline at end of file diff --git a/edenai_apis/apis/openai/outputs/translation/language_detection_output.json b/edenai_apis/apis/openai/outputs/translation/language_detection_output.json index 04becf5c..d5beeb87 100644 --- a/edenai_apis/apis/openai/outputs/translation/language_detection_output.json +++ b/edenai_apis/apis/openai/outputs/translation/language_detection_output.json @@ -1,50 +1,32 @@ { "original_response": { - "id": "cmpl-6gx87aQ4tfJs2lIbKcyVJCJifees5", - "object": "text_completion", - "created": 1675695091, - "model": "text-davinci-003", + "id": "chatcmpl-8O20GGzcSGTmwRzGodPa59wq31JCe", + "object": "chat.completion", + "created": 1700738264, + "model": "gpt-3.5-turbo-1106", "choices": [ { - "text": " it", "index": 0, - "logprobs": { - "tokens": [ - " it", - "<|endoftext|>" - ], - "token_logprobs": [ - -0.07574644, - -0.00047410018 - ], - "top_logprobs": [ - { - " it": -0.07574644 - }, - { - "<|endoftext|>": -0.00047410018 - } - ], - "text_offset": [ - 898, - 901 - ] + "message": { + "role": "assistant", + "content": "{\n \"items\": [\n {\n \"language\": \"it\",\n \"display_name\": \"Italian\",\n \"confidence\": 1.0\n }\n ]\n}" }, "finish_reason": "stop" } ], "usage": { - "prompt_tokens": 325, - "completion_tokens": 1, - "total_tokens": 326 - } + "prompt_tokens": 332, + "completion_tokens": 37, + "total_tokens": 369 + }, + "system_fingerprint": "fp_eeff13170a" }, "standardized_response": { "items": [ { "language": "it", "display_name": "Italian", - "confidence": 0.93 + "confidence": 1.0 } ] }