IliaLarchenko commited on
Commit
64e8b03
1 Parent(s): 992866a

Cleaned up instructions

Browse files
Files changed (3) hide show
  1. docs/instruction.py +0 -261
  2. ui/coding.py +6 -2
  3. ui/instructions.py +53 -10
docs/instruction.py DELETED
@@ -1,261 +0,0 @@
1
- # I will change it into proper format later
2
-
3
- instruction = {
4
- "demo": """
5
- <span style="color: red;">
6
- This service is running in demo mode with limited performance (eg. slow voice recognition). For a better experience, run the service locally, refer to the Instruction tab for more details.
7
- </span>
8
- """,
9
- "introduction": """
10
- # Welcome to the AI Mock Interviewer!
11
-
12
- You can try this service in the demo mode here: [AI Interviewer](https://huggingface.co/spaces/IliaLarchenko/interviewer).
13
-
14
- But for the good experience you need to run it locally [Project repository](https://github.com/IliaLarchenko/Interviewer).
15
-
16
- This tool is designed to help you practice various technical interviews by simulating real interview experiences.
17
- Now, you can enhance your skills not only in coding but also in system design, machine learning system design, and other specialized topics.
18
- Here you can brush your interview skills in a realistic setting, although it’s not intended to replace thorough preparations like studying algorithms or practicing coding problems.
19
-
20
- ## Key Features
21
-
22
- - **Speech-First Interface**: Talk to the AI just like you would with a real interviewer. This makes your practice sessions feel more realistic.
23
- - **Various AI Models**: The tool uses three types of AI models:
24
- - **LLM (Large Language Model)**: Acts as the interviewer.
25
- - **Speech-to-Text and Text-to-Speech Models**: These help mimic real conversations by converting spoken words to text and vice versa.
26
- - **Model Flexibility**: The tool works with many different models, including those from OpenAI, open-source models from Hugging Face, and locally running models.
27
- - **Streaming Mode**: The tool can use all models in streaming mode when it is supported. Instead of waiting for the full response from the AI, you can get partial responses in real-time.
28
- - **Expanded Interview Coverage**: The tool now supports a variety of interview types, including Coding, System Design, Machine Learning System Design, Math, Stats, and Logic, SQL, and ML Theory interviews.
29
-
30
-
31
- ## Planned Updates
32
-
33
- This is just the first beta version, and I'm working on enhancing this tool. Planned updates include:
34
- 1. **More Interview Types**: More Interview Types: Continue to expand with additional simulations such as Behavioral Interviews and specialized technical interviews.
35
- 2. **Testing More Models**: Exploring additional open-source models to enhance the tool’s performance and flexibility.
36
- 3. **Improving the User Interface**: Making it easier to navigate and use, ensuring a better experience for all users.
37
- """,
38
- "quick_start": """
39
- # Running the AI Tech Interviewer Simulator
40
-
41
- To get the real experience you should run the service locally and use your own API key or local model.
42
-
43
- ## Initial Setup
44
-
45
- ### Clone the Repository
46
-
47
- First, clone the project repository to your local machine with the following commands:
48
-
49
- ```bash
50
- git clone https://github.com/IliaLarchenko/Interviewer
51
- cd interviewer
52
- ```
53
-
54
- ### Configure the Environment
55
-
56
- Create a `.env` file from the provided Open AI example and edit it to include your OpenAI API key (learn how to get it here: https://platform.openai.com/api-keys):
57
-
58
- ```bash
59
- cp .env.openai.example .env
60
- nano .env # You can use any text editor
61
- ```
62
-
63
- If you want to use any other model, follow the instructions in Models Configuration section.
64
-
65
- ### Build and Run the Docker Container
66
-
67
- To build and start the Docker container:
68
-
69
- ```bash
70
- docker-compose build
71
- docker-compose up
72
- ```
73
-
74
- The application will be accessible at `http://localhost:7860`.
75
-
76
- ### Running Locally (alternative)
77
-
78
- Set up a Python environment and install dependencies to run the application locally:
79
-
80
- ```bash
81
- python -m venv venv
82
- source venv/bin/activate
83
- pip install -r requirements.txt
84
- python app.py
85
- ```
86
-
87
- The application should now be accessible at `http://localhost:7860`.
88
- """,
89
- "interface": """
90
- # Interview Interface Overview
91
-
92
- This tool now supports multiple types of interviews, including Coding, System Design, Machine Learning System Design, Math, Stats, and Logic, SQL, and ML Theory.
93
- Each type is tailored to help you practice specific skills and knowledge areas.
94
- Here's how to navigate the interface:
95
-
96
- ### Setting
97
- Configure the interview settings such as difficulty, topic, and any specific requirements. Start the interview by clicking the **"Generate a problem"** button.
98
-
99
- ### Problem Statement
100
- The AI will present a problem after you initiate the session.
101
-
102
- ### Solution
103
- This section is where the interaction happens:
104
- - **Code/Solution Area**: On the left side, you will find a space to write your solution. For codding problem you can use any language, although syntax highlighting is only available for Python ans SQL currently.
105
- - **Communication Area**: On the right, this area includes:
106
- - **Chat History**: Displays the entire dialogue history, showing messages from both you and the AI interviewer.
107
- - **New message text box**: You recognized speech will be shown in this field. You can edit it before sending, but don't care the LLM can handle the text with all the voice recognition mistakes.
108
- - **Send Button**: Use this button to send your message and get the response from the AI.
109
- - **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 sent to the chat, along with a snapshot of your code or any notes from solution text area."
110
-
111
- 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.
112
-
113
- Once the interview is completed, or if you decide to end it early, click the **"Finish the interview"** button.
114
-
115
- ### Feedback
116
- Detailed feedback will be provided in this section, helping you understand your performance and areas for improvement.
117
- """,
118
- "models": """
119
- # Models Configuration
120
-
121
- This tool utilizes three types of AI 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.
122
-
123
- ## Flexible Model Integration
124
-
125
- 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:
126
-
127
- ### Large Language Model (LLM)
128
-
129
- - **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.
130
- - **Hugging Face Models**: Models like Meta-Llama from Hugging Face can also be integrated. Make sure your API key has appropriate permissions.
131
- - **Local Models**: If you have the capability, you can run models locally. Ensure they are compatible with the Hugging Face API for seamless integration.
132
-
133
- ### Speech-to-Text (STT)
134
-
135
- - **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.
136
- - **Other OS models**: Can be used too but can require a specific wrapper to align with API requirements.
137
-
138
- ### Text-to-Speech (TTS)
139
-
140
- - **OpenAI Models**: The "tts-1" model from OpenAI is fast and produces human-like results, making it quite convenient for this use case.
141
- - **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.
142
-
143
- ## Configuration via .env File
144
-
145
- The tool uses a `.env` file for environment configuration. Here’s a breakdown of how this works:
146
-
147
- - **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.
148
- - **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).
149
- - **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.
150
-
151
- ### Example Configuration
152
-
153
- OpenAI LLM:
154
- ```plaintext
155
- OPENAI_API_KEY=sk-YOUR_OPENAI_API_KEY
156
- LLM_URL=https://api.openai.com/v1
157
- LLM_TYPE=OPENAI_API
158
- LLM_NAME=gpt-3.5-turbo
159
- ```
160
-
161
- Hugging face TTS:
162
- ```plaintext
163
- HF_API_KEY=hf_YOUR_HUGGINGFACE_API_KEY
164
- TTS_URL=https://api-inference.huggingface.co/models/facebook/mms-tts-eng
165
- TTS_TYPE=HF_API
166
- TTS_NAME=Facebook-mms-tts-eng
167
- ```
168
-
169
- Local STT:
170
- ```plaintext
171
- HF_API_KEY=None
172
- STT_URL=http://127.0.0.1:5000/transcribe
173
- STT_TYPE=HF_API
174
- STT_NAME=whisper-base.en
175
- ```
176
-
177
- You can configure each models separately. Find more examples in the `.env.example` files provided.
178
-
179
- """,
180
- "acknowledgements": """
181
- # Acknowledgements
182
-
183
- The service is powered by Gradio, and the demo version is hosted on HuggingFace Spaces.
184
-
185
- Even though the service can be used with great variety of models I want to specifically acknowledge a few of them:
186
- - **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).
187
- - **Meta**: For the Llama models, particularly the Meta-Llama-3-70B-Instruct, as well as Facebook-mms-tts-eng model. Visit [Meta AI](https://ai.facebook.com) for more information.
188
- - **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).
189
-
190
- 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.
191
- """,
192
- "legal": """
193
- # Important Legal and Compliance Information
194
-
195
- ## Acceptance of Terms
196
- By utilizing this project, in any form—hosted or locally run—you acknowledge and consent to the terms outlined herein. Continued use of the service following any modifications to these terms constitutes acceptance of the revised terms.
197
-
198
- ## General User Responsibilities
199
- Users of this project are responsible for complying with all applicable laws and regulations in their jurisdiction, including data protection and privacy laws.
200
-
201
- ## Liability Disclaimer
202
- The creator of this open source software disclaims all liability for any damages or legal issues that arise from the use of this software. Users are solely responsible for their own data and ensuring compliance with all applicable laws and regulations.
203
-
204
- ## License Compatibility
205
- This project is released under the Apache 2.0 license. Users must ensure compatibility with this license when integrating additional software or libraries.
206
-
207
- ## Contribution Guidelines
208
- Contributors are required to ensure that their contributions comply with this license and respect the legal rights of third parties.
209
-
210
- ## Specific Guidelines for Usage
211
- ### 1. Hosted Demo Version on Hugging Face Spaces
212
- - **Prohibition on Personal Data Submission**: Users must not input any private, personal, sensitive information, or other restricted categories such as commercial secrets, proprietary business information, or potentially non-public financial data into this service. The functionalities that process personal data, such as CV analysis and behavioral interviews, have been disabled in this demo mode. The service is designed solely for non-personal data interaction.
213
- - **Third-Party API Usage**: User inputs are processed using third-party APIs, including services by OpenAI and Hugging Face OS models, under the service owner's API keys. No data is stored by the service owner. Users must review and comply with the terms of service and privacy policies of these third-party services.
214
- - **Hugging Face Policies**: Usage of this service on Hugging Face Spaces binds users to Hugging Face’s terms of use and privacy policy. Users are advised to review these policies, accessible on the Hugging Face website, to understand their rights and obligations.
215
-
216
- ### 2. Running the Service Locally
217
- - **Absolute User Responsibility**: When the service is run locally, users have absolute control and responsibility over its operation. Users must secure their own API keys from third-party providers or opt to run local models. Users are fully responsible for ensuring that their use complies with all applicable laws and third-party policies.
218
- - **Data Sensitivity Caution**: Users are strongly cautioned against entering sensitive, personal, or non-public information, including but not limited to trade secrets, undisclosed patents, or insider information that could potentially result in legal repercussions or breaches of confidentiality.
219
-
220
- ## AI-Generated Content Disclaimer
221
- - **Nature of AI Content**: Content generated by this service is derived from artificial intelligence, utilizing models such as Large Language Models (LLM), Speech-to-Text (STT), Text-to-Speech (TTS), and other models. The service owner assumes no responsibility for the content generated by AI. This content is provided for informational or entertainment purposes only and should not be considered legally binding or factually accurate. AI-generated content does not constitute an agreement or acknowledge any factual statements or obligations.
222
- """,
223
- }
224
-
225
- if __name__ == "__main__":
226
- spaces_config = """---
227
- title: Interview With AI
228
- emoji: 📚
229
- colorFrom: pink
230
- colorTo: yellow
231
- sdk: gradio
232
- sdk_version: 4.36.0
233
- app_file: app.py
234
- pinned: true
235
- license: apache-2.0
236
- short_description: Mock tech interview with AI.
237
- tags:
238
- - LLM
239
- - AI
240
- - Interview
241
- - Coding
242
- - System Design
243
- - Speech-to-Text
244
- - Text-to-Speech
245
- - Agent
246
- - Chatbot
247
- - Voice Assistant
248
- - Education
249
- ---
250
-
251
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
252
-
253
- """
254
-
255
- if __name__ == "__main__":
256
- with open("README.md", "w") as f:
257
- f.write(spaces_config)
258
-
259
- for key in ("introduction", "quick_start", "interface", "models", "acknowledgements", "legal"):
260
- f.write(instruction[key])
261
- f.write("\n")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/coding.py CHANGED
@@ -11,7 +11,6 @@ from typing import List, Dict, Generator, Optional, Tuple
11
  from functools import partial
