# Project export: Proficient

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: Cal Hacks 10.0
- Tagline: An AI assistant for interview practice featuring sample interview questions and sentiment analysis of interview recordings.
- Devpost: https://devpost.com/software/proficient-z6018k
- GitHub: https://github.com/ferril-s/calPandasCALHACKS
- Team: 1 GitHub contributor(s) — ferril-s (3 commits)

## Devpost submission (written by the team)

### Inspiration

As we are a group of students actively looking for summer internships, we felt that an application to assist in practicing for interviews would be highly impactful. In addition, we felt that there was an opportunity and gap regarding AI and interview prep.

### What it does

The app is comprised of two main parts: Interview question generation and video/audio sentiment analysis. The user first requests interview questions based on the job title they are applying for. Then, they film or record themselves answering the questions and submit their answers to be analyzed. The user is given back the 5 highest emotions sensed, which the user can take note of.

### How we built it

We built this in Python using Taipy, HumeAi, and OpenAI's ChatGPT API

### Challenges we ran into

As this is our first hackathon coordinating our group and utilizing the new software presented many challenges!

### Accomplishments we're proud of

Utilizing Taipy and including HumeAI and OpenAI's APIS were great accomplishments for us.

### What's next

We have plans to add many features including live video analysis and live question generation.

## README (from the GitHub repository)

# calPandasCALHACKS
CalPandas github repo for CalHacks


## Detected evidence (automated analysis)

Indexed codebase: 5 recognized source files, 5 KB.
- CSS (language) — detected in the code
- Python (language) — detected in the code
- HTML (language) — claimed on Devpost, not found in the code
- OpenAI (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (8 of 8)

```
.DS_Store
audioInterp.py
main.css
main.py
README.md
recordings/bored.m4a
recordings/Happy.m4a
test.py
```

### Dependencies

No dependency index available.

### Recent commits (newest first)

- final vs
- added output method
- PRETTY MUCH DONE
- Added Open AI questions
- Added file
- Taipy Adding
- remove
- Chatgpt
- Initial commit

## Key source files (fetched from GitHub, selected and truncated for size)

### main.py

```python
from taipy.gui import Gui
import pandas as pd
import openai
import os
import time
from audioInterp import *

openai.api_key="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"


def get_completion(prompt, model="gpt-3.5-turbo"):
    print(prompt)
    messages = [
        {"role": "system",
         "content": "You are an interviewer preparing questions"
        },
        {"role": "user", 
        "content": f"Give me 5 interview questions for this job position: {prompt}"}]
    response = openai.ChatCompletion.create(
    model=model,
    messages=messages,
    temperature=0
    )
    return response.choices[0].message["content"]


prompt = ""
prompt2 = ""
content = ""

# response = get_completion(prompt)

def test(state):
    state.prompt2 = state.prompt
    x = get_completion(state.prompt2)
    state.returnVal = x
    
def printer(state):
    # state.value = state.content
    state.value = get_top_emotions(run(state.content))

def change(state):
    state.value = "Submitted!"

value = "Insert File..."
returnVal = ""
page = """

<center><|Generate interview questions|text|id=hdr|></center>
#
<center><|{prompt}|input|id=enter|label=Job Title|><|Generate Interview Questions|button|on_action=test|></center>
#
<center><|{returnVal}|input|id=response|label=Awaiting AI Response...|active=False|multiline=True|height=50|></center>

"""
page_file = """
<center><|AI Analyzations of your responses|text|id=hdr1|></center>

#
<center><|Upload a video of you answering the questions for, the previous page to receive feedback|></center>
#
<center><|The top 5 emotions the AI detected were:|text|></center>
<center><|{value}|text|id=hi|></center>
<center><|{content}|file_selector|extensions=.mp3,.mp4,.m4a|on_action=change|></center>
<center><|Submit|button|on_action=printer|></center>
"""

pages = {
    "/": "<|Proficient|text|id=title|height=30px|width=30px|><|toggle|theme|>\n<center>\n<|navbar|>\n</center>",
    "generate-questions": page,
    "receive-feedback": page_file,
}


Gui(pages=pages).run(use_reloader=True, port=5001)

```

### main.css

```css
#hi{
    font-size: 25px;
}

#hdr{
    font-size: 50px;
}

#hdr1{
    font-size: 50px;
}

.taipy-input{
    --container-max-width: 500px;
}

#title{
    font-size: 35px;
}

/* .taipy-text{
    font-size: 100px;
} */
```

### test.py

```python
import pandas as pd
import openai
import os
import time

openai.api_key="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"

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
    model=model,
    messages=messages,
    temperature=0
    )
    return response.choices[0].message["content"]


prompt = "What is 5 + 5?"

response = get_completion(prompt)
print(response)
```

### audioInterp.py

```python
# import asyncio
# from hume import HumeStreamClient
# from hume.models.config import ProsodyConfig

# def find_top_three_emotions(data):
#     emotions = data['prosody']['predictions'][0]['emotions']

#     # Sort the emotions by score in descending order
#     sorted_emotions = sorted(emotions, key=lambda x: x['score'], reverse=True)

#     # Get the top three emotions
#     top_three_emotions = [emotion['name'] for emotion in sorted_emotions[:3]]

#     return top_three_emotions

# async def main(content):
#     client = HumeStreamClient("4pLMpdxQgho6hO7YaPvFrm4xssArylydAIgfUfAZrh6A44xu")
#     configs = [ProsodyConfig()]
#     async with client.connect(configs) as socket:
#         result = await socket.send_file(content)
#         return find_top_three_emotions(result)

from hume import HumeBatchClient
from hume.models.config import FaceConfig
from hume.models.config import ProsodyConfig

def output(list):
    returnString = ""
    for i in range(len(list)):
        returnString += f"{i + 1}. {list[i]} \n"
    return returnString     




def get_top_emotions(data):
    emotions = []
    
    # Extract emotions from the data
    predictions = data[0]['results']['predictions'][0]['models']['prosody']['grouped_predictions'][0]['predictions'][0]['emotions']
    
    # Sort emotions by score in descending order
    sorted_emotions = sorted(predictions, key=lambda x: x['score'], reverse=True)
    
    # Get the top 5 emotions
    top_5_emotions = sorted_emotions[:5]
    
    # Extract emotion names and scores
    for emotion in top_5_emotions:
        emotions.append({
            'name': emotion['name'],
            'score': emotion['score']
        })
    
    print(emotions)
    return output([x['name'] for x in emotions])
    

client = HumeBatchClient("4pLMpdxQgho6hO7YaPvFrm4xssArylydAIgfUfAZrh6A44xu")

configs = [ProsodyConfig()]

def run(content):
    files = [content]
    job = client.submit_job([],configs, files=files)
    print(job)
    print("Running...")
    job.await_complete()
    print(job.get_predictions())
    return job.get_predictions()
```