TestTesting123 commited on
Commit
8bb829a
·
verified ·
1 Parent(s): 7acdea3

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +54 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from openai import OpenAI
4
+
5
+ # Подключение к OpenRouter
6
+ client = OpenAI(
7
+ base_url="https://openrouter.ai/api/v1",
8
+ api_key=os.getenv("OPENROUTER_API_KEY")
9
+ )
10
+
11
+ SYSTEM_PROMPT = """
12
+ You are a professional job interview simulator.
13
+ You act as an HR interviewer.
14
+
15
+ Rules:
16
+ - Ask one question at a time.
17
+ - Wait for the user's answer.
18
+ - After 5 questions, provide structured feedback:
19
+ - Strengths
20
+ - Weaknesses
21
+ - Final recommendation
22
+ Be realistic and professional.
23
+ """
24
+
25
+ def chat_with_ai(message, history):
26
+ messages = [{"role": "system", "content": SYSTEM_PROMPT}]
27
+
28
+ for human, assistant in history:
29
+ messages.append({"role": "user", "content": human})
30
+ messages.append({"role": "assistant", "content": assistant})
31
+
32
+ messages.append({"role": "user", "content": message})
33
+
34
+ response = client.chat.completions.create(
35
+ model="anthropic/claude-3.5-sonnet",
36
+ messages=messages,
37
+ temperature=0.7
38
+ )
39
+
40
+ reply = response.choices[0].message.content
41
+ return reply
42
+
43
+ with gr.Blocks() as demo:
44
+ gr.Markdown("# 🎯 InterviewSim AI")
45
+ gr.Markdown("Simulate a real job interview and receive feedback.")
46
+
47
+ chatbot = gr.ChatInterface(
48
+ chat_with_ai,
49
+ textbox=gr.Textbox(placeholder="Type your answer here...", container=False),
50
+ title="AI Interviewer"
51
+ )
52
+
53
+ if __name__ == "__main__":
54
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ openai