Comments (1)
🚀 Here's the PR! #3841
Actions
- ↻ Restart Sweep
Step 1: 🔎 Searching
Here are the code search results. I'm now analyzing these search results to write the PR.
Relevant files (click to expand). Mentioned files will always appear here.
sweep/sweepai/core/vector_db.py
Lines 1 to 258 in ca2e86c
sweep/sweepai/config/server.py
Lines 1 to 209 in ca2e86c
Step 2: ⌨️ Coding
sweepai/core/vector_db.py
Add the necessary imports for the backoff and Redis timeout functionality.
---
+++
@@ -9,6 +9,7 @@
import requests
from loguru import logger
from redis import Redis
+from redis.exceptions import TimeoutError
from tqdm import tqdm
import voyageai
import boto3
sweepai/core/vector_db.py
Modify the `openai_with_expo_backoff` function to add a timeout to the Redis query and wrap it with the backoff decorator.
---
+++
@@ -1,11 +1,21 @@
cache_keys = [hash_sha256(text) + CACHE_VERSION for text in batch]
- try:
- for i, cache_value in enumerate(redis_client.mget(cache_keys)):
- if cache_value:
- embeddings[i] = np.array(json.loads(cache_value))
- except Exception as e:
- logger.exception(e)
- # not stored in cache call openai
+
+ @backoff.on_exception(backoff.expo, TimeoutError, max_tries=5)
+ def get_cached_embeddings():
+ try:
+ cache_values = redis_client.mget(cache_keys, timeout=5)
+ for i, cache_value in enumerate(cache_values):
+ if cache_value:
+ embeddings[i] = np.array(json.loads(cache_value))
+ except TimeoutError:
+ logger.warning("Redis query timed out, retrying...")
+ raise
+ except Exception as e:
+ logger.exception(e)
+
+ get_cached_embeddings()
+
+ # not stored in cache, call openai
batch = [
text for i, text in enumerate(batch) if embeddings[i] is None
] # remove all the cached values from the batch
Step 3: 🔄️ Validating
Your changes have been successfully made to the branch sweep/sweep_connection_closed_by_server_redis
. I have validated these changes using a syntax checker and a linter.
Tip
To recreate the pull request, edit the issue title or description.
This is an automated message generated by Sweep AI.
from sweep.
Related Issues (20)
- Sweep: when events are handled, run a sentry set user and set to organization account HOT 1
- Sweep: downgrade to warning HOT 1
- Sweep: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte HOT 1
- Sweep: can't compare offset-naive and offset-aware datetimes HOT 1
- Sweep: 422 {"message": "Validation Failed", "errors": [{"resource": "Label", "code": "already_exists", "field": "name"}], "documentation_url": "https://docs.github.com/rest/issues/labels#create-a-label"} HOT 1
- Sweep: turn this into a warning HOT 1
- Sweep: AttributeError - 'str' object has no attribute 'file_path' HOT 1
- Sweep: TypeError - Unhandled decode() argument 'encoding' must be str, not None HOT 1
- Sweep: ZeroDivisionError - float division by zero HOT 1
- Sweep: Fix this bug HOT 1
- Sweep: Turn this error into a warning.
- Sweep: Turn this error into a warning HOT 1
- Sweep: Unhandled 'NoneType' object has no attribute 'splitlines' HOT 1
- Sweep: UnknownObjectException Level: Error 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/pulls/pulls#get-a-pull-request"} HOT 1
- Sweep: Fix the following sentry bug HOT 1
- Sweep: Handle this error in sweepai/utils/ticket_rendering_utils.py HOT 1
- Sweep: Fix this error ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) HOT 1
- Sweep: Fix this sentry error PREdited pull_request.body Input should be a valid string HOT 1
- Sweep: Handle this sentry error: 409 {"message": "Git Repository is empty.", "documentation_url": "https://docs.github.com/rest/commits/commits#list-commits"} HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sweep.