From 1b969d2bcbe83293c1af90eeb9f65155772b6ce2 Mon Sep 17 00:00:00 2001 From: bsahd <193844131+bsahd@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:25:56 +0900 Subject: [PATCH 1/3] fix codeblock of README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f7e735..8c9d8bf 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,11 @@ $ python make_index.py It outputs like below: -code:: - % python make_index.py - 97%|███████████████████████████████████████████████████████████████████████████████████████████████████▉ | 846/872 [07:06<00:10, 2.59 It/s]The server is currently overloaded with other requests. Sorry about that! You can retry your request, or contact us through our help center at help. openai.com if the error persists. - 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 872/872 [07:45<00:00, 1 .87it/s] +``` +% python make_index.py + 97%|███████████████████████████████████████████████████████████████████████████████████████████████████▉ | 846/872 [07:06<00:10, 2.59 It/s]The server is currently overloaded with other requests. Sorry about that! You can retry your request, or contact us through our help center at help. openai.com if the error persists. +100%|███████████████████████████████████████████████████████████████████████████████████████████████████████| 872/872 [07:45<00:00, 1 .87it/s] +``` Ask. From 4957b08f67f04c8c762f91bc9ceb9aacd0e5e0ac Mon Sep 17 00:00:00 2001 From: bsahd <193844131+bsahd@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:39:17 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Python3.13=E3=81=A7=E3=81=AE=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E9=96=A2=E4=BF=82=E3=81=AE=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=83=AB=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=81=A7=E5=90=84=E7=A8=AE=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E3=82=92=E6=9C=80=E6=96=B0=E7=89=88?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 61 +++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/requirements.txt b/requirements.txt index bcc8e0a..47ff58c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,24 +1,37 @@ -aiohttp==3.8.4 -aiosignal==1.3.1 -async-timeout==4.0.2 -attrs==22.2.0 -autopep8==2.0.2 -blobfile==2.0.1 -certifi==2022.12.7 -charset-normalizer==3.1.0 -filelock==3.9.0 -frozenlist==1.3.3 -idna==3.4 -lxml==4.9.2 -multidict==6.0.4 -numpy==1.24.2 -openai==0.27.1 -pycodestyle==2.10.0 -pycryptodomex==3.17 -python-dotenv==1.0.0 -regex==2022.10.31 -requests==2.28.2 -tiktoken==0.3.0 -tqdm==4.65.0 -urllib3==1.26.14 -yarl==1.8.2 +aiohappyeyeballs==2.4.4 +aiohttp==3.11.11 +aiosignal==1.3.2 +annotated-types==0.7.0 +anyio==4.8.0 +async-timeout==5.0.1 +attrs==24.3.0 +autopep8==2.3.1 +blobfile==3.0.0 +certifi==2024.12.14 +charset-normalizer==3.4.1 +distro==1.9.0 +filelock==3.16.1 +frozenlist==1.5.0 +h11==0.14.0 +httpcore==1.0.7 +httpx==0.28.1 +idna==3.10 +jiter==0.8.2 +lxml==5.3.0 +multidict==6.1.0 +numpy==2.2.1 +openai==1.59.6 +propcache==0.2.1 +pycodestyle==2.12.1 +pycryptodomex==3.21.0 +pydantic==2.10.5 +pydantic_core==2.27.2 +python-dotenv==1.0.1 +regex==2024.11.6 +requests==2.32.3 +sniffio==1.3.1 +tiktoken==0.8.0 +tqdm==4.67.1 +typing_extensions==4.12.2 +urllib3==2.3.0 +yarl==1.18.3 From 59153eeb01ddee0e1f52047e78c2bcf0976d57c6 Mon Sep 17 00:00:00 2001 From: bsahd <193844131+bsahd@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:42:48 +0900 Subject: [PATCH 3/3] =?UTF-8?q?OpenAI=20API=E3=82=92=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E3=81=99=E3=82=8B=E7=AE=87=E6=89=80=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ask.py | 4 ++-- make_index.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ask.py b/ask.py index 506621c..8ca73d4 100644 --- a/ask.py +++ b/ask.py @@ -42,7 +42,7 @@ def ask(input_str, index_file): prompt = PROMPT.format(input=input_str, text=text) print("\nTHINKING...") - response = openai.ChatCompletion.create( + response = openai.OpenAI().chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "user", "content": prompt} @@ -52,7 +52,7 @@ def ask(input_str, index_file): ) # show question and answer - content = response['choices'][0]['message']['content'] + content = response.choices[0].message.content print("\nANSWER:") print(f">>>> {input_str}") print(">", content) diff --git a/make_index.py b/make_index.py index 32540b7..f870044 100644 --- a/make_index.py +++ b/make_index.py @@ -30,7 +30,7 @@ def embed_text(text, sleep_after_success=1): while True: try: - res = openai.Embedding.create( + res = openai.OpenAI().embeddings.create( input=[text], model="text-embedding-ada-002") time.sleep(sleep_after_success) @@ -40,7 +40,7 @@ def embed_text(text, sleep_after_success=1): continue break - return res["data"][0]["embedding"] + return res.data[0].embedding def update_from_scrapbox(json_file, out_index, in_index=None):