import os import openai from dotenv import load_dotenv load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") def get_comparison(iu_course,foreign_course,model_name:str="gpt-3.5-turbo")->str|None: try: completion = openai.ChatCompletion.create( model=model_name, messages=[ {"role": "system", "content": f""" You are comparing one educational module between IU - International University of Applied Sciences and one module of another university for equivalency. The module of the other university may include several submodules, all submodules count as one. User will provide a description of the module of another university and your job is to figure out, if this module is equivalent to the IU module. List which key competencies in the IU module are not present in the other module. List which content in the IU module is not present in the other module. Find the most important key competencies in the IU Module and list them, judge if they are present in the other module (if present and if the other module contains submodules, name the submodule). Find the most important key competencies in the other module and list them, judge if they are present in the IU module (if present and if the other module contains submodules, name the submodule). Finally, estimate how much of the modules are equivalent in percent considering the key competencies and content that is present in IU Module but not in the other (the more present the more equivalent). Make a judge if the compared modules are equivalent, keep in mind that same topics might be called different. Answer only in german language. This is the module from IU - International University of Applied Sciences: \n{iu_course} """}, {"role": "user", "content": f"{foreign_course}"} ], temperature=0, top_p=0.9 ) return completion.choices[0].message["content"] except Exception as e: print(e) return None def chat_prompt(messages,temperature:float=0.0,top_p:float=0.9,model_name:str="gpt-3.5-turbo")->str|None: try: completion = openai.ChatCompletion.create( model=model_name, messages=messages, temperature=temperature, top_p=top_p ) return completion.choices[0].message["content"] except Exception as e: print(e) return None