import gradio as gr import os import time import openai import numpy as np openai.organization = os.environ.get('ORGANIZATION') openai.api_key = os.environ.get('API_KEY') def calculate_embeddings_with_gpt3(text, engine="text-similarity-davinci-001", interval = 1.5, verbose=True): if verbose: print(f'Calculating embedding for {text}...') time.sleep(interval) response = openai.Embedding.create( input=text, engine=engine ) embedding = response['data'][0]['embedding'] return embedding def compare_text(source, target): embedding_source = calculate_embeddings_with_gpt3(source,interval=0) embedding_target = calculate_embeddings_with_gpt3(target,interval=0) cosine = np.dot(embedding_target,embedding_source)/(np.linalg.norm(embedding_target)*np.linalg.norm(embedding_source)) return { "Similarity": cosine }, round(cosine,3) import gradio as gr with gr.Blocks(css=".gradio-container { background-color: white; background-image: url('file=./qc-logo.png'); background-size: 75px 75px; background-repeat: no-repeat; background-position: 0px 0px; }") as demo: gr.Markdown(f"# {' ' * 8}Text comparer with GPT-3") with gr.Row(): source = gr.Textbox(lines=3, label="Text to be compared", placeholder="Source text") with gr.Row(): target = gr.Textbox(lines=3, label="Target phrases", placeholder="Target text") btn = gr.Button(value="Compare!", variant="primary") with gr.Row(): label = gr.Label() score = gr.Textbox(label="Score", interactive=False) btn.click(fn=compare_text, inputs=[source,target], outputs=[label,score]) gr.Examples([ ["most advanced conversation intelligence and AI powered coaching platform","most advanced conversation intelligence and AI powered coaching platform"], ["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems.","most advanced conversation intelligence and AI powered coaching platform"], ["Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems. And what does that really mean? So, um, communication coaching is something that is typically delivered one on one between a communication coach who has a, uh, a doctorate or a, um, background and experience in teaching people how to be better communicators and how to express themselves effectively.","most advanced conversation intelligence and AI powered coaching platform"], ["And what does that really mean? So, um, communication coaching is something that is typically delivered one on one between a communication coach who has a, uh, a doctorate or a, um, background and experience in teaching people how to be better communicators and how to express themselves effectively.","most advanced conversation intelligence and AI powered coaching platform"], ["The new movie is awesome","most advanced conversation intelligence and AI powered coaching platform"], ["Hello, how are you doing today? I'm here to tell you a little bit about, uh, quantified communications and the quantified platform and how it impacts organizations, who it helps and how it works. So I'll get started off by telling you just a little bit about a high level about, um, the quantified platform. Oh, so the quantified platform is one of the most advanced communication intelligence in AI powered coaching systems. And what does that really mean? So, um, communication coaching is something that is typically delivered one on one between a communication coach who has a, uh, a doctorate or a, um, background and experience in teaching people how to be better communicators and how to express themselves effectively. Um, those coaches would work one-on-one with individuals, um, maybe put their information in front of audiences and see how well they respond. And that can be a very costly process as well as a time consuming. And, um, not always backed by the science of what really drives great communication.", "most advanced conversation intelligence and AI powered coaching platform"], ["Hi, everybody. I'm really excited to be first here to try this out. Not only do I get to go first and be the Guinea pig, but I also know that I will be first on the leaderboard. So tell me about quantified. What is it exactly quantified is an AI powered coaching platform. We are here to make people remarkably better communicators by combining behavioral science, artificial intelligence, and experiential learning to give them the experience of what the world's best communication coach would do with them. If they were sitting with them in every single conversation they had, we know that through our intelligence insights feedback, and we can help people go from not knowing where they stand, when it comes to being how they communicate to becoming exceptional, confident, and inspirational in the way that they communicate, build relationships and succeed professionally in their career. So how does it work? Quantified works by 10, the behaviors that you do, what you do with your voice, your face, your gestures, and your words, and understanding how that an audience is going to react to that we have essentially built a audience digital twin that predicts how people are going to respond to you when you speak.", "most advanced conversation intelligence and AI powered coaching platform"], ["Hi, so upfront caveat, this is going to be terrible. Um, personally, I need days to craft elegant wording, uh, and then more days to practice delivering that message. Um, and instead I'm extemporizing and so this is gonna read much more like a hostage video than marketing material that said dive in. So what is quantified, uh, quantified is the most advanced conversation intelligence and AI powered coaching platform, a software platform that helps people reach their potential, uh, for communicating and connecting empowered by behavioral science, which uses artificial intelligence to drive performance outcomes for customer facing teams, uh, which helps them sell more, which helps them deliver better experiences. How does it work? Um, it is integrated into video conference platforms in which you record yourself, uh, or respond to prompts with fun and realistic experiences. Um, that's all we need you to do, uh, have conversations like the types you have every day. We've built technology that looks at the words that you say, uh, what you do with your voice, your face, your gestures, simple input create, and we create benchmarking, scoring feedback, personalized guidance, and understand how you come across and relay to you how you're doing, uh, how you can get better coach you using in artificial intelligence as if the world's best communication coach.", "most advanced conversation intelligence and AI powered coaching platform"], ["My name's Johnny, thank you all so much for taking the time to chat with me today. I kinda wanna just to introduce, quantify, kind of give an overview of who we are and what problems we're trying to seek to solve here. So I'm gonna do this by simply answering four questions. The first of how does it work? Who does it help, who can have the greatest impact? Um, and by answering these questions, I think each of you will have a better understanding of who we are here at quantified. So just to get started, we are the most advanced conversations, intelligence and AI powered coaching platform. We're a software platform that helps people reach their utmost potential and for communicating and connecting with one another, we are empowered by behavioral research and science. So know that everything that we do is backed up by specific science and behavioral research. And we use a component of our artificial intelligence that really drives performance outcomes. And to customer facing teams, we help, for example, sales teams sell more. That's a, an ROI that we're able to capture and we help everyone just deliver overall better experiences to anyone that they're in con um, connection with how does it work?", "most advanced conversation intelligence and AI powered coaching platform"] ], [source, target], fn=compare_text ) demo.launch(debug=True)