Skip to content
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

Router stuck in WARNING semantic_router.utils.logger Retrying in 2 seconds #354

Open
mvohal opened this issue Jul 15, 2024 · 3 comments
Open

Comments

@mvohal
Copy link

mvohal commented Jul 15, 2024

openai | 1.35.13
langchain | 0.2.8
langchain-core | 0.2.19
semantic-router | 0.0.52

`from openai import OpenAI
import os
os.environ["OPENAI_API_KEY"] = "sk-XXXXX"
from semantic_router import Route, RouteLayer
from semantic_router.encoders import OpenAIEncoder

repo_route = Route(
name="get-repos",
utterances=[
"what are the repos in ADSI?",
"what are the files in the repo",
],
)

project_route = Route(
name="get-project-details",
utterances=[
"is there a project called ADSI?",
"can you give me details around the project ADSI?",
],
)

routes=[repo_route, project_route]

rl = RouteLayer(encoder = OpenAIEncoder(name="text-embedding-3-small"),routes=routes)
route=rl("list all the files in the repo ADS")
print(route.name)`

2024-07-15 15:50:20 WARNING semantic_router.utils.logger Retrying in 2 seconds...
2024-07-15 15:50:27 WARNING semantic_router.utils.logger Retrying in 4 seconds...
2024-07-15 15:50:38 WARNING semantic_router.utils.logger Retrying in 8 seconds...
2024-07-15 15:50:57 WARNING semantic_router.utils.logger Retrying in 16 seconds...
2024-07-15 15:51:31 WARNING semantic_router.utils.logger Retrying in 32 seconds...
2024-07-15 15:52:38 WARNING semantic_router.utils.logger Retrying in 64 seconds...
2024-07-15 15:52:38 INFO semantic_router.utils.logger Returned embeddings: None
Traceback (most recent call last):
File "/Users/mmvohal/code/ai-thon/pages/📖FOSS.py", line 27, in
rl = RouteLayer(encoder = OpenAIEncoder(name="text-embedding-ada-002"),routes=routes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mmvohal/code/ai-thon/ai-thon/lib/python3.11/site-packages/semantic_router/layer.py", line 222, in init
self._add_routes(routes=self.routes)
File "/Users/mmvohal/code/ai-thon/ai-thon/lib/python3.11/site-packages/semantic_router/layer.py", line 465, in _add_routes
embedded_utterances = self.encoder(all_utterances)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mmvohal/code/ai-thon/ai-thon/lib/python3.11/site-packages/semantic_router/encoders/openai.py", line 135, in call
raise ValueError(f"No embeddings returned. Error: {error_message}")
ValueError: No embeddings returned. Error: Connection error.

@jamescalam
Copy link
Member

The warnings you're seeing here are from the retry mechanism for embeddings. The encoder retries if it gets an erroneous (or no) response from OpenAI, likely issues:

  1. Actual network connection issues
  2. API key?
  3. Does your API key have permissions to create embeddings?

@mvohal
Copy link
Author

mvohal commented Jul 16, 2024

No network connection issues
API Key is correct
Everything is working as expected on Windows machine but issue is on mac os (M1)

@jess-lord
Copy link

i also get this. I was testing cohere/huggingface/openai. OpenAI worked, then later in the day it stopped working giving a similar error to OP. Generated a new API key with no restrictions and same behaviour.

2024-08-12 14:52:33 WARNING semantic_router.utils.logger Retrying in 2 seconds...
2024-08-12 14:52:38 WARNING semantic_router.utils.logger Retrying in 4 seconds...
Traceback (most recent call last):
...
BadRequestError: Error code: 400 - {'error': {'message': "'$.input' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference.", 'type': 'invalid_request_error', 'param': None, 'code': None}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants