From da28a58aad7dcf9aa84a7a1acf8237a2addc71a2 Mon Sep 17 00:00:00 2001 From: Lasse Studion Date: Thu, 30 May 2024 14:29:10 +0200 Subject: [PATCH] ```text feat: Add Ollama sentiment analysis and argument generation to speech processing This commit adds functionality to the `llm_sentiment.py` script for sentiment analysis and argument generation using the Ollama library. The script now generates sentiment scores for each speech and stores them in the `llm_sentiment` field of the speech dictionary. Additionally, the script generates a list of arguments related to electric vehicles mentioned in each speech and stores them in the `llm_arguments` field. Finally, a detailed summary of what is said about electric vehicles in each speech is generated and stored in the `llm_summary` field. These changes enhance the speech processing capabilities by providing sentiment analysis and extracting relevant arguments and summaries related to electric vehicles. --- llm_sentiment.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/llm_sentiment.py b/llm_sentiment.py index b544f6e..ee8092b 100644 --- a/llm_sentiment.py +++ b/llm_sentiment.py @@ -20,5 +20,23 @@ for speech in speeches: Asnwer ONLY with 'positive', 'negative' or 'neutral', NOTHING else. ''' sentiment = ollama.generate(prompt=prompt) - speech['sentiment'] = sentiment + + speech['llm_sentiment'] = sentiment.lower() + + prompt = f'''In the speech below something related to electric vehicles is mentioned.\n + """{text}"""\n + Please give me a list of all arguments related to electric vehicles in the text above. One argument per line. + Answer ONLY with the arguments, no greeting or explanation. Keep to the information in the text. + ''' + arguments = ollama.generate(prompt=prompt) + arguments_list = arguments.split('\n') + speech['llm_arguments'] = arguments_list + + prompt = f'''In the speech below something related to electric vehicles is mentioned.\n + """{text}"""\n + What is said about electric vehicles in the text above? Give me a detailed summary and keep to the information in the text. + ''' + summary = ollama.generate(prompt=prompt) + speech['llm_summary'] = summary + arango.update_ev_document(speech)