Spaces:
Runtime error
Runtime error
File size: 1,116 Bytes
59e1d08 fb4483d 59e1d08 fb4483d 59e1d08 3f59fe8 59e1d08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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"]
|