Insights-summary / gpt_s.py
muhyzatar's picture
Rename gppt_s.py to gpt_s.py
85f4ba3 verified
raw
history blame
1.17 kB
import openai
import os
openai.api_key = "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"
class GPT:
# A class for interacting with the GPT-3.5 model for topic extraction and representation.
def __init__(self):
pass
def extract_insights(self, sentence):
"""
Extracts a topic from the given sentence using GPT-3.5.
Parameters:
- sentence (str): The input sentence from which the topic is to be extracted.
Returns:
str: The GPT-3.5 generated representation of the topic.
"""
messages = [
{
"role": "system",
"content": "You are a summarizer, you give a comprehensive summary of a transcription you will be provided with. Give back the summary in the same langugae of the text you recieve."
},
]
messages.append({"role": "user", "content": "{}".format(sentence)})
chat = openai.ChatCompletion.create(
model="gpt-4-1106",
temperature=0.1,
max_tokens=4096,
messages=messages
)
reply = chat.choices[0].message.content
return reply