Skip to content
Open
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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions make_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down
61 changes: 37 additions & 24 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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