You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the instructions as follows to run quickstart.ipynb:
In terminal logged in to my azure account by running az login --use-device-code
Post authentication I go back to VScode and run the following code block within quickstart.ipynb which runs fine:
import os
import tiktoken
import openai
import numpy as np
import pandas as pd
from dotenv import load_dotenv
from azure.identity import DefaultAzureCredential
from openai.embeddings_utils import cosine_similarity
from tenacity import retry, wait_random_exponential, stop_after_attempt
Load environment variables
load_dotenv()
Option 1 - Use Azure AD authentication with az cli (use az login in terminal)
Now when I run the following code block I get the error below:
response = openai.Completion.create(engine="gpt-4",
prompt="Knock knock.",
temperature=0)
print(response.choices[0].text)
File ~/miniconda3/lib/python3.10/site-packages/requests/models.py:439, in PreparedRequest.prepare_url(self, url, params)
438 if not scheme:
--> 439 raise MissingSchema(
440 f"Invalid URL {url!r}: No scheme supplied. "
441 f"Perhaps you meant https://{url}?"
442 )
444 if not host:
APIConnectionError: Error communicating with OpenAI: Invalid URL 'None/openai/deployments/gpt-4/completions?api-version=2023-06-13': No scheme supplied. Perhaps you meant https://none/openai/deployments/gpt-4/completions?api-version=2023-06-13?
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
The text was updated successfully, but these errors were encountered:
I followed the instructions as follows to run quickstart.ipynb:
In terminal logged in to my azure account by running az login --use-device-code
Post authentication I go back to VScode and run the following code block within quickstart.ipynb which runs fine:
import os
import tiktoken
import openai
import numpy as np
import pandas as pd
from dotenv import load_dotenv
from azure.identity import DefaultAzureCredential
from openai.embeddings_utils import cosine_similarity
from tenacity import retry, wait_random_exponential, stop_after_attempt
Load environment variables
load_dotenv()
Option 1 - Use Azure AD authentication with az cli (use az login in terminal)
default_credential = DefaultAzureCredential()
token = default_credential.get_token("https://cognitiveservices.azure.com/.default")
openai.api_type = "azure_ad"
openai.api_base = os.environ.get("OPENAI_API_BASE")
openai.api_key = token.token
openai.api_version = "2023-06-13"
Option 2 - Using Access Key
openai.api_type = "azure"
openai.api_base = os.environ.get("OPENAI_API_BASE")
openai.api_key = os.environ.get("OPENAI_API_KEY")
openai.api_version = "2022-12-01"
Define embedding model and encoding
EMBEDDING_MODEL = 'text-embedding-ada-002'
COMPLETION_MODEL = 'gpt-4'
encoding = tiktoken.get_encoding('cl100k_base')
Now when I run the following code block I get the error below:
response = openai.Completion.create(engine="gpt-4",
prompt="Knock knock.",
temperature=0)
print(response.choices[0].text)
Error:
MissingSchema Traceback (most recent call last)
File ~/miniconda3/lib/python3.10/site-packages/openai/api_requestor.py:596, in APIRequestor.request_raw(self, method, url, params, supplied_headers, files, stream, request_id, request_timeout)
595 try:
--> 596 result = _thread_context.session.request(
597 method,
598 abs_url,
599 headers=headers,
600 data=data,
601 files=files,
602 stream=stream,
603 timeout=request_timeout if request_timeout else TIMEOUT_SECS,
604 proxies=_thread_context.session.proxies,
605 )
606 except requests.exceptions.Timeout as e:
File ~/miniconda3/lib/python3.10/site-packages/requests/sessions.py:573, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
561 req = Request(
562 method=method.upper(),
563 url=url,
(...)
571 hooks=hooks,
572 )
--> 573 prep = self.prepare_request(req)
575 proxies = proxies or {}
File ~/miniconda3/lib/python3.10/site-packages/requests/sessions.py:484, in Session.prepare_request(self, request)
483 p = PreparedRequest()
--> 484 p.prepare(
485 method=request.method.upper(),
486 url=request.url,
487 files=request.files,
488 data=request.data,
489 json=request.json,
490 headers=merge_setting(
491 request.headers, self.headers, dict_class=CaseInsensitiveDict
492 ),
493 params=merge_setting(request.params, self.params),
494 auth=merge_setting(auth, self.auth),
495 cookies=merged_cookies,
496 hooks=merge_hooks(request.hooks, self.hooks),
497 )
498 return p
File ~/miniconda3/lib/python3.10/site-packages/requests/models.py:368, in PreparedRequest.prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
367 self.prepare_method(method)
--> 368 self.prepare_url(url, params)
369 self.prepare_headers(headers)
File ~/miniconda3/lib/python3.10/site-packages/requests/models.py:439, in PreparedRequest.prepare_url(self, url, params)
438 if not scheme:
--> 439 raise MissingSchema(
440 f"Invalid URL {url!r}: No scheme supplied. "
441 f"Perhaps you meant https://{url}?"
442 )
444 if not host:
MissingSchema: Invalid URL 'None/openai/deployments/gpt-4/completions?api-version=2023-06-13': No scheme supplied. Perhaps you meant https://none/openai/deployments/gpt-4/completions?api-version=2023-06-13?
The above exception was the direct cause of the following exception:
APIConnectionError Traceback (most recent call last)
Cell In[22], line 1
----> 1 response = openai.Completion.create(engine="gpt-4",
2 prompt="Knock knock.",
3 temperature=0)
4 print(response.choices[0].text)
File ~/miniconda3/lib/python3.10/site-packages/openai/api_resources/completion.py:25, in Completion.create(cls, *args, **kwargs)
23 while True:
24 try:
---> 25 return super().create(*args, **kwargs)
26 except TryAgain as e:
27 if timeout is not None and time.time() > start + timeout:
File ~/miniconda3/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
127 @classmethod
128 def create(
129 cls,
(...)
136 **params,
137 ):
138 (
139 deployment_id,
140 engine,
(...)
150 api_key, api_base, api_type, api_version, organization, **params
151 )
--> 153 response, _, api_key = requestor.request(
154 "post",
155 url,
156 params=params,
157 headers=headers,
158 stream=stream,
159 request_id=request_id,
...
617 request_id=result.headers.get("X-Request-Id"),
618 )
619 # Don't read the whole stream for debug logging unless necessary.
APIConnectionError: Error communicating with OpenAI: Invalid URL 'None/openai/deployments/gpt-4/completions?api-version=2023-06-13': No scheme supplied. Perhaps you meant https://none/openai/deployments/gpt-4/completions?api-version=2023-06-13?
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
The text was updated successfully, but these errors were encountered: