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.
main
Lasse Studion 2 years ago
parent d806b67ea9
commit da28a58aad
  1. 20
      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)

Loading…
Cancel
Save