Skip to content

Commit e94455f

Browse files
authored
Update integrating-generative-apis-with-popular-tools.mdx
Remove duplicated code
1 parent e2535dd commit e94455f

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pages/generative-apis/reference-content/integrating-generative-apis-with-popular-tools.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,10 @@ pip install openai
4444
Then you'll need to set the API key and base URL in your OpenAI-compatible client:
4545
```python
4646
from openai import OpenAI
47-
4847
client = OpenAI(
4948
base_url="https://api.scaleway.ai/v1",
5049
api_key="<API secret key>"
5150
)
52-
53-
response = client.chat.completions.create(
54-
model="llama-3.1-8b-instruct",
55-
messages=[{"role": "user", "content": "Tell me a joke about AI"}]
56-
)
57-
58-
print(response.choices[0].message.content)
5951
```
6052
<Message type="tip">
6153
Make sure to replace `<API secret key>` with your actual API key.
@@ -65,11 +57,11 @@ print(response.choices[0].message.content)
6557

6658
To use OpenAI client for text generation, you can create a `ChatCompletion` object and call the `create` method:
6759
```python
68-
response = openai.ChatCompletion.create(
60+
response = client.chat.completions.create(
6961
model="llama-3.1-8b-instruct",
7062
messages=[{"role": "user", "content": "Tell me a joke about AI"}]
7163
)
72-
print(response["choices"][0]["message"]["content"])
64+
print(response.choices[0].message.content)
7365
```
7466

7567
## LangChain (RAG & LLM applications)

0 commit comments

Comments
 (0)