12
  from api.llm import LLMManager
13
  from api.audio import TTSManager, STTManager
14
- from docs.instruction import instruction
15
 
16
 
17
  def send_request(
@@ -112,12 +111,17 @@ def change_code_area(interview_type):
112
  )
113
 
114
 
 
 
 
 
 
115
  def get_problem_solving_ui(llm: LLMManager, tts: TTSManager, stt: STTManager, default_audio_params: Dict, audio_output):
116
  send_request_partial = partial(send_request, llm=llm, tts=tts)
117
 
118
  with gr.Tab("Interview", render=False, elem_id=f"tab") as problem_tab:
119
  if os.getenv("IS_DEMO"):
120
- gr.Markdown(instruction["demo"])
121
  chat_history = gr.State([])
122
  previous_code = gr.State("")
123
  hi_markdown = gr.Markdown(
 
11
  from functools import partial
12
  from api.llm import LLMManager
13
  from api.audio import TTSManager, STTManager
 
14
 
15
 
16
  def send_request(
 
111
  )
112
 
113
 
114
+ DEMO_MESSAGE = """<span style="color: red;">
115
+ This service is running in demo mode with limited performance (e.g. slow voice recognition). For a better experience, run the service locally, refer to the Instruction tab for more details.
116
+ </span>"""
117
+
118
+
119
  def get_problem_solving_ui(llm: LLMManager, tts: TTSManager, stt: STTManager, default_audio_params: Dict, audio_output):
120
  send_request_partial = partial(send_request, llm=llm, tts=tts)
121
 
122
  with gr.Tab("Interview", render=False, elem_id=f"tab") as problem_tab:
123
  if os.getenv("IS_DEMO"):
124
+ gr.Markdown(DEMO_MESSAGE)
125
  chat_history = gr.State([])
126
  previous_code = gr.State("")
127
  hi_markdown = gr.Markdown(
ui/instructions.py CHANGED
@@ -2,15 +2,56 @@ import os
2
 
3
  import gradio as gr
4
 
5
- from docs.instruction import instruction
6
  from utils.ui import get_status_color
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def get_instructions_ui(llm, tts, stt, default_audio_params):
10
  with gr.Tab("Instruction", render=False) as instruction_tab:
11
  with gr.Row():
12
  with gr.Column(scale=2):
13
- gr.Markdown(instruction["introduction"])
14
  with gr.Column(scale=1):
15
  space = "&nbsp;" * 10
16
 
@@ -23,20 +64,22 @@ def get_instructions_ui(llm, tts, stt, default_audio_params):
23
  llm_status = get_status_color(llm)
24
  gr.Markdown(f"LLM status: {llm_status}{space}{llm.config.llm.name}", elem_id="llm_status")
25
 
26
- gr.Markdown(instruction["quick_start"])
27
  with gr.Row():
28
  with gr.Column(scale=2):
29
- gr.Markdown(instruction["interface"])
30
  with gr.Column(scale=1):
31
- gr.Markdown("Bot interaction area will look like this. Use Record button to record your answer.")
32
- gr.Markdown("Click 'Send' to send you answer and get a reply.")
33
  chat_example = gr.Chatbot(
34
  label="Chat", show_label=False, show_share_button=False, value=[["Candidate message", "Interviewer message"]]
35
  )
36
- send_btn_example = gr.Button("Send", interactive=False)
 
 
 
 
 
 
 
 
37
  audio_input_example = gr.Audio(interactive=True, **default_audio_params)
38
- gr.Markdown(instruction["models"])
39
- gr.Markdown(instruction["acknowledgements"])
40
- gr.Markdown(instruction["legal"])
41
 
42
  return instruction_tab
 
2
 
3
  import gradio as gr
4
 
 
5
  from utils.ui import get_status_color
6
 
7
+ INTRO = """
8
+ # Welcome to the AI Mock Interviewer!
9
+
10
+ You can try this service in the demo mode here: [AI Interviewer](https://huggingface.co/spaces/IliaLarchenko/interviewer).
11
+
12
+ But for the good experience you need to run it locally [Project repository](https://github.com/IliaLarchenko/Interviewer).
13
+
14
+ This tool is designed to help you practice various technical interviews by simulating real interview experiences.
15
+ You can enhance your skills in coding, (machine learning) system design, and other topics.
16
+ You can brush your interview skills in a realistic setting, although it’s not intended to replace thorough preparations like studying algorithms or practicing coding problems.
17
+
18
+ """
19
+
20
+ INTERFACE = """
21
+ # Interface
22
+
23
+ AI interviewer supports multiple types of interviews, including Coding, System Design, Machine Learning System Design, Math, Stats, and Logic, SQL, and ML Theory.
24
+ Each type is tailored to help you practice specific skills and knowledge areas. You can also chose the Custom interview type to practice any topic you want - the AI will generate a problem based on your input.
25
+ Here's how to navigate the interface:
26
+
27
+ ### Setting
28
+ Configure the interview settings such as difficulty, topic, and any specific requirements. Start the interview by clicking the **"Generate a problem"** button.
29
+
30
+ ### Problem Statement
31
+ The AI will present a problem after you initiate the session.
32
+
33
+ ### Solution
34
+ This section is where the interaction happens:
35
+ - **Code/Solution Area**: On the left side, you will find a space to write your solution. For codding problem you can use any language, although syntax highlighting is only available for Python and SQL.
36
+ - **Communication Area**: On the right, this area includes:
37
+ - **Chat History**: Displays the entire dialogue history, showing messages from both you and the AI interviewer.
38
+ - **New message text box**: Your recognized speech will be shown in this field before sending it to the AI. It is more like a legacy text input field that will be removed in the future.
39
+ - **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 sent to the chat, along with a snapshot of your code or any notes from solution text area."
40
+
41
+ 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.
42
+
43
+ Once the interview is completed, or if you decide to end it early, click the **"Finish the interview"** button.
44
+
45
+ ### Feedback
46
+ Detailed feedback will be provided in this section after the interview is over, helping you understand your performance and areas for improvement.
47
+ """
48
+
49
 
50
  def get_instructions_ui(llm, tts, stt, default_audio_params):
51
  with gr.Tab("Instruction", render=False) as instruction_tab:
52
  with gr.Row():
53
  with gr.Column(scale=2):
54
+ gr.Markdown(INTRO)
55
  with gr.Column(scale=1):
56
  space = "&nbsp;" * 10
57
 
 
64
  llm_status = get_status_color(llm)
65
  gr.Markdown(f"LLM status: {llm_status}{space}{llm.config.llm.name}", elem_id="llm_status")
66
 
 
67
  with gr.Row():
68
  with gr.Column(scale=2):
69
+ gr.Markdown(INTERFACE)
70
  with gr.Column(scale=1):
 
 
71
  chat_example = gr.Chatbot(
72
  label="Chat", show_label=False, show_share_button=False, value=[["Candidate message", "Interviewer message"]]
73
  )
74
+ message_example = gr.Textbox(
75
+ label="Message",
76
+ show_label=False,
77
+ placeholder="Your recognized speech will be shown here",
78
+ lines=5,
79
+ max_lines=5,
80
+ interactive=False,
81
+ container=False,
82
+ )
83
  audio_input_example = gr.Audio(interactive=True, **default_audio_params)
 
 
 
84
 
85
  return instruction_tab