File tree Expand file tree Collapse file tree 1 file changed +2
-10
lines changed
pages/generative-apis/reference-content Expand file tree Collapse file tree 1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,10 @@ pip install openai
4444Then you'll need to set the API key and base URL in your OpenAI-compatible client:
4545``` python
4646from openai import OpenAI
47-
4847client = 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
6658To 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)
You can’t perform that action at this time.
0 commit comments