Thanks to visit codestin.com
Credit goes to github.com

Skip to content

python client 0.11.0 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.egg-info
__pycache__
/public/dist
.idea
.python-version
.python-version
/public/dist
__pycache__
build
6 changes: 6 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[settings]
include_trailing_comma=True
line_length=88
known_first_party=
multi_line_output=3
py_version=36
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ openai api completions.create -e ada -p "Hello world"

## Requirements

- Python 3.7+
- Python 3.7.1+

In general we want to support the versions of Python that our
customers are using, so if you run into issues with any version
Expand Down
5 changes: 3 additions & 2 deletions bin/openai
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import logging
import sys

import openai
from openai.cli import display_error
from openai.cli import api_register, tools_register
from openai.cli import api_register, display_error, tools_register

logger = logging.getLogger()
formatter = logging.Formatter("[%(asctime)s] %(message)s")
Expand Down Expand Up @@ -62,8 +61,10 @@ def main():
args.func(args)
except openai.error.OpenAIError as e:
display_error(e)
return 1
except KeyboardInterrupt:
sys.stderr.write("\n")
return 1
return 0


Expand Down
6 changes: 4 additions & 2 deletions examples/codex/backtranslation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import openai
from smokey import Smokey
from typing import List, Union

from smokey import Smokey

import openai


def get_candidates(
prompt: str,
Expand Down
3 changes: 2 additions & 1 deletion examples/finetuning/answers-with-ft.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import openai
import argparse

import openai


def create_context(
question, search_file_id, max_len=1800, search_model="ada", max_rerank=10
Expand Down
3 changes: 2 additions & 1 deletion examples/semanticsearch/semanticsearch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import openai
import argparse
import logging
import sys
from typing import List

import openai

logger = logging.getLogger()
formatter = logging.Formatter("[%(asctime)s] [%(process)d] %(message)s")
handler = logging.StreamHandler(sys.stderr)
Expand Down
72 changes: 48 additions & 24 deletions openai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import os

# OpenAI Python bindings.
#
# Originally forked from the MIT-licensed Stripe Python bindings.

# Configuration variables

api_key = os.environ.get("OPENAI_API_KEY")
organization = os.environ.get("OPENAI_ORGANIZATION")
client_id = None
api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com")
file_api_base = None
api_version = None
verify_ssl_certs = True
proxy = None
default_http_client = None
app_info = None
enable_telemetry = True
max_network_retries = 0
ca_bundle_path = os.path.join(os.path.dirname(__file__), "data/ca-certificates.crt")
debug = False

# Set to either 'debug' or 'info', controls console logging
log = None
import os
from typing import Optional

# API resources
from openai.api_resources import ( # noqa: E402,F401
from openai.api_resources import (
Answer,
Classification,
Completion,
Expand All @@ -36,4 +16,48 @@
Model,
Search,
)
from openai.error import APIError, InvalidRequestError, OpenAIError # noqa: E402,F401
from openai.error import APIError, InvalidRequestError, OpenAIError

api_key = os.environ.get("OPENAI_API_KEY")
# Path of a file with an API key, whose contents can change. Supercedes
# `api_key` if set. The main use case is volume-mounted Kubernetes secrets,
# which are updated automatically.
api_key_path: Optional[str] = os.environ.get("OPENAI_API_KEY_PATH")

organization = os.environ.get("OPENAI_ORGANIZATION")
api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com")
api_version = None
verify_ssl_certs = True # No effect. Certificates are always verified.
proxy = None
app_info = None
enable_telemetry = False # Ignored; the telemetry feature was removed.
ca_bundle_path = os.path.join(os.path.dirname(__file__), "data/ca-certificates.crt")
debug = False
log = None # Set to either 'debug' or 'info', controls console logging

__all__ = [
"APIError",
"Answer",
"Classification",
"Completion",
"Engine",
"ErrorObject",
"File",
"FineTune",
"InvalidRequestError",
"Model",
"OpenAIError",
"Search",
"api_base",
"api_key",
"api_key_path",
"api_version",
"app_info",
"ca_bundle_path",
"debug",
"enable_elemetry",
"log",
"organization",
"proxy",
"verify_ssl_certs",
]
Loading