Skip to content

Commit

Permalink
#1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Gavryliuk committed Jan 3, 2024
1 parent ee0e384 commit abbb8e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 4 additions & 3 deletions daily_dragon.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ def __init__(self):

def get_daily_word(self):
prompt = prompts.get_daily_word_prompt()
prompt = prompt.replace('${language}', self.language)
print(prompt)
prompt = prompt.format(language=self.language)
print(f"Language: {self.language}")
completion = self.openai_client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": f"You are a teacher of ${self.language}."},
{"role": "system", "content": f"You are a teacher of {self.language}."},
{"role": "user", "content": f"${prompt}"}
]
)
print(completion)
return completion.choices[0].message.content

def set_language(self, language: str):
Expand Down
4 changes: 2 additions & 2 deletions daily_dragon_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
RAINY_BABE = 'rainy_babe'


async def daily_word(update: Update, context: ContextTypes.DEFAULT_TYPE):
async def random_word(update: Update, context: ContextTypes.DEFAULT_TYPE):
username = update.effective_user.username
print(f'User {username} requested daily word')
if username == RAINY_BABE:
Expand All @@ -35,7 +35,7 @@ async def daily_word(update: Update, context: ContextTypes.DEFAULT_TYPE):
if __name__ == '__main__':
application = ApplicationBuilder().token(TELEGRAM_TOKEN).build()

start_handler = CommandHandler('dailyword', daily_word)
start_handler = CommandHandler('random', random_word)
application.add_handler(start_handler)

application.run_polling()
10 changes: 3 additions & 7 deletions prompts/daily_word
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
Provide me a random new ${language} word with pronunciation, meanings in English and sentences to illustrate them.
Provide me one random new ${language} word with pronunciation, meanings in English and several sentences to illustrate them.
Respond in the following format:
```
Word: <word> (jiǎo zi)
Meaning: dumplings

Example sentences:
1. <sentence>
(<pronunciation>)
<translation>

2. <sentence>
(<pronunciation>)
<translation>

and so on
```

0 comments on commit abbb8e3

Please sign in to comment.