Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
engineer-naito committed Aug 3, 2024
1 parent 3e4f719 commit bd5b09a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,54 @@ ChatBotFactory.register(ChatBotServices.OPENAI)(OpenAIChatBot)

https://zenn.dev/miyaji26/articles/fe4a50319ed799

---
transition: view-transition
level: 2
---

# 実際の使用例(チャットbot)

<br />

デコレータとして

````md magic-move
```python{all}{lines:true}
from openai import OpenAI

class OpenAIChatBot(ChatBot):
def __init__(self):
self.chatgpt_client = OpenAI(api_key=OPEN_AI_API_KEY)

def genrerate_response(self, messages) -> str:
completion = self.chatgpt_client.chat.completions.create(
messages=messages,
model="gpt-4o",
)
content = completion.choices[0].message.content

return content
```

```python{all}{lines:true}

from openai import OpenAI
@ChatBotFactory.register(ChatBotServices.OPENAI)
class OpenAIChatBot(ChatBot):
def __init__(self):
self.chatgpt_client = OpenAI(api_key=OPEN_AI_API_KEY)

def genrerate_response(self, messages) -> str:
completion = self.chatgpt_client.chat.completions.create(
messages=messages,
model="gpt-4o",
)
content = completion.choices[0].message.content

return content
```
````

---
transition: slide-left
level: 2
Expand Down

0 comments on commit bd5b09a

Please sign in to comment.