Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main working #36

Merged
merged 3 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions interviewkit/interview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from random import choice
from interviewee import Interviewee
import openai
from enum import StrEnum, auto
from transcript import Transcript


class Status(StrEnum):
Expand All @@ -14,7 +14,7 @@ class Status(StrEnum):
class Interview(object):
"""An interview between an Interviewee and an Interviewer."""

def __init__(self, interviewee: Interviewee):
def __init__(self, interviewee: Interviewee, transcript: Transcript):
self.interviewee = interviewee
self.status = Status.IN_PROGRESS

Expand All @@ -27,8 +27,8 @@ def stop_recording(self) -> None:
self.status = Status.RECORDED

def start_transcription(self) -> None:
print("transcribing")
self.status = "Transcribing"
self.transcript = [] # TODO: Use object Transcript instead of list?

def add_to_transcript(self, speech: str) -> None:
self.transcript.append(speech)
Expand All @@ -40,20 +40,15 @@ def stop_transcription(self) -> None:
self.transcript = " ".join(self.transcript)

def suggest_questions(self) -> str:
"""Use the OpenAI API to suggest questions based on the transcript content."""
"""suggest questions based on the transcript content."""
suggested_questions = self.generate_questions(self.transcript)
return suggested_questions

def generate_questions(self, content: str) -> list[str]:
"""Call the OpenAI API to generate questions, and return them."""
response = openai.Completion.create(
engine="text-davinci-002",
prompt=f"Generate interview questions based on the following transcript:\n{content}\n",
max_tokens=50, # Adjust the max tokens as needed
n=5, # Number of questions to generate
stop=None,
temperature=0.7, # Adjust the temperature for creativity
)
"""generate questions, and return them."""

#TODO
response = None

# Extract and return the generated questions
generated_questions = [choice["text"].strip() for choice in response.choices]
Expand Down
3 changes: 1 addition & 2 deletions interviewkit/interviewee.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import StrEnum, auto
from pydantic import BaseModel, NonNegativeInt


class Gender(StrEnum):
MALE = auto()
FEMALE = auto()
Expand All @@ -13,4 +12,4 @@ class Interviewee(BaseModel):

name: str
age: NonNegativeInt
gender: Gender
gender: Gender
14 changes: 4 additions & 10 deletions interviewkit/main.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import os

import openai

from interview import Interview
from interviewee import Interviewee
from interviewee import Interviewee, Gender
from transcript import Transcript
from settings import Settings


# Set the OpenAI API key
settings = Settings()
openai.api_key = settings.OPENAI_API_KEY


if __name__ == "__main__":
interviewee = Interviewee("John Doe", 60, "Male")
interviewee = Interviewee(name="John Doe", age=60, gender=Gender.MALE)

transcript_content = "This is the content of the transcript."
transcript = Transcript(transcript_content)
transcript = Transcript(content=transcript_content)

interview = Interview(interviewee, transcript)

interview.transcribe()
interview.start_transcription()

print(f"Interview Status: {interview.status}")
3 changes: 2 additions & 1 deletion interviewkit/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@


class Settings(BaseSettings):
OPENAI_API_KEY: str
#TODO
pass
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license= "GPL-2.0-or-later"

[tool.poetry.dependencies]
python = "^3.11"
openai = "^0.28.0"
pydantic-settings = "^2.0.3"
pydantic = "^2.3.0"

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ colorama==0.4.6
frozenlist==1.4.0
idna==3.4
multidict==6.0.4
openai==0.28.0
requests==2.31.0
tqdm==4.66.1
urllib3==2.0.5
Expand Down