Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkweon17 committed Feb 15, 2024
2 parents a9e9077 + 2b82e02 commit 8b50cfb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Binary file modified requirements/requirements.txt
Binary file not shown.
5 changes: 3 additions & 2 deletions src/gpt/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import openai
from dotenv import load_dotenv
import os
from kss import split_sentences

# Load environment variables from .env file
load_dotenv()
Expand All @@ -27,8 +28,8 @@ def generate_response(input_messages):
# max_tokens=200, # Adjust based on the length of response you expect; keep it short for 1-3 phrases
)

reply = completion.choices[0].message.content
return reply
replies = split_sentences(completion.choices[0].message.content)
return replies
except Exception as e:
print(f"An error occurred: {e}")
return None
Expand Down
17 changes: 11 additions & 6 deletions src/routers/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@ async def make_followed_question(parent_id: int, db: Session, user_id: int):
p = db.query(LQuestions).filter(LQuestions.question_id == p.parents_id).first()
context.reverse()
print(context)
content = generate_response(context) #여기에 ai로 새 꼬리질문 만들어 넣기
print(content)
followed = LQuestions(user_id=parent.user_id, parents_id=parent_id, content=content, is_answerable=True, level=parent.level+1, chapter_id=parent.chapter_id, next_question_id=parent.next_question_id)
db.add(followed)
db.commit()
db.refresh(followed)
contents = generate_response(context) #여기에 ai로 새 꼬리질문 만들어 넣기
print(contents)
for content in contents:
if content == contents[-1]:
is_answerable = True
else:
is_answerable = False
followed = LQuestions(user_id=user_id, parents_id=parent_id, content=content, is_answerable=is_answerable, level=parent.level+1, chapter_id=parent.chapter_id, next_question_id=parent.next_question_id)
db.add(followed)
db.commit()
db.refresh(followed)
return {
'status': 'success',
'id': followed.question_id,
Expand Down

0 comments on commit 8b50cfb

Please sign in to comment.