IliaLarchenko commited on
Commit
2d989a9
1 Parent(s): c37b091

Added full introduction

Browse files
Files changed (2) hide show
  1. app.py +25 -21
  2. docs/instruction.py +218 -21
app.py CHANGED
@@ -49,42 +49,46 @@ def hide_solution():
49
  # Interface
50
 
51
  with gr.Blocks() as demo:
52
- audio_output = gr.Audio(label="Play audio", autoplay=True, visible=False)
 
53
 
 
54
  with gr.Tab("Instruction") as instruction_tab:
55
  with gr.Row():
56
- with gr.Column(scale=10):
57
- gr.Markdown("# Welcome to the AI Tech Interviewer Training!")
58
- gr.Markdown(instruction["intro"])
59
-
60
- if os.getenv("IS_DEMO"):
61
- gr.Markdown(instruction["demo"])
62
-
63
- gr.Markdown("### Introduction")
64
- gr.Markdown("### Setting Up Locally")
65
- gr.Markdown("### Interview Interface Overview")
66
- gr.Markdown("### Models Configuration")
67
- gr.Markdown("### Acknowledgement")
68
- gr.Markdown(instruction["acknowledgements"])
69
-
70
  with gr.Column(scale=1):
 
71
  try:
72
  audio_test = tts.text_to_speech("Handshake")
73
- gr.Markdown(f"TTS status: 🟢. Model: {config.tts.name}")
74
  except:
75
- gr.Markdown(f"TTS status: 🔴. Model: {config.tts.name}")
76
 
77
  try:
78
  text_test = stt.speech_to_text(audio_test, False)
79
- gr.Markdown(f"STT status: 🟢. Model: {config.stt.name}")
80
  except:
81
- gr.Markdown(f"STT status: 🔴. Model: {config.stt.name}")
82
 
83
  try:
84
  llm.test_connection()
85
- gr.Markdown(f"LLM status: 🟢. Model: {config.llm.name}")
86
  except:
87
- gr.Markdown(f"LLM status: 🔴. Model: {config.llm.name}")
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  with gr.Tab("Coding") as coding_tab:
90
  chat_history = gr.State([])
 
49
  # Interface
50
 
51
  with gr.Blocks() as demo:
52
+ if os.getenv("IS_DEMO"):
53
+ gr.Markdown(instruction["demo"])
54
 
55
+ audio_output = gr.Audio(label="Play audio", autoplay=True, visible=False)
56
  with gr.Tab("Instruction") as instruction_tab:
57
  with gr.Row():
58
+ with gr.Column(scale=2):
59
+ gr.Markdown(instruction["introduction"])
 
 
 
 
 
 
 
 
 
 
 
 
60
  with gr.Column(scale=1):
61
+ space = " " * 10
62
  try:
63
  audio_test = tts.text_to_speech("Handshake")
64
+ gr.Markdown(f"TTS status: 🟢{space} {config.tts.name}")
65
  except:
66
+ gr.Markdown(f"TTS status: 🔴{space} {config.tts.name}")
67
 
68
  try:
69
  text_test = stt.speech_to_text(audio_test, False)
70
+ gr.Markdown(f"STT status: 🟢{space} {config.stt.name}")
71
  except:
72
+ gr.Markdown(f"STT status: 🔴{space} {config.stt.name}")
73
 
74
  try:
75
  llm.test_connection()
76
+ gr.Markdown(f"LLM status: 🟢{space} {config.llm.name}")
77
  except:
78
+ gr.Markdown(f"LLM status: 🔴{space} {config.llm.name}")
79
+
80
+ gr.Markdown(instruction["quick_start"])
81
+ with gr.Row():
82
+ with gr.Column(scale=2):
83
+ gr.Markdown(instruction["interface"])
84
+ with gr.Column(scale=1):
85
+ gr.Markdown("Bot interaction area will look like this. Use Record button to record your answer.")
86
+ chat_example = gr.Chatbot(
87
+ label="Chat", show_label=False, show_share_button=False, value=[["Candidate message", "Interviewer message"]]
88
+ )
89
+ audio_input_example = gr.Audio(interactive=True, **default_audio_params)
90
+ gr.Markdown(instruction["models"])
91
+ gr.Markdown(instruction["acknowledgements"])
92
 
93
  with gr.Tab("Coding") as coding_tab:
94
  chat_history = gr.State([])
docs/instruction.py CHANGED
@@ -1,29 +1,226 @@
1
  # I will change it into proper format later
2
 
