chompionsawelo's picture
instruction change
3f59fe8
raw
history blame
1.12 kB
import openai
import tiktoken
import tool.text_file_tool as text_file_tool
import os
openai.api_key = os.environ["OPEN_AI_KEY"]
def get_summary(lang_choice: int):
transcribe_list = text_file_tool.read_simple_transcribe_file()
transcribe = "\n".join(transcribe_list)
encoding = tiktoken.get_encoding("cl100k_base")
token_num = len(encoding.encode(transcribe))
print(f"Token number is {token_num}")
language = ["English", "Bahasa Indonesia", "Any"]
result = openai.ChatCompletion.create(
model="gpt-3.5-turbo" if token_num < 4097 else "gpt-3.5-turbo-16k",
messages=[
{"role": "system", "content": "You will make summary from dialogues in a meeting. The summary will only mention core point of the meeting in bullet points"},
{"role": "user", "content": "Please provide the dialogue"},
{"role": "assistant", "content": transcribe},
{"role": "user",
"content": f"Write summary for the given meeting dialogue in {language[lang_choice]}"}
]
)
return result["choices"][0]["message"]["content"]