Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
1.3 kB
2
Indexable
Never
class ConversationAnalyzer:
    def __init__(self):
        self.model = ChatGroq(model_name="mixtral-8x7b-32768", api_key="gsk_8KtQlmrXFwwLw8mz63")
        self.prompt = ChatPromptTemplate.from_messages([
            ("system", 
             "You are an expert in analyzing conversations. Your task is to assess the naturalness of conversation snippets, with the following specific rules:\n"
             "1. Any snippet that contains a single sentence should receive a high score.\n"
             "2. If the snippet contains the same sentence repeated twice in the same language, it should also receive a high score. This simulates a situation where a person repeats what was said.\n"
             "3. If the snippet contains the same sentence repeated in two different languages, it should receive a high score as well. This simulates a conversation involving a middleman acting as a translator."),
             
            ("human", 
             "Text: {text}\n\nAnalyze the text based on the above rules and respond with a score between 0 (not at all part of a natural conversation) and 1 (very likely to be part of a natural conversation). Provide a clear explanation for your score.")
        ])
        self.chain = self.prompt | self.model | StrOutputParser()
Leave a Comment