Mathias Lux commited on
Commit
bc56583
·
1 Parent(s): 635e7af

Removed audio support to basically finish up fooling around.

Browse files
Files changed (1) hide show
  1. app.py +16 -29
app.py CHANGED
@@ -7,9 +7,6 @@ For more information on `huggingface_hub` Inference API support, please check th
7
  client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
8
  # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
10
- # Create a separate client for audio transcription
11
- audio_client = InferenceClient("openai/whisper-large-v3-turbo")
12
-
13
  _sys_msg = """
14
  You are a reporter writing a biographical article about your interviewee and you only ask one question at a time and let the user answer. Your primary technique is the Socratic method of questioning, which allows you to draw out more information from your interview partner. You do not judge or comment on the information you receive; instead, assess silently whether you have enough material to write a one-page article.
15
 
@@ -31,23 +28,13 @@ Welcome to the interview. I want to write a short biography about you and need s
31
  Can you please start by stating your name and talking about your early childhood?
32
  """
33
 
34
- def transcribe(audio):
35
- if audio is None:
36
- return None
37
- text = audio_client.audio_transcription(audio)
38
- return text
39
-
40
  def respond(
41
  message,
42
  history: list[tuple[str, str]],
43
- audio,
 
 
44
  ):
45
- # Handle voice input if provided
46
- if audio is not None:
47
- transcribed_text = transcribe(audio)
48
- if transcribed_text:
49
- message = transcribed_text
50
-
51
  messages = [{"role": "system", "content": _sys_msg},
52
  {"role": "assistant", "content": _ass_msg_start}]
53
 
@@ -57,37 +44,37 @@ def respond(
57
  if val[1]:
58
  messages.append({"role": "assistant", "content": val[1]})
59
 
 
60
  messages.append({"role": "user", "content": message})
61
 
62
  response = ""
63
 
64
  for message in client.chat_completion(
65
  messages,
66
- max_tokens=2048,
67
  stream=True,
68
- temperature=0.7,
69
- top_p=0.95,
70
  ):
71
  token = message.choices[0].delta.content
 
72
  response += token
73
  yield response
74
 
75
- demo = gr.ChatInterface(
 
76
  respond,
77
- additional_inputs=[
78
- gr.Audio(type="filepath", label="Voice Input (click to record)", sources="microphone")
79
- ],
80
- title="AI Biographical Interview Assistant",
81
- description="""
82
  Welcome to the AI Biographical Interview Assistant! This tool uses advanced AI to conduct
83
  an in-depth interview about your life experiences. The AI interviewer uses the Socratic method
84
  to ask thoughtful questions and gather information for creating a biographical article.
85
 
86
  Simply start with stating your name and a few facts about your early childhood, and the AI will guide you through the interview process.
87
- You can either type your responses or use the microphone button to speak them.
88
- When finished ask for the final article and the AI will wrap it up and give you a summary.
89
  """
90
- )
 
91
 
92
  if __name__ == "__main__":
93
- demo.launch()
 
7
  client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
8
  # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
9
 
 
 
 
10
  _sys_msg = """
11
  You are a reporter writing a biographical article about your interviewee and you only ask one question at a time and let the user answer. Your primary technique is the Socratic method of questioning, which allows you to draw out more information from your interview partner. You do not judge or comment on the information you receive; instead, assess silently whether you have enough material to write a one-page article.
12
 
 
28
  Can you please start by stating your name and talking about your early childhood?
29
  """
30
 
 
 
 
 
 
 
31
  def respond(
32
  message,
33
  history: list[tuple[str, str]],
34
+ max_tokens,
35
+ temperature,
36
+ top_p,
37
  ):
 
 
 
 
 
 
38
  messages = [{"role": "system", "content": _sys_msg},
39
  {"role": "assistant", "content": _ass_msg_start}]
40
 
 
44
  if val[1]:
45
  messages.append({"role": "assistant", "content": val[1]})
46
 
47
+
48
  messages.append({"role": "user", "content": message})
49
 
50
  response = ""
51
 
52
  for message in client.chat_completion(
53
  messages,
54
+ max_tokens=2048, # Fixed value
55
  stream=True,
56
+ temperature=0.7, # Fixed value
57
+ top_p=0.95, # Fixed value
58
  ):
59
  token = message.choices[0].delta.content
60
+
61
  response += token
62
  yield response
63
 
64
+
65
+ demo = gr.ChatInterface(
66
  respond,
67
+ title = "AI Biographical Interview Assistant",
68
+ description = """
 
 
 
69
  Welcome to the AI Biographical Interview Assistant! This tool uses advanced AI to conduct
70
  an in-depth interview about your life experiences. The AI interviewer uses the Socratic method
71
  to ask thoughtful questions and gather information for creating a biographical article.
72
 
73
  Simply start with stating your name and a few facts about your early childhood, and the AI will guide you through the interview process.
74
+ When finished ask for the final article and the AI will give wrap it up and give you a summary.
 
75
  """
76
+ )
77
+
78
 
79
  if __name__ == "__main__":
80
+ demo.launch()