File size: 2,984 Bytes
89d3fbe
 
 
c4a35d4
89d3fbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b699905
89d3fbe
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
# Set up OpenAI API credentials
import openai
openai.api_key = os.getenv('api_token')
import gradio as gr

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0, # this is the degree of randomness of the model's output
    )
    return response.choices[0].message["content"]

def choose_topic(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0.9, # this is the degree of randomness of the model's output
    )
    return response.choices[0].message["content"]

def generate_topic(aiquotient,response):
  prompt_sum = f"""
  Generate a question that evaluates the understanding of AI concepts of a person.  Ensure that the question challenges the {aiquotient} of the person and is connected to the response {response}. Limit it to at the max 20 words. Here are some examples:
  What is reinforcement learning? How is it different from supervised and unsupervised learning?
  What is the difference between a model and an algorithm?
  Explain the concept of "overfitting" in machine learning and its potential impact on model performance.
  Explain how natural language processing (NLP) is employed in virtual assistants like Siri or Alexa.
  Explain how Uber uses Machine Learning with an example
  How does ChatGPT work?
  Describe the ethical implications of using AI in autonomous vehicles and potential biases in facial recognition systems.
  What is Bias-Variance tradeoff?
  What is the importance of p-value?
  What are the assumptions under which Linear Regression works?
  What are the limitations of K-Nearest Neighbors algorithm?
"""

  response_sum = choose_topic(prompt_sum)
  return response_sum

def evaluate(response):
  prompt_sum = f"""
  Imagine you are Alan Turing, the scientist who devised Turing test. Analyze the user's response {response} and figure out the question. Then identify areas of improvement, provide the ideal answer and calculate AI Quotient. 
  Your response should be:
  [AI Quotient, Areas of Improvement, Ideal Answer] 
"""

  response_sum = get_completion(prompt_sum)
  return response_sum

import gradio as gr
def transcribe(audio):
    print(audio)

#   Whisper API

    audio_file = open(audio, "rb")
    transcript = openai.Audio.transcribe("whisper-1", audio_file)


    print(transcript)
    eval = evaluate(transcript)

    return eval

question = generate_topic(aiquotient=100,response='I am an expert in Machine Learning. Ask me a difficult question')

inputs = gr.Audio(source="microphone", type="filepath",label=question)

bot = gr.Interface(fn=transcribe, inputs=inputs, outputs="text", title="Ask Turing: Improve your AI Quotient",
    description="Answer the question and receive feedback")

bot.launch()