3
  instruction = {
4
- "intro": """
5
- This project leverages the latest AI models to simulate a realistic tech interview experience,
6
- allowing you to practice your coding interview skills in an environment that closely mimics the real thing.
7
- While it's not designed to replace a human interviewer or the essential steps of interview preparation, such as studying algorithms and practicing coding,
8
- it serves as a valuable addition to your preparation arsenal.
9
- """,
10
  "demo": """
11
- ### Demo Version Notice
12
- **This is a demo version running on limited resources, which may respond slower than usual.**
13
- It's primarily for demonstration purposes.
14
- For optimal performance, we recommend running this application on your local machine using your own OpenAI API_KEY or local models.
15
- See the instructions below on how to set up and run this application locally for the best experience.
16
- I also recommend to read this introduction page first.
17
- If you proceed to the interview interface right now, just click on the 'Coding' tab.
18
  """,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  "acknowledgements": """
20
- The library can be used with a wide variety of models and APIs depending on configuration.
21
- But I would like to acknowledge the following models in particular:
22
- * OpenAI: GPT-3.5, GPT-4, Whisper, TTS-1, etc.
23
- * Meta: Llama family, especially Meta-Llama-3-70B-Instruct and Meta-Llama-3-8B-Instruct.
24
- * HuggingFace: for providing a wide range of models and APIs that can be used with this library.
25
-
26
- Please, make sure to check the documentation of the models and APIs you are using to understand their capabilities and limitations.
27
- Also, make sure to comply with the terms of service and acceptable use policies of the models and APIs you are using.
 
 
 
 
 
 
 
 
 
 
 
 
28
  """,
29
  }
 
1
  # I will change it into proper format later
2
 
