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

Update cohere client to V2 #417

Merged
merged 4 commits into from
Feb 3, 2025
Merged

Update cohere client to V2 #417

merged 4 commits into from
Feb 3, 2025

Conversation

jgpruitt
Copy link
Collaborator

@jgpruitt jgpruitt commented Feb 3, 2025

Updates cohere client to 5.13.11 which adds support for the V2 endpoints for embed, chat, and rerank. This introduces breaking changes to the corresponding pgai functions, but unlocks the latest features from cohere.

This PR also adds support for Cohere to text-to-sql. This is feature-flagged, non-production code.

I keep API keys in environment variables in a .env file. If I ran `just test-server`
from my dev host, the command in build.py was explicitly setting the environment vars
in the docker exec command without reading the .env file yielding empty environment vars.
build.py does not load a .env file because we don't want build.py to depend on any 3rd
party dependencies (just std lib).

This change fixes the issue. The test server will load the .env file. No need to set env
vars explicitly in the `docker exec` call.
@jgpruitt jgpruitt self-assigned this Feb 3, 2025
@jgpruitt jgpruitt marked this pull request as ready for review February 3, 2025 23:05
@jgpruitt jgpruitt requested a review from a team as a code owner February 3, 2025 23:05
Comment on lines +102 to +103
response = client.embed(texts=[input_text], model=model, embedding_types=["float"], **args)
return response.embeddings.float[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any use case to exposing the embedding types to the end user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe? I did a brief look to see if any alternate embedding type from cohere would map to an alternate vector type from pgvector, but it wasn't obvious that any did.

@jgpruitt jgpruitt merged commit 9c4410f into main Feb 3, 2025
5 checks passed
@jgpruitt jgpruitt deleted the jgpruitt/cohere branch February 3, 2025 23:30
-e VOYAGE_API_KEY=${VOYAGE_API_KEY} \
-it -w /pgai/tests/vectorizer pgai-ext fastapi dev server.py
"""
cmd = """docker exec -it -w /pgai/tests/vectorizer pgai-ext uv run fastapi dev server.py"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the env-var passing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in the commit message. The test server looks up these env cars in a .env file, but for some reason putting these explicitly on the docker exec command was causing them to be empty. It took precedence over the dot env file

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

Successfully merging this pull request may close these issues.

3 participants