3
  instruction = {
 
 
 
 
 
 
4
  "demo": """
5
+ <span style="color: red;">
6
+ This is a demo version with limited resources, which may respond slower than usual.
7
+ It's primarily for demonstration. For optimal performance, please run it locally and use your own OpenAI key or HuggingFace model.
8
+ Read the introduction page, or click on the 'Coding' tab to proceed to the interview interface in demo mode.
9
+ </span>
 
 
10
  """,
11
+ "introduction": """
12
+ # Welcome to the AI Tech Interviewer Simulator!
13
+
14
+ Welcome to the AI Tech Interviewer Training tool! This tool is designed to help you practice for coding interviews by simulating the real interview experience. It's perfect for brushing up on your skills in a realistic setting, although it's not meant to replace actual interview preparations like studying algorithms or practicing coding problems.
15
+
16
+ ## Key Features
17
+
18
+ - **Speech-First Interface**: You can talk to the tool just like you'd talk to a real interviewer. This makes practicing for your interviews more realistic.
19
+ - **Support for Various AI Models**: You can use different AI models with this tool, including:
20
+ - **LLM (Large Language Model)**: Acts as the interviewer.
21
+ - **Speech-to-Text and Text-to-Speech Models**: These help mimic a real conversation by converting spoken words to text and vice versa.
22
+ - **Model Flexibility**: The tool works with many different models, including ones from OpenAI and open-source models from Hugging Face.
23
+ - **Personal Project**: I created this tool as a fun way to experiment with AI models and to provide a helpful resource for interview practice.
24
+
25
+ ## Compliance and Licensing
26
+
27
+ This tool is available under the Apache 2.0 license. Please make sure to follow all license agreements and terms of service for the models and APIs you use with this tool.
28
+
29
+ Check out the other sections for instructions on how to set up the tool, use the interview interface, configure models, and more.
30
+
31
+ """,
32
+ "quick_start": """
33
+ # Setting Up Locally
34
+
35
+ Follow these steps to set up the AI Tech Interviewer Training tool on your local machine:
36
+
37
+ ## Prerequisites
38
+
39
+ Before starting the setup, ensure you have Python installed on your system. You can download Python from [python.org](https://www.python.org/downloads/).
40
+
41
+ ## Clone the Repository
42
+
43
+ First, clone the project repository to your local machine using the following command in your terminal:
44
+
45
+ ```bash
46
+ git clone https://huggingface.co/spaces/IliaLarchenko/interviewer
47
+ ```
48
+
49
+ ## Create a Virtual Environment
50
+
51
+ Create a virtual environment to manage the dependencies separately from your system-wide Python installations:
52
+
53
+ ```bash
54
+ cd interviewer
55
+ python -m venv venv
56
+ source venv/bin/activate
57
+ ```
58
+
59
+ ## Install Dependencies
60
+
61
+ Install the necessary Python packages within the virtual environment:
62
+
63
+ ```bash
64
+ pip install -r requirements.txt
65
+ ```
66
+
67
+ ## Set Up Environment Variables
68
+
69
+ The application uses environment variables defined in a `.env` file for configuration. Create this file by copying the provided example and update it with your own configurations:
70
+
71
+ ```bash
72
+ cp .env.openai.example .env
73
+ nano .env # or use any other text editor to edit the .env file
74
+ ```
75
+
76
+ Be sure to replace `sk-YOUR_OPENAI_API_KEY` with your actual OpenAI API key, which you can obtain from [OpenAI Platform](https://platform.openai.com/api-keys).
77
+
78
+ ### Additional Configuration for HuggingFace Spaces
79
+
80
+ If you choose to copy the demo space on HuggingFace instead of using a local `.env` file, you will need to set up all the environment variables in the space setup.
81
+
82
+ You will also need the `.env` file to use any non-OpenAI models, as described below. You can also refer to one of the example `.env` files provided in the repository for guidance.
83
+
84
+ ## Running the Application
85
+
86
+ With the environment set up, you are now ready to run the application. Execute the following command in your terminal:
87
+
88
+ ```bash
89
+ python app.py
90
+ ```
91
+
92
+ This will start the server, and the application should be accessible locally. By default, it usually runs at `http://localhost:7860` but check your terminal output to confirm the exact URL.
93
+
94
+ ## Next Steps
95
+
96
+ Now that your application is running, you can proceed to the [Interview Interface Overview](#interview-interface-overview) section to learn how to interact with the application.
97
+ """,
98
+ "interface": """
99
+ # Interview Interface Overview
100
+
101
+ The AI Tech Interviewer Training tool currently supports different types of interviews, with only the coding interview available at this time. To begin, select the corresponding tab at the top of the interface.
102
+
103
+ ## Interface Components
104
+
105
+ The interface is divided into four main sections, which you will navigate through sequentially:
106
+
107
+ ### Setting
108
+ In this section, you can configure the interview parameters such as difficulty, topic, and any specific requirements in a free text form. Once you've set your preferences, click the **"Generate a problem"** button to start the interview. The AI will then prepare a coding problem for you.
109
+
110
+ ### Problem Statement
111
+ After clicking **"Generate a problem"**, wait for less than 10 seconds, and the AI will present a coding problem in this section. Review the problem statement carefully to understand what is expected for your solution.
112
+
113
+ ### Solution
114
+ This is where the main interaction occurs:
115
+ - **Code Area**: On the left side, you will find a space to write your solution. You can use any programming language, although syntax highlighting is only available for Python currently.
116
+ - **Communication Area**: On the right, this area includes:
117
+ - **Chat History**: Displays the entire dialogue history, showing messages from both you and the AI interviewer.
118
+ - **Audio Record Button**: Use this button to record your responses. Press to start recording, speak your thoughts, and press stop to send your audio. Your message will be transcribed and added to the chat, along with a snapshot of your code. For code-only messages, type your code and record a brief message like "Check out my code."
119
+
120
+ Engage with the AI as you would with a real interviewer. Provide concise responses and frequent updates rather than long monologues. Your interactions, including any commentary on your code, will be recorded and the AI's responses will be read aloud and displayed in the chat. Follow the AI's instructions and respond to any follow-up questions as they arise.
121
+
122
+ ### Feedback
123
+ Once the interview is completed, or if you decide to end it early, click the **"Finish the interview"** button. Detailed feedback will be provided in this section, helping you understand your performance and areas for improvement.
124
+ """,
125
+ "models": """
126
+ # Models Configuration
127
+
128
+ The AI Tech Interviewer Training tool utilizes three types of models: a Large Language Model (LLM) for simulating interviews, a Speech-to-Text (STT) model for audio processing, and a Text-to-Speech (TTS) model for auditory feedback. You can configure each model separately to tailor the experience based on your preferences and available resources.
129
+
130
+ ## Flexible Model Integration
131
+
132
+ You can connect various models from different sources to the tool. Whether you are using models from OpenAI, Hugging Face, or even locally hosted models, the tool is designed to be compatible with a range of APIs. Here’s how you can configure each type:
133
+
134
+ ### Large Language Model (LLM)
135
+
136
+ - **OpenAI Models**: You can use models like GPT-3.5-turbo or GPT-4 provided by OpenAI. Set up is straightforward with your OpenAI API key.
137
+ - **Hugging Face Models**: Models like Meta-Llama from Hugging Face can also be integrated. Make sure your API key has appropriate permissions.
138
+ - **Local Models**: If you have the capability, you can run models locally. Ensure they are compatible with the Hugging Face API for seamless integration.
139
+
140
+ ### Speech-to-Text (STT)
141
+
142
+ - **OpenAI Whisper**: Available via OpenAI, this model supports multiple languages and dialects. It is also available in an open-source version on Hugging Face, giving you the flexibility to use it either through the OpenAI API or as a locally hosted version.
143
+ - **Other OS models**: Can be used too but can require a specific wrapper to align with API requirements.
144
+
145
+ ### Text-to-Speech (TTS)
146
+
147
+ - **OpenAI Models**: The "tts-1" model from OpenAI is fast and produces human-like results, making it quite convenient for this use case.
148
+ - **Other OS models**: Can be used too but can require a specific wrapper to align with API requirements. In my experience, OS models sound more robotic than OpenAI models.
149
+
150
+ ## Configuration via .env File
151
+
152
+ The tool uses a `.env` file for environment configuration. Here’s a breakdown of how this works:
153
+
154
+ - **API Keys**: Whether using OpenAI, Hugging Face, or other services, your API key must be specified in the `.env` file. This key should have the necessary permissions to access the models you intend to use.
155
+ - **Model URLs and Types**: Specify the API endpoint URLs for each model and their type (e.g., `OPENAI_API` for OpenAI models, `HF_API` for Hugging Face or local APIs).
156
+ - **Model Names**: Set the specific model name, such as `gpt-3.5-turbo` or `whisper-1`, to tell the application which model to interact with.
157
+
158
+ ### Example Configuration
159
+
160
+ For OpenAI models:
161
+ ```plaintext
162
+ OPENAI_API_KEY=sk-YOUR_OPENAI_API_KEY
163
+ LLM_URL=https://api.openai.com/v1
164
+ LLM_TYPE=OPENAI_API
165
+ LLM_NAME=gpt-3.5-turbo
166
+ STT_URL=https://api.openai.com/v1
167
+ STT_TYPE=OPENAI_API
168
+ STT_NAME=whisper-1
169
+ TTS_URL=https://api.openai.com/v1
170
+ TTS_TYPE=OPENAI_API
171
+ TTS_NAME=tts-1
172
+ ```
173
+
174
+ For a Hugging Face model integration:
175
+ ```plaintext
176
+ HF_API_KEY=hf_YOUR_HUGGINGFACE_API_KEY
177
+ LLM_URL=https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-70B-Instruct/v1
178
+ LLM_TYPE=HF_API
179
+ LLM_NAME=Meta-Llama-3-70B-Instruct
180
+ STT_URL=https://api-inference.huggingface.co/models/openai/whisper-tiny.en
181
+ STT_TYPE=HF_API
182
+ STT_NAME=whisper-tiny.en
183
+ TTS_URL=https://api-inference.huggingface.co/models/facebook/mms-tts-eng
184
+ TTS_TYPE=HF_API
185
+ TTS_NAME=Facebook-mms-tts-eng
186
+ ```
187
+
188
+ For local models:
189
+ ```plaintext
190
+ HF_API_KEY=None
191
+ LLM_URL=http://192.168.1.1:8080/v1
192
+ LLM_TYPE=HF_API
193
+ LLM_NAME=Meta-Llama-3-8B-Instruct
194
+ STT_URL=http://127.0.0.1:5000/transcribe
195
+ STT_TYPE=HF_API
196
+ STT_NAME=whisper-base.en
197
+ TTS_URL=http://127.0.0.1:5001/read
198
+ TTS_TYPE=HF_API
199
+ TTS_NAME=my-tts-model
200
+ ```
201
+
202
+ This section provides a comprehensive guide on how to configure and integrate different AI models into the tool, including handling the `.env` configuration file and adapting it to various sources.
203
+ """,
204
  "acknowledgements": """
205
+ # Acknowledgements
206
+
207
+ This tool is powered by Gradio, enabling me to create an easy-to-use interface for AI-based interview practice. I thank Gradio for their fantastic platform.
208
+
209
+ ## Thanks to the Model Providers
210
+
211
+ While this tool can integrate various AI models, I primarily utilize and sincerely appreciate technologies provided by the following organizations:
212
+
213
+ - **OpenAI**: For models like GPT-3.5, GPT-4, Whisper, and TTS-1. More details on their models and usage policies can be found at [OpenAI's website](https://www.openai.com).
214
+ - **Meta**: For the Llama models, particularly the Meta-Llama-3-70B-Instruct and Meta-Llama-3-8B-Instruct, crucial for advanced language processing. Visit [Meta AI](https://ai.facebook.com) for more information.
215
+ - **HuggingFace**: For a wide range of models and APIs that greatly enhance the flexibility of this tool. For specific details on usage, refer to [Hugging Face's documentation](https://huggingface.co).
216
+
217
+ Please ensure to review the specific documentation and follow the terms of service for each model and API you use, as this is crucial for responsible and compliant use of these technologies.
218
+
219
+ ## Other Models
220
+
221
+ This tool is designed to be adaptable, allowing the integration of other models that comply with the APIs of the major providers listed. This enables the tool to be continually enhanced and tailored to specific needs.
222
+
223
+ I hope this tool assists you effectively in preparing for your interviews by leveraging these advanced technologies.
224
+
225
  """,
226